private void button2_Click(object sender, EventArgs e) { bool check = false; foreach (var item in falseStatus) { if (idPhieuNhap == item) { check = true; } } if (check == true) { var tenPhieuNhap = ""; var time = DateTime.Now.ToString(); PhieuNhapDao dao = new PhieuNhapDao(); PhieuNhap pn = new PhieuNhap(); pn.TieuDe = tieude; tenPhieuNhap = pn.TieuDe; pn.TongTien = tongtien; //var idPhieuNhap = dao.getIdPhieuNhap_fromName(tenPhieuNhap); this.Hide(); //Form_Update_AddNew f_uq = new Form_Update_AddNew(idPhieuNhap); Form_UpdateQty_AddNewBook f_uq = new Form_UpdateQty_AddNewBook(idPhieuNhap, pn.TieuDe, pn.TongTien.GetValueOrDefault()); f_uq.ShowDialog(); } else { MessageBox.Show("Phiếu nhập đã hoàn thành, không thể sửa !"); } }
private void button3_Click(object sender, EventArgs e) { bool check = false; foreach (var item in falseStatus) { if (idPhieuNhap == item) { check = true; } } if (check == true) { if (MessageBox.Show("Xóa phiếu nhập ??", "Xóa phiếu nhập", MessageBoxButtons.YesNo) == DialogResult.Yes) { // xoa phieu nhap PhieuNhapDao dao = new PhieuNhapDao(); var res = dao.deletePhieuNhap(idPhieuNhap); if (res > 0) { MessageBox.Show("Đã xóa phiếu nhập !"); populateGridViewLeft(); } else { MessageBox.Show("Xóa không thành công !"); } } } else { MessageBox.Show("Phiếu nhập đã hoàn thành, không thể xóa !"); } }
private void button5_Click(object sender, EventArgs e) { if (MessageBox.Show("Đã hoàn thành việc nhập và thoát phiên làm việc ? ", "Exit ", MessageBoxButtons.YesNo) == DialogResult.Yes) { PhieuNhapDao dao = new PhieuNhapDao(); dao.updateStatusTrue(idPhieuNhap); this.Close(); } }
private void button1_Click(object sender, EventArgs e) { if (comboBoxBookTitleuq.Text == "" || textBoxQuantityuq.Text == "") { MessageBox.Show("Hãy nhập đủ thông tin !"); } var qty = int.TryParse(textBoxQuantityuq.Text, out _); if (qty == false) { MessageBox.Show("Kiểm tra số lượng nhập !"); } else { // Bây giờ tạo thêm ChiTietPhieuNhap ChiTietPhieuNhapDao ctpnDao = new ChiTietPhieuNhapDao(); ChiTietPhieuNhap ctpn = new ChiTietPhieuNhap() { MaPhieuNhap = idPhieuNhap, MaSach = int.Parse(textBoxIDuq.Text), SoLuong = int.Parse(textBoxQuantityuq.Text) }; var resss = ctpnDao.insertChiTietPhieuNhap(ctpn.MaPhieuNhap, ctpn.MaSach, ctpn.SoLuong); // update lại số lượng tồn SachDao sDao = new SachDao(); sDao.updateQuantity(ctpn.MaSach, ctpn.SoLuong); bindDataToGrid(dataGridView2); // update tong tien var bookPrice = sDao.getPriceById(ctpn.MaSach); var soluong = ctpn.SoLuong; PhieuNhapDao pnDao = new PhieuNhapDao(); pnDao.updateAmount(idPhieuNhap, (bookPrice * soluong).GetValueOrDefault()); labelAmount2.Text = pnDao.getAmountById(idPhieuNhap).ToString(); clearAllUpdateQuantity(); } }
private void button1_Click(object sender, EventArgs e) { var tenPhieuNhap = ""; var time = DateTime.Now.ToString(); PhieuNhapDao dao = new PhieuNhapDao(); PhieuNhap pn = new PhieuNhap(); pn.TieuDe = textBoxTitle.Text + " " + time; tenPhieuNhap = pn.TieuDe; pn.MoTa = richTextBoxDes.Text; pn.TongTien = 0; pn.TrangThai = false; dao.insertPhieuNhap(pn); //var idPhieuNhap = dao.getIdPhieuNhap_fromName(tenPhieuNhap); var idPhieuNhap = dao.getNewestId(); this.Hide(); //Form_Update_AddNew f_uq = new Form_Update_AddNew(idPhieuNhap); Form_UpdateQty_AddNewBook f_uq = new Form_UpdateQty_AddNewBook(idPhieuNhap, pn.TieuDe, pn.TongTien.GetValueOrDefault()); f_uq.ShowDialog(); f_uq.Closed += (s, args) => this.Close(); }