コード例 #1
0
ファイル: Department.cs プロジェクト: hpbaotho/benhvien
 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
ファイル: Department.cs プロジェクト: hpbaotho/benhvien
 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
ファイル: Department.cs プロジェクト: hpbaotho/benhvien
 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;
 }