Пример #1
0
 public static int InsertDepartment(Department newDepartment)
 {
     String sqlInsert = @"INSERT INTO DEPARTMENT(DEPARTMENTNAME)
                         VALUES        (@DEPARTMENTNAME)";
     SqlParameter[] sqlParameters = { new SqlParameter("@DEPARTMENTNAME", newDepartment.DepartmentName) };
     return SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters);
 }
Пример #2
0
 private void buttonOk_Click(object sender, EventArgs e)
 {
     if (!superValidator1.Validate())
         return;
         try
         {
             if (UserAction == "edit")
             {
                 DepartmentDetail.DepartmentName = textBoxDepartmentName.Text;
                 DialogResult dialogResult = MessageBox.Show("Xác nhận cập nhập thông tin phòng ban", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                 if (dialogResult == DialogResult.Yes)
                 {
                     if (Department.UpdateDepartment(DepartmentDetail) > 0)
                         MessageBox.Show("Cập nhập thông tin phòng ban thành công thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 
             }
             else
             {
                 Department newDepartment = new Department(0, textBoxDepartmentName.Text);
                 if (Department.InsertDepartment(newDepartment) > 0)
                     MessageBox.Show("Thêm phòng ban thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         catch
         {
             MessageBox.Show("Lỗi dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     
     this.Close();
 }
Пример #3
0
 public FormDepartmentDetail(Department departmentDetail, String userAction)
 {
     InitializeComponent();
     this.DepartmentDetail = departmentDetail;
     this.UserAction = userAction;
     if (this.UserAction == "edit")
         SetDepartmentDetail(departmentDetail);
 }
Пример #4
0
 public static int UpdateDepartment(Department updateDepartment)
 {
     string sqlUpdate = @"UPDATE DEPARTMENT
                         SET DEPARTMENTNAME = @DEPARTMENTNAME
                         WHERE (DEPARTMENTID =@DEPARTMENTID)";
     SqlParameter[] sqlParameters = { new SqlParameter("@DEPARTMENTID", updateDepartment.DepartmentID),
                                    new SqlParameter("@DEPARTMENTNAME", updateDepartment.DepartmentName)};
     return SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters);
 }
Пример #5
0
 public static Department GetDepartment(int departmentID)
 {
     Department newDepartment = new Department();
     int tempInterger;
     string sqlSelect = @"SELECT        DEPARTMENTID, DEPARTMENTNAME
                         FROM            DEPARTMENT
                         WHERE           (DEPARTMENTID=@DEPARTMENTID)";
     SqlParameter[] sqlParameters = { new SqlParameter("@DEPARTMENTID", departmentID) };
     DataTable dataTable = SqlResult.ExecuteQuery(sqlSelect,sqlParameters);
     if (dataTable.Rows.Count > 0)
     {
         int.TryParse(dataTable.Rows[0][0].ToString(), out tempInterger);
         newDepartment.DepartmentID = tempInterger;
         newDepartment.DepartmentName = dataTable.Rows[0][1].ToString();
     }
     return newDepartment;
 }
Пример #6
0
 private void SetDepartmentDetail(Department departmentDetail)
 {
     textBoxDepartmentID.Text = departmentDetail.DepartmentID.ToString();
     textBoxDepartmentName.Text = departmentDetail.DepartmentName;
 }