Пример #1
0
        public static void staffDepartmentInsert(DepartmentStaff depStaff)
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.Connection  = Common.getConnection();
                cmd.CommandText = "Staff_Department_Insert";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter sDepartmentName = new SqlParameter("@departmentName", depStaff.departmentName);
                sDepartmentName.SqlDbType = System.Data.SqlDbType.NVarChar;
                cmd.Parameters.Add(sDepartmentName);

                cmd.ExecuteNonQuery();
            }
        }
Пример #2
0
        public static void staffDepartmentDelete(DepartmentStaff depStaff)
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.Connection  = Common.getConnection();
                cmd.CommandText = "Staff_Department_Delete";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter iDepartmentId = new SqlParameter("@departmentId", depStaff.departmentId);
                iDepartmentId.SqlDbType = System.Data.SqlDbType.Int;
                cmd.Parameters.Add(iDepartmentId);

                cmd.ExecuteNonQuery();
            }
        }
Пример #3
0
        public static List <DepartmentStaff> getDepartmentList()
        {
            List <DepartmentStaff> DepartmentList = new List <DepartmentStaff>();

            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.Connection  = Common.getConnection();
                cmd.CommandText = "Staff_Department_Select";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                da.Fill(dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DepartmentStaff dep = new DepartmentStaff();
                    dep.departmentName = dt.Rows[i]["departmentName"].ToString();
                    dep.departmentId   = Int32.Parse(dt.Rows[i]["departmentId"].ToString());
                    DepartmentList.Add(dep);
                }
            }
            return(DepartmentList);
        }