private void btnSuaSP_Click(object sender, EventArgs e) { if (texMaHoaDon.Text == null || texMaHoaDon.Text == "") { MessageBox.Show("Bạn Cần Phải Nhập Hóa Đơn Để Thêm Sản Phâm"); return; } if (texMaSP.Text == null || texMaSP.Text == "") { MessageBox.Show("Bạn Cần Chọn Sản Phẩm Đền Thêm Vào Hóa Đơn"); return; } CT_PhieuNhap cT_PhieuNhap = new CT_PhieuNhap() { MaPhieuNhap = texMaHoaDon.Text, SanPham = texMaSP.Text, TenSanPham = texTenSP.Text, SoLuong = int.Parse(texSoLuong.Text), GhiChu = " ", DonGia = double.Parse(texDonGiaNhap.Text), TongTien = double.Parse(texSoLuong.Text) * double.Parse(texDonGiaNhap.Text) }; HienThiCT_PhieuNhapBLL.CapNhapThongTinCT_HoaDonNhap(cT_PhieuNhap); }
private void btnLuu_Click(object sender, EventArgs e) { PhieuNhapDTO phieuNhap = new PhieuNhapDTO(); phieuNhap.MaPN = txtPhieu.Text; phieuNhap.NCC = txtMaNCC.Text; phieuNhap.KhoXuat = int.Parse(cbKhoXuat.SelectedValue.ToString()); phieuNhap.Ngay = txtNgay.Text; phieuNhap.NgayGiao = txtNgayGiao.Text; phieuNhap.HanThanhToan = txtHanThanhToan.Text; phieuNhap.GhiChu = txtGhiChu.Text; phieuNhap.TongTien = tongTien; PhieuNhapBUS phieuNhapBUS = new PhieuNhapBUS(); phieuNhapBUS.LuuPhieuNhap(phieuNhap); int i = 0; foreach (DataGridViewRow row in dgvNhapHang.Rows) { CT_PhieuNhap cT_PhieuNhap = new CT_PhieuNhap(); cT_PhieuNhap.MaPN = txtPhieu.Text; cT_PhieuNhap.STT = i; cT_PhieuNhap.TenHang = row.Cells["TenHang"].Value.ToString(); cT_PhieuNhap.DonVi = 1; cT_PhieuNhap.DonGia = float.Parse(row.Cells["DonGia"].Value.ToString()); cT_PhieuNhap.ThanhTien = float.Parse(row.Cells["ThanhTien"].Value.ToString()); phieuNhapBUS = new PhieuNhapBUS(); phieuNhapBUS.LuuCTPhieuNhap(cT_PhieuNhap); } MessageBox.Show("Lưu thành công"); }
public int ThemCTPhieuNhap(CT_PhieuNhap ctpn) { string sql = "insert into CT_PHIEU_NHAP(MaPhieuNhap, MaHang, SoLuong, DonGia, GhiChu, ThanhTien) " + string.Format("values ('{0}','{1}',{2},{3}, N'{4}', {5})", ctpn.MaPhieuNhap, ctpn.MaHang, ctpn.SoLuong, ctpn.DonGia, ctpn.GhiChu, ctpn.ThanhTien); return(Execute.InsertUpdateDelete(sql)); }
public ActionResult DeleteConfirmed(int id) { CT_PhieuNhap cT_PhieuNhap = db.CT_PhieuNhap.Find(id); db.CT_PhieuNhap.Remove(cT_PhieuNhap); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,DonGiaNhap,SoLuong,ThanhTien,MaPhieu,MaSach")] CT_PhieuNhap cT_PhieuNhap) { if (ModelState.IsValid) { db.Entry(cT_PhieuNhap).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaPhieu = new SelectList(db.PhieuNhaps, "MaPhieu", "NguoiGiaoSach", cT_PhieuNhap.MaPhieu); ViewBag.MaSach = new SelectList(db.Saches, "MaSach", "TenSach", cT_PhieuNhap.MaSach); return(View(cT_PhieuNhap)); }
// GET: CT_PhieuNhap/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CT_PhieuNhap cT_PhieuNhap = db.CT_PhieuNhap.Find(id); if (cT_PhieuNhap == null) { return(HttpNotFound()); } return(View(cT_PhieuNhap)); }
public ActionResult Create([Bind(Include = "ID,DonGiaNhap,SoLuong,ThanhTien,MaPhieu,MaSach")] CT_PhieuNhap cT_PhieuNhap) { if (ModelState.IsValid) { cT_PhieuNhap.ThanhTien = cT_PhieuNhap.SoLuong * cT_PhieuNhap.DonGiaNhap; db.CT_PhieuNhap.Add(cT_PhieuNhap); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaPhieu = new SelectList(db.PhieuNhaps, "MaPhieu", "NguoiGiaoSach", cT_PhieuNhap.MaPhieu); ViewBag.MaSach = new SelectList(db.Saches, "MaSach", "TenSach", cT_PhieuNhap.MaSach); return(View(cT_PhieuNhap)); }
// GET: CT_PhieuNhap/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CT_PhieuNhap cT_PhieuNhap = db.CT_PhieuNhap.Find(id); if (cT_PhieuNhap == null) { return(HttpNotFound()); } ViewBag.MaPhieu = new SelectList(db.PhieuNhaps, "MaPhieu", "NguoiGiaoSach", cT_PhieuNhap.MaPhieu); ViewBag.MaSach = new SelectList(db.Saches, "MaSach", "TenSach", cT_PhieuNhap.MaSach); return(View(cT_PhieuNhap)); }
public void CapNhapThongTinCT_HoaDonNhap(CT_PhieuNhap cT_PhieuNhap) { if (cT_PhieuNhap.SoLuong == null) { cT_PhieuNhap.SoLuong = 0; } if (cT_PhieuNhap.GhiChu == null) { cT_PhieuNhap.GhiChu = " "; } if (cT_PhieuNhap.TongTien == null) { cT_PhieuNhap.TongTien = 0; } if (cT_PhieuNhap.DonGia == null) { cT_PhieuNhap.DonGia = 0; } hienThiCT_PhieuNhapDAL.CapNhapThongTinCT_HoaDonNhap(cT_PhieuNhap); }
public bool AddPhieuNhap(PhieuNhap pn) { try { pnSer.AddData(pn); foreach (DataRow row in pn.DtPN.Rows) { CT_PhieuNhap ctpn = new CT_PhieuNhap(); ctpn.MaPN = pn.MaPN; ctpn.MaSach = row["MaSach"].ToString(); ctpn.SoLuong = int.Parse(row["SoLuong"].ToString()); //Get số lượng từ chi tiết phiếu nhập và cộng với số lượng sẵn có trong kho if (!(Object.ReferenceEquals(null, sachSer.GetData(ctpn.MaSach)))) { int soLuongTon = sachSer.GetData(ctpn.MaSach).SlTon + ctpn.SoLuong; sachSer.UpdateSL(ctpn.MaSach, soLuongTon, pn.NgayLapPN); ctpnSer.AddData(ctpn); } else { Sach s = new Sach(row["MaSach"].ToString().Trim(), row["TenSach"].ToString().Trim(), row["MaTL"].ToString().Trim(), row["MaNXB"].ToString().Trim(), row["MaTG"].ToString().Trim(), pn.NgayLapPN, Int32.Parse(row["GiaBan"].ToString()), Int32.Parse(row["GiaNhap"].ToString()), Int32.Parse(row["GiamGia"].ToString()), Int32.Parse(row["SoLuong"].ToString())); sachSer.AddData(s); ctpnSer.AddData(ctpn); } } }catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Error: " + ex.ToString(), "Lỗi", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return(false); } return(true); }
public bool AddData(CT_PhieuNhap ctpn) { cmd.CommandText = String.Format("Insert into CT_PhieuNhap values('{0}','{1}', '{2}') ", ctpn.MaPN, ctpn.MaSach, ctpn.SoLuong); cmd.CommandType = CommandType.Text; cmd.Connection = con.Connection; try { con.OpenConn(); cmd.ExecuteNonQuery(); return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Error: " + ex.ToString(), "Lỗi", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); con.CloseConn(); cmd.Dispose(); return(false); } return(false); }
private void btnLLuuSP_Click(object sender, EventArgs e) { CT_PhieuNhap cT_PhieuNhap = new CT_PhieuNhap() { MaPhieuNhap = texMaHoaDon.Text, SanPham = texMaSP.Text, TenSanPham = texTenSP.Text, SoLuong = int.Parse(texSoLuong.Text), GhiChu = " ", DonGia = double.Parse(texDonGiaNhap.Text), TongTien = double.Parse(texSoLuong.Text) * double.Parse(texDonGiaNhap.Text) }; int k = 0; if (DanhSachSanPhamTheoHoaDơn.Count != 0) { foreach (CT_PhieuNhap sp in DanhSachSanPhamTheoHoaDơn) { if (cT_PhieuNhap.SanPham == sp.SanPham && cT_PhieuNhap.MaPhieuNhap == sp.MaPhieuNhap) { sp.SoLuong += cT_PhieuNhap.SoLuong; break; } k++; if (k == DanhSachSanPhamTheoHoaDơn.Count && sp.SanPham != cT_PhieuNhap.SanPham && cT_PhieuNhap.MaPhieuNhap == sp.MaPhieuNhap) { DanhSachSanPhamTheoHoaDơn.Add(cT_PhieuNhap); break; } } } else { DanhSachSanPhamTheoHoaDơn.Add(cT_PhieuNhap); } HienThiDanhSachSanPhamHD(DanhSachSanPhamTheoHoaDơn); }
public bool ThemMoiCT_PhieuNhap(CT_PhieuNhap cT_PhieuNhap) { try { OpenDataBase(); SqlCommand sqlCommand = new SqlCommand(); List <CT_PhieuNhap> DanhSachSP = new List <CT_PhieuNhap>(); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "ThemMoiCT_PhieuNhap"; sqlCommand.Parameters.Add("@MaPhieuNhap", SqlDbType.Char).Value = cT_PhieuNhap.MaPhieuNhap; sqlCommand.Parameters.Add("@MaSanPham", SqlDbType.Char).Value = cT_PhieuNhap.SanPham; sqlCommand.Parameters.Add("@SoLuong", SqlDbType.Int).Value = cT_PhieuNhap.SoLuong; sqlCommand.Parameters.Add("@DonGiaNhap", SqlDbType.Money).Value = cT_PhieuNhap.DonGia; sqlCommand.Parameters.Add("@TongTien", SqlDbType.Money).Value = cT_PhieuNhap.TongTien; sqlCommand.Parameters.Add("@GhiChu", SqlDbType.NVarChar).Value = cT_PhieuNhap.GhiChu; sqlCommand.Connection = sqlConnection; int k = sqlCommand.ExecuteNonQuery(); return(k > 0); } catch (Exception ex) { throw ex; } }
public int ThemCTPhieuNhap(CT_PhieuNhap ctpn) { return(xl_ctpn.ThemCTPhieuNhap(ctpn)); }
public int LuuCTPhieuNhap(CT_PhieuNhap p) { string sql = string.Format("INSERT INTO CT_PN VALUES ('{0}','{1}', '{2}', '{3}', '{4}', '{5}', '{6}')", p.MaPN, p.STT, p.TenHang, p.DonGia, p.SoLuong, p.DonGia, p.ThanhTien); return(dB.ExecuteNonQuery(System.Data.CommandType.Text, sql)); }
private void BtnLuu_Click(object sender, EventArgs e) { if (gvPhieuNhap.Rows.Count <= 1) { MessageBox.Show("Dữ liệu trống, không thể lưu"); } else if (lkueMaNCC.EditValue == null) { MessageBox.Show("Vui lòng chọn Khách Hàng"); } else { PhieuNhap pn = new PhieuNhap(); pn.MaPhieu = txtMaPhieu.Text; pn.MaNCC = lkueMaNCC.EditValue.ToString(); pn.NgayLap = DateTime.Parse(deNgayLap.EditValue.ToString()); pn.GhiChu = rtxtGhiChu.Text; pn.SoHoaDonVAT = txtSoHDVAT.Text; pn.MaNVLap = lkueMaNV.EditValue.ToString(); pn.SoPhieuNhapTay = txtSoPhieuNhapTay.Text; pn.MaKhoNhap = lkueKho.EditValue.ToString(); pn.DieuKhoanThanhToan = cbDKTT.Text; pn.HinhThucThanhToan = cbHTTT.Text; pn.HanThanhToan = DateTime.Parse(deHanThanhToan.EditValue.ToString()); pn.DaTra = 0; pn.TongTien = int.Parse(nmrThanhToan.Value.ToString()); List <CT_PhieuNhap> lstCT_PN = new List <CT_PhieuNhap>(); for (int i = 0; i < gvPhieuNhap.Rows.Count - 1; i++) { CT_PhieuNhap ctpn = new CT_PhieuNhap(); ctpn.MaPhieuNhap = pn.MaPhieu; ctpn.MaHang = gvPhieuNhap.Rows[i].Cells["colMaHang"].Value.ToString(); ctpn.SoLuong = int.Parse(gvPhieuNhap.Rows[i].Cells["colSoLuong"].Value.ToString()); ctpn.DonGia = int.Parse(gvPhieuNhap.Rows[i].Cells["colDonGia"].Value.ToString()); ctpn.ThanhTien = int.Parse(gvPhieuNhap.Rows[i].Cells["colThanhTien"].Value.ToString()); ctpn.GhiChu = gvPhieuNhap.Rows[i].Cells["colGhiChu"].Value.ToString(); lstCT_PN.Add(ctpn); } nv_pn.ThemPhieuNhap(pn); foreach (CT_PhieuNhap ct in lstCT_PN) { nv_ctpn.ThemCTPhieuNhap(ct); nv_hh.CapNhatSlTon(ct.MaHang, ct.SoLuong, 1); } AddNhatKy("Thêm", TenChucNang); MessageBox.Show("Thêm thành công"); if (cbInSauKhiLuu.Checked) { //print preview AddNhatKy("In", TenChucNang); PrintPreview(); } } }
public int LuuCTPhieuNhap(CT_PhieuNhap p) { return(phieuNhapDAO.LuuCTPhieuNhap(p)); }
public bool SuaCt_PhieuNhap(CT_PhieuNhap cT_PhieuNhap) { return(hienThiCT_PhieuNhapDAL.SuaCt_PhieuNhap(cT_PhieuNhap)); }
public bool ThemMoiCT_PhieuNhap(CT_PhieuNhap cT_PhieuNhap) { return(hienThiCT_PhieuNhapDAL.ThemMoiCT_PhieuNhap(cT_PhieuNhap)); }