Example #1
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (comboBoxCHNhan.SelectedValue.ToString() == comboBoxCHPP.SelectedValue.ToString())
     {
         MessageBox.Show("Lỗi! Hai Cửa Hàng Trùng Nhau.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         if (numericUpDownThemBotSL.Value <= Convert.ToInt32(textBoxSLTonCHPP.Text) && numericUpDownThemBotSL.Value > 0)
         {
             string id1 = comboBoxCHNhan.SelectedValue.ToString();
             string id2 = comboBoxCHPP.SelectedValue.ToString();
             string id  = textBoxMaKieu.Text;
             KhoHangBUS.KiemTraKho_CuaHang_MaKieu(id, id1);
             KhoHangBUS.KiemTraKho_CuaHang_MaKieu(id, id2);
             int sl = Convert.ToInt32(numericUpDownThemBotSL.Value);
             try{
                 ChiTietSPBUS.PhanChiSP(id, id1, id2, sl);
                 MessageBox.Show("Thành Công! Sản Phẩm Đã Được Phân Phối.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 khoHangBindingSource.DataSource = KhoHangBUS.GetAllKhoHangByMaKieu(id);
             }
             catch
             {
                 MessageBox.Show("Lỗi! Không Thể Thực Hiện Thao Tác.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Lỗi! Số Lượng Phân Phối Không Phù Hợp.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }