private void btnXacNhan_Click(object sender, EventArgs e) { eCTPhieuQlyKho ect = new eCTPhieuQlyKho(); ect._donVi = txtDonVi.Text; ect._maPhieuQly = cbbMaPhieuQL.Text; ect._maSP = cbbMaSP.Text; ect._tenSP = cbbTenSP.Text; ect._soLuongQly = Convert.ToInt32(txtSoluong.Text); ect._sTT = txtSTT.Text; if (bllCTqlkho.UpdateCTPQLKho(ect)) { MessageBox.Show("Sửa xong !!"); CheDoButton(true); btnXacNhan.Enabled = false; CheDoTextBox(false); listCTqlykho = bllCTqlkho.getCTPhieuQLKhoTheoMaPhieu(cbbMaPhieuQL.Text); duadulieulendgview(dgvCTPQLK, listCTqlykho); btnSua.Text = "Sửa"; } else { MessageBox.Show("bạn chưa chọn vào phiếu nhập kho cần sửa thông tin!"); } }
private void btnLuu_Click(object sender, EventArgs e) { try { eCTPhieuQlyKho newect = new eCTPhieuQlyKho(); newect._maPhieuQly = cbbMaPhieuQL.Text; newect._sTT = txtSTT.Text; newect._maSP = cbbMaSP.Text; newect._tenSP = cbbMaSP.Text; newect._soLuongQly = Convert.ToInt32(txtSoluong.Text); newect._donVi = txtDonVi.Text; bool kq = bllCTqlkho.AddAllCTPQLKho(newect); if (kq) { MessageBox.Show("Thêm thành công!!!"); } else { MessageBox.Show("Trùng mã phiếu!!"); } listCTqlykho = bllCTqlkho.getCTPhieuQLKhoTheoMaPhieu(cbbMaPhieuQL.Text); //listtp = blltp.getthuephongbymaphong(txtmaphong.Text); duadulieulendgview(dgvCTPQLK, listCTqlykho); CheDoButton(true); CheDoTextBox(false); btnThem.Text = "Thêm"; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public bool UpdateCTPQLKho(eCTPhieuQlyKho updatectpqlk) { try { Tbl_CTPhieuQLKho ctpqlk = DB.Tbl_CTPhieuQLKhos.Single(x => x.maPhieuql == updatectpqlk._maPhieuQly && x.maSP == updatectpqlk._maSP); ctpqlk.tenSP = updatectpqlk._tenSP; ctpqlk.sTT = updatectpqlk._sTT; ctpqlk.sLuongql = updatectpqlk._soLuongQly; ctpqlk.donVi = updatectpqlk._donVi; DB.SubmitChanges(); return(true); } catch { return(false); } }
public List <eCTPhieuQlyKho> getCTPhieuQLKhoTheoMaPhieu(string maphieu) { var dsctpqlk = DB.Tbl_CTPhieuQLKhos.Where(x => x.maPhieuql == maphieu).ToList(); List <eCTPhieuQlyKho> ls = new List <eCTPhieuQlyKho>(); foreach (Tbl_CTPhieuQLKho ctpqlktemp in dsctpqlk) { eCTPhieuQlyKho ctpqlk = new eCTPhieuQlyKho(); ctpqlk._maPhieuQly = ctpqlktemp.maPhieuql; ctpqlk._maSP = ctpqlktemp.maSP; ctpqlk._tenSP = ctpqlktemp.tenSP; ctpqlk._sTT = ctpqlktemp.sTT; ctpqlk._soLuongQly = Convert.ToInt32(ctpqlktemp.sLuongql); ctpqlk._donVi = ctpqlktemp.donVi; ls.Add(ctpqlk); } return(ls); }
public bool AddAllCTPQLKho(eCTPhieuQlyKho newctpqlk) { try { Tbl_CTPhieuQLKho ctpqlk = DB.Tbl_CTPhieuQLKhos.Single(x => x.maPhieuql == newctpqlk._maPhieuQly && x.maSP == newctpqlk._maSP); ctpqlk.maPhieuql = newctpqlk._maPhieuQly; ctpqlk.maSP = newctpqlk._maSP; ctpqlk.sTT = newctpqlk._sTT; ctpqlk.tenSP = newctpqlk._tenSP; ctpqlk.sLuongql = newctpqlk._soLuongQly; ctpqlk.donVi = newctpqlk._donVi; DB.Tbl_CTPhieuQLKhos.InsertOnSubmit(ctpqlk); DB.SubmitChanges(); return(true); } catch { return(false); } }