Beispiel #1
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (them)
     {
         try
         {
             BLDichVu btDV = new BLDichVu();
             btDV.ThemDichVu(this.txbMaDV.Text, this.txbTenDV.Text, Int32.Parse(this.txbGiaDV.Text), ref err);
             LoadData();
             MessageBox.Show("Đã thêm xong !!!");
         }
         catch (SqlException)
         {
             MessageBox.Show("Không thêm được hãy thử lại !!!");
         }
     }
     else
     {
         try
         {
             BLDichVu btDV = new BLDichVu();
             btDV.CapNhatDichVu(this.txbMaDV.Text, this.txbTenDV.Text, Int32.Parse(this.txbGiaDV.Text), ref err);
             LoadData();
             MessageBox.Show("Đã sửa xong!!!");
         }
         catch (SqlException)
         {
             MessageBox.Show("Không sửa được hãy thử lại !!!");
         }
     }
 }
Beispiel #2
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (Them)
     {
         try
         {
             BLDichVu blDv = new BLDichVu();
             blDv.ThemDichVu(this.txtMaDV.Text.Trim(), this.txtTenDV.Text.Trim(), Convert.ToInt32(this.txtGiaDV.Text.Trim()),
                             this.cbxMaNV.Text.Trim(), ref err);
             LoadData();
             MessageBox.Show("Đã Thêm Xong");
         }
         catch (SqlException)
         {
             MessageBox.Show("ko thêm đc. Lỗi r!.");
         }
     }
     else
     {
         BLDichVu blDv = new BLDichVu();
         blDv.CapNhatDichVu(this.txtMaDV.Text.Trim(), this.txtTenDV.Text.Trim(), Convert.ToInt32(this.txtGiaDV.Text.Trim()),
                            this.cbxMaNV.Text.Trim(), ref err);
         LoadData();
         MessageBox.Show("Đã sửa xong");
     }
 }
 private void btnLuu_Click(object sender, EventArgs e)
 {
     BLDV = new BLDichVu();
     if (Them)
     {
         if (this.txtMaDV.Text == "")
         {
             MessageBox.Show("Bạn chưa nhập mã!", "Thông báo",
                             MessageBoxButtons.OK, MessageBoxIcon.Warning);
             this.txtMaDV.Focus();
         }
         else
         {
             try
             {
                 if (BLDV.ThemDichVu(this.txtMaDV.Text, this.txtTenDichVu.Text, this.txtGia.Text, ref err))
                 {
                     LoadData();
                     MessageBox.Show("Đã thêm xong!");
                     Default_Button();
                 }
                 else
                 {
                     MessageBox.Show(err, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             catch (SqlException)
             {
                 MessageBox.Show("Không thêm được. Lỗi rồi!");
             }
         }
     }
     else
     {
         try
         {
             if (BLDV.CapNhatDichVu(this.txtMaDV.Text, this.txtTenDichVu.Text, this.txtGia.Text, ref err))
             {
                 LoadData();
                 MessageBox.Show("Đã sửa xong!");
                 Default_Button();
                 this.txtMaDV.Enabled = true;
             }
             else
             {
                 MessageBox.Show(this.err);
             }
         }
         catch (SqlException)
         {
             MessageBox.Show("Không sửa được. Lỗi rồi!");
         }
     }
 }