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); } } }
private void comboBoxMaKieu_SelectedIndexChanged(object sender, EventArgs e) { try { textBoxSLTonKieu.Text = ""; pictureBox.BackgroundImage = null; khoHangBindingSource.DataSource = null; textBoxMaKieu.Text = ""; string id = comboBoxMaKieu.SelectedValue.ToString(); CtSp = ChiTietSPBUS.Get1ChiTietSPByIDMaKieu(id); textBoxMaKieu.Text = CtSp.MaKieu; textBoxSLTonKieu.Text = CtSp.SoluongSP.ToString(); try { pictureBox.BackgroundImage = ConverBinaryToImage(CtSp.Anh); } catch { pictureBox.BackgroundImage = null; } khoHangBindingSource.DataSource = KhoHangBUS.GetAllKhoHangByMaKieu(CtSp.MaKieu); } catch { } }
public void LoadChiTietSP() { //try //{ LoadSP(); //} //catch //{ //} comboBoxCHNhan.DataSource = CuaHangBUS.GetAllCuaHang(); comboBoxCHNhan.DisplayMember = "TenCuaHang"; comboBoxCHNhan.ValueMember = "MaCuaHang"; comboBoxCHPP.DataSource = CuaHangBUS.GetAllCuaHang(); comboBoxCHPP.DisplayMember = "TenCuaHang"; comboBoxCHPP.ValueMember = "MaCuaHang"; comboBoxNXS.DataSource = HSXBUS.GetAllHSX(); comboBoxNXS.DisplayMember = "TenHSX"; comboBoxNXS.ValueMember = "MaHSX"; comboBoxNXS.SelectedValue = DSp.MaHSX; comboBoxDSP.DataSource = DongSanPhamBUS.GetAllDongSPByMaHSX(DSp.MaHSX); comboBoxDSP.DisplayMember = "TenDong"; comboBoxDSP.ValueMember = "MaDSP"; comboBoxDSP.SelectedValue = DSp.MaDSP; comboBoxSP.DataSource = SanPhamBUS.GetSanPhamByMaDSP(DSp.MaDSP); comboBoxSP.DisplayMember = "TenSP"; comboBoxSP.ValueMember = "MaSP"; comboBoxSP.SelectedValue = Sp.MaSP; comboBoxMaKieu.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(Sp.MaSP); comboBoxMaKieu.DisplayMember = "MaKieu"; comboBoxMaKieu.ValueMember = "MaKieu"; CtSp = ChiTietSPBUS.Get1ChiTietSPByIDMaKieu(IDMaKieu); comboBoxMaKieu.SelectedValue = CtSp.MaKieu; textBoxSLTonKieu.Text = CtSp.SoluongSP.ToString(); pictureBox.BackgroundImage = ConverBinaryToImage(CtSp.Anh); khoHangBindingSource.DataSource = KhoHangBUS.GetAllKhoHangByMaKieu(CtSp.MaKieu); }