private void comboBoxSP_SelectedIndexChanged(object sender, EventArgs e) { try { comboBoxMaKieu.DataSource = null; string id = comboBoxSP.SelectedValue.ToString(); comboBoxMaKieu.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id); comboBoxMaKieu.DisplayMember = "MaKieu"; comboBoxMaKieu.ValueMember = "MaKieu"; } catch { } }
private void btnXoaKieuSP_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có chắc muốn xóa dòng này không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { try { ChiTietSPBUS.XoaKieuSp(cmBoxMaKieuSP.SelectedValue.ToString()); MessageBox.Show("Xóa Thành Công!", "Thông Báo"); string id = cmBoxMaSP.SelectedValue.ToString(); chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id); } catch { MessageBox.Show("Không Thể Thực Hiện Thao Tác!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void comboBoxSP_SelectedIndexChanged(object sender, EventArgs e) { try { string id = comboBoxSP.SelectedValue.ToString(); textBoxTenSP.Text = SanPhamBUS.GetSanPhamByID(id).TenSP.ToString(); if (ChiTietSPBUS.GetChiTietSPByIDSP(id).Count != 0) { comboBoxMaKieu.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id); comboBoxMaKieu.DisplayMember = "MaKieu"; comboBoxMaKieu.ValueMember = "MaKieu"; } else { comboBoxMaKieu.DataSource = null; } } catch { comboBoxMaKieu.DataSource = null; } }
private void cmBoxSP_SelectedIndexChanged(object sender, EventArgs e) { try { string id = cmBoxSP.SelectedValue.ToString(); if (ChiTietSPBUS.GetChiTietSPByIDSP(id).Count != 0) { cmBoxKieuSP.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id); cmBoxKieuSP.DisplayMember = "MaKieu"; cmBoxKieuSP.ValueMember = "MaKieu"; } else { cmBoxKieuSP.DataSource = null; } } catch { cmBoxKieuSP.DataSource = null; } }
private void cmBoxMaSP_SelectedIndexChanged(object sender, EventArgs e) { string id = cmBoxMaSP.SelectedValue.ToString(); //cmBoxMaKieuSP.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id); //cmBoxMaKieuSP.DisplayMember = "MaKieu"; //cmBoxMaKieuSP.ValueMember = "MaKieu"; //cmBoxMauSP.DataSource = ChiTietSPBUS.GetAllMauSP(); //cmBoxMauSP.ValueMember = "MaMau"; //cmBoxMauSP.DisplayMember = "Mau"; if (IDMode == "ts") { chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id); cmBoxMaKieuSP.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id); cmBoxMaKieuSP.DisplayMember = "MaKieu"; cmBoxMaKieuSP.ValueMember = "MaKieu"; cmBoxMauSP.DataSource = ChiTietSPBUS.GetAllMauSP(); cmBoxMauSP.ValueMember = "MaMau"; cmBoxMauSP.DisplayMember = "Mau"; } else { chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDSP(IDMode, id); //cmBoxMaKieuSP.DataSource = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDSP(IDMode,id); if (ChiTietSPBUS.GetChiTietSPOderByMaCHByIDSP(IDMode, id).Count != 0) { cmBoxMaKieuSP.DataSource = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDSP(IDMode, id); cmBoxMaKieuSP.DisplayMember = "MaKieu"; cmBoxMaKieuSP.ValueMember = "MaKieu"; } else { cmBoxMaKieuSP.DataSource = null; } cmBoxMauSP.DataSource = ChiTietSPBUS.GetAllMauSP(); cmBoxMauSP.ValueMember = "MaMau"; cmBoxMauSP.DisplayMember = "Mau"; } }
private void cmBoxSP_SelectedIndexChanged(object sender, EventArgs e) { try { if (ID != null) { string id = cmBoxSP.SelectedValue.ToString(); SanPham sp = SanPhamBUS.GetSanPhamByID(id); cmBoxMaSP.SelectedValue = id; cmBoxSP.SelectedValue = id; txtboxMaSP.Text = sp.MaSP; txtTenSP.Text = sp.TenSP; txtNamSX.Text = sp.NămSX; txtboxCPU.Text = sp.CPU; txtboxGPU.Text = sp.CardManHinh; txtCamera.Text = sp.Camera; txtPort.Text = sp.Port; txtboxRam.Text = sp.Ram; txtboxManHinh.Text = sp.ManHinh; txtboxOS.Text = sp.OS; txtboxSim.Text = sp.Sim; txtboxPin.Text = sp.DungLuongPin; txtBoxTrongLuong.Text = sp.TrongLuong; txtboxBNngoai.Text = sp.BoNhoNgoai; txtboxBNtrong.Text = sp.BoNhoTrong; if (IDMode == "ts") { chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id); } else { chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPOderByMaCHByIDSP(IDMode, id); } //chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(ID); } } 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); }
private async void btnLuuKieuSP_Click(object sender, EventArgs e) { using (GalaxyMobileEntities db = new GalaxyMobileEntities()) { ChiTietSP sp = new ChiTietSP(); try { // sp.Anh = CovertImageToBinary(picBoxKieuSP.Image); sp.Anh = CovertImageToBinary(picBoxKieuSP.BackgroundImage); } catch { } sp.Gia = 0; sp.SoluongSP = 0; sp.MaKieu = textBoxMaKieu.Text; sp.MaSP = /*textBoxMaSP.Text;*/ cmBoxMaSP.SelectedValue.ToString(); sp.MaMau = cmBoxMauSP.SelectedValue.ToString(); try { if (NewCTSP) { db.ChiTietSPs.Add(sp); db.SaveChanges(); // await db.SaveChangesAsync(); MessageBox.Show("Thêm Thành Công!", "Thông Báo"); ChiTietSPBUS.Them_CTSPMoi_Into_KhoHang_(sp.MaKieu); } else { try { // sp.Anh = CovertImageToBinary(picBoxKieuSP.Image); sp.Anh = CovertImageToBinary(picBoxKieuSP.BackgroundImage); } catch { sp.Anh = ChiTietSPBUS.LayAnhKieuSP(cmBoxMaKieuSP.SelectedValue.ToString(), cmBoxMaSP.SelectedValue.ToString()); } int r = dgvCTSP.CurrentCell.RowIndex; //sp.Gia = Convert.ToDecimal(dgvCTSP.Rows[r].Cells[3].Value.ToString()); sp.Gia = Convert.ToDecimal(txtBoxGiaSP.Text); sp.SoluongSP = Convert.ToInt32(txtboxSoLuongAll.Text); db.ChiTietSPs.Attach(sp); db.Entry(sp).State = System.Data.Entity.EntityState.Modified; await db.SaveChangesAsync(); MessageBox.Show("Thay Đổi Thành Công!", "Thông Báo"); string id = cmBoxMaSP.SelectedValue.ToString(); chiTietSPBindingSource.DataSource = ChiTietSPBUS.GetChiTietSPByIDSP(id); } } catch { MessageBox.Show("Không Thể Thực Hiện Thao Tác!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } btnLuuKieuSP.Visible = false; btnHuyKieuSP.Visible = false; btnThemKieuSP.Visible = true; btnChinhSuaKieuSP.Visible = true; btnXoaKieuSP.Visible = true; textBoxMaKieu.ReadOnly = false; textBoxMaSP.ReadOnly = false; textBoxMaKieu.Visible = false; textBoxMaSP.Visible = false; txtBoxGiaSP.ReadOnly = true; textBoxMau.Visible = false; dgvCTSP.Enabled = true; }