domingo, 23 de outubro de 2011

Creating a web-site (Sign-up, delete, select existing itens and update) - Part 2

Good afternoon guys!
Let's go to continue our web-site?! I hope that you finished the first part, because that's needed to continue the our software development.
Now, We will develop the interface about our software and a little bit involving the programming in C#.
It's very important (in your personal projects or When You will make a test in one interview) divide your project into 3 parts:
1. B.O. : here we will encapsulate the fields names of the table who exist in our table
2.  DAL (Data Acces Layer): here, we will to develop the insert methods, update, exclusion and listing.
3. Interface: I don't need to explain, =P! Here we will to create the user interface.

1 - First layer: B.O.
We need to remember, or see your table to get the knowledge involving: the type of the field name, the orign name...
Open your Microsoft Visual Studio 2010 and follow the steps:

Picture 1: Creating a new project


Picture 2: Creating a new project [2]


Picture 3: Adding a new item


Picture 4: Adding a new item [2]

The class was created, and now we need to put ALL the fields names of the table "Department". Observe the next figure, we will encapsulate the fields and set the methods: get and set.
Observe too, the items who stays checked in red:
- First we need to set this class as public , because in the future we will use these fields in other project.
- When the type of the variable is integer, put: int?


Picture 5: Encapsulating the fields

We need to encapsulate the storeds procedures too, observe the Picture 6:

Ps: When we encapsulate a stored procedure, we just need to set the method get.


Compare your DepartmentBO with this code:
namespace Web.BO
{
    public class DepatmentBO
    {
        private int? idDepto;
        public int? IdDepto
        {
            get { return idDepto; }
            set { idDepto = value; }
        }

        private string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        private string phone;
        public string Phone
        {
            get { return phone; }
            set { phone = value; }
        }

        private string sp_department_sel = "spr_Department_sel";
        public string Sp_department_sel
        {
            get { return sp_department_sel; }
        }

        private string sp_department_ins = "spr_Department_insert";
        public string Sp_department_ins
        {
            get { return sp_department_ins; }
        }

        private string sp_department_delete = "spr_Department_delete";
        public string Sp_department_delete
        {
            get { return sp_department_delete; }
        }

        private string sp_department_update = "spr_Department_update";
        public string Sp_department_update
        {
            get { return sp_department_update; }
        }
    }
}


Make the same with the StaffBO.cs.
Compare your StaffBO with this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Web.BO
{
    public class StaffBO
    {
        private int? cod_depto;
        public int? Cod_depto
        {
            get { return cod_depto; }
            set { cod_depto = value; }
        }

        private string name;
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        private string wage;
        public string Wage
        {
          get { return wage; }
          set { wage = value; }
        }

        private string position;
        public string Position
        {
          get { return position; }
          set { position = value; }
        }

        private int? cod_staff;
        public int? Cod_staff
        {
          get { return cod_staff; }
          set { cod_staff = value; }
        }

        private DateTime admission_date;
        public DateTime Admission_date
        {
            get { return admission_date; }
            set { admission_date = value; }
        }

        private string sp_staff_insert = "spr_Staff_insert";
        public string Sp_staff_insert
        {
            get { return sp_staff_insert; }
        }

        private string sp_staff_delete = "spr_Staff_delete";
        public string Sp_staff_delete
        {
            get { return sp_staff_delete; }
        }

        private string sp_staff_update = "spr_Staff_update";
        public string Sp_staff_update
        {
            get { return sp_staff_update; }
        }

        private string sp_staff_sel = "spr_Staff_sel";
        public string Sp_staff_sel
        {
            get { return sp_staff_sel; }
        }
    }
}



Good bye guys. See you in the next post.

Nenhum comentário:

Postar um comentário