private void btnImport_Click(object sender, EventArgs e) { if (Uc_WareHouse.GetData.id == "") { MessageBox.Show("Do not have import bill yet"); } else { Uc_WareHouse.GetData.choose = 3; GetData.idSP = lbID.Text; //frmProductShow.GetData.idSP = lbID.Text; frmAmount amount = new frmAmount(); amount.ShowDialog(); if (frmAmount.GetData.sL != 0) { CTPhieuNhap ctpn = db.CTPhieuNhaps.Where(s => s.maphieu.Equals(Uc_WareHouse.GetData.id) && s.masp.Equals(lbID.Text)).FirstOrDefault(); if (ctpn != null) { MessageBox.Show("Already have this product in present bill"); } else { db.CTPN_Add(Uc_WareHouse.GetData.id, lbID.Text, frmAmount.GetData.sL); } } } }
public ActionResult Edit1(string id, string id2) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CTPhieuNhap cTPhieuNhap = new CTPhieuNhap(); var dsPN = db.CTPhieuNhaps.Where(x => x.MaPN == id); foreach (var i in dsPN) { if (i.MaSP == id2) { cTPhieuNhap = i; break; } } if (cTPhieuNhap == null) { return(HttpNotFound()); } ViewBag.MaPN = new SelectList(db.PhieuNhaps, "MaPN", "MaNCC", cTPhieuNhap.MaPN); ViewBag.MaSP = new SelectList(db.SanPhams, "MaSP", "TenSP", cTPhieuNhap.MaSP); return(View(cTPhieuNhap)); }
public ActionResult DeleteConfirmed(string id) { CTPhieuNhap cTPhieuNhap = db.CTPhieuNhaps.Find(id); db.CTPhieuNhaps.Remove(cTPhieuNhap); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult Put([FromBody] CTPhieuNhap x) { if (!ModelState.IsValid) { return(BadRequest("Not a valid data")); } CTPhieuNhapDAO.Instance.Update(x.MaCTPN, x.MaPN, x.MaHH, x.SoLuong, x.GiaNhap); return(Ok()); }
public IHttpActionResult Post([FromBody] CTPhieuNhap x) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } CTPhieuNhapDAO.Instance.Create(x.MaCTPN, x.MaPN, x.MaHH, x.SoLuong, x.GiaNhap);//(string MaCTPN, string MaPN, string MaHH, string SoLuong, string GiaNhap) return(Ok()); }
public ActionResult Edit([Bind(Include = "MaPN,MaSP,SoLuong,DonGia")] CTPhieuNhap cTPhieuNhap) { if (ModelState.IsValid) { db.Entry(cTPhieuNhap).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaPN = new SelectList(db.PhieuNhaps, "MaPN", "MaNCC", cTPhieuNhap.MaPN); ViewBag.MaSP = new SelectList(db.SanPhams, "MaSP", "TenSP", cTPhieuNhap.MaSP); return(View(cTPhieuNhap)); }
public List <CTPhieuNhap> GetList() { List <CTPhieuNhap> list = new List <CTPhieuNhap>(); DataTable data = DataProvider.Instance.ExecuteQuery("SELECT * FROM dbo.CTPHIEUNHAP"); foreach (DataRow item in data.Rows) { CTPhieuNhap obj = new CTPhieuNhap(item); list.Add(obj); } return(list); }
// GET: CTPhieuNhaps/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CTPhieuNhap cTPhieuNhap = db.CTPhieuNhaps.Find(id); if (cTPhieuNhap == null) { return(HttpNotFound()); } return(View(cTPhieuNhap)); }
// GET: CTPhieuNhaps/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CTPhieuNhap cTPhieuNhap = db.CTPhieuNhaps.Find(id); if (cTPhieuNhap == null) { return(HttpNotFound()); } ViewBag.MaPN = new SelectList(db.PhieuNhaps, "MaPN", "MaNCC", cTPhieuNhap.MaPN); ViewBag.MaSP = new SelectList(db.SanPhams, "MaSP", "TenSP", cTPhieuNhap.MaSP); return(View(cTPhieuNhap)); }
// GET: CTPhieuNhaps/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CTPhieuNhap cTPhieuNhap = db.CTPhieuNhaps.SingleOrDefault(c => c.MaPN == id); // CTPhieuNhap cTPhieuNhap = db.CTPhieuNhaps.Find(id); if (cTPhieuNhap == null) { return(HttpNotFound()); } return(View(cTPhieuNhap)); }
public ActionResult Delete1Confirmed(string id, string id2) { var dsPN = db.CTPhieuNhaps.Where(x => x.MaPN == id); CTPhieuNhap cTPhieuNhap = new CTPhieuNhap(); foreach (var i in dsPN) { if (i.MaSP == id2) { cTPhieuNhap = i; break; } } db.CTPhieuNhaps.Remove(cTPhieuNhap); db.SaveChanges(); return(RedirectToAction("Index")); }
private void button1_Click_1(object sender, EventArgs e) { try { string mausac = cb_MauSac.SelectedValue.ToString(); int kichco = int.Parse(cb_KichCo.SelectedValue.ToString()); string chatlieu = cb_ChatLieu.SelectedValue.ToString(); int masp = int.Parse(cb_SanPham.SelectedValue.ToString()); // viết cho phần hiển thị sản phẩm string tensp = cb_SanPham.Text; string Mausac = cb_MauSac.Text; string Chatlieu = cb_ChatLieu.Text; int kichcos = int.Parse(cb_KichCo.Text); float gia = float.Parse(txtGiaNhap.Text); int soluong = 0; try { soluong = int.Parse(txt_SoLuong.Text); CTPhieuNhap a = new CTPhieuNhap(); Cart giohang = new Cart(tensp, Mausac, Chatlieu, kichcos, gia, soluong, soluong * gia); cartList.Add(giohang); a.MaCTSp = SanPhamModels.SanPhams.getCTsp(chatlieu, kichco, mausac, masp); a.SoLuong = soluong; a.GiaNhap = gia; listCT.Add(a); soluongss++; txt_SoLuong.Text = null; button2.Enabled = true; button3.Enabled = true; foreach (Cart item in cartList) { tongtien += item.Giatien; } getdata(); } catch (Exception) { MessageBox.Show("Số lượng không được để trống và chỉ được nhập số"); } } catch (Exception) { MessageBox.Show("Không thể thêm sản phẩm"); } }
public static List <CTPhieuNhap> ChuyenDoiDTOCTPhieuNhap(DataTable bang) { List <CTPhieuNhap> kq = new List <CTPhieuNhap>(); foreach (DataRow dong in bang.Rows) { CTPhieuNhap a = new CTPhieuNhap(); a.MaChiTietNhap = dong["MaChiTietNhap"].ToString(); a.MaPhieuNhap = dong["MaPhieuNhap"].ToString(); a.MaSP = dong["MaSP"].ToString(); a.DonGiaSP = float.Parse(dong["DonGiaSP"].ToString()); a.ThanhTien = float.Parse(dong["ThanhTien"].ToString()); a.Thue = float.Parse(dong["Thue"].ToString()); a.SoLuongMua = int.Parse(dong["SoLuongMua"].ToString()); kq.Add(a); } return(kq); }
public bool DeleteCTPhieuNhap(CTPhieuNhap pn) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseAddress); //HTTP POST var postTask = client.DeleteAsync("ctphieunhap?MaCTPN=" + pn.MaCTPN); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { ListCTPhieuNhap = GetListCTPhieuNhap(); return(true); } else { return(false); } } }
public bool PutCTPhieuNhap(CTPhieuNhap ctpn) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseAddress); //HTTP POST var postTask = client.PutAsJsonAsync <CTPhieuNhap>("ctphieunhap", ctpn); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { ListCTPhieuNhap = GetListCTPhieuNhap(); return(true); } else { return(false); } } }
public ActionResult Delete1(string id, string id2) { if (id == null || id2 == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var dsPN = db.CTPhieuNhaps.Where(x => x.MaPN == id); CTPhieuNhap cTPhieuNhap = new CTPhieuNhap(); foreach (var i in dsPN) { if (i.MaSP == id2) { cTPhieuNhap = i; break; } } if (cTPhieuNhap == null) { return(HttpNotFound()); } return(View(cTPhieuNhap)); }
// Thêm chi tiết phiếu nhập public void ThemCTPN(CTPhieuNhap ctpn) { dah.ThucThiCauLenhSQL("INSERT INTO tblCTPN VALUES('" + ctpn.Mapn + "','" + ctpn.Masp + "','" + ctpn.Soluongnhap + "','" + ctpn.Dongianhap + "',(" + ctpn.Soluongnhap + " * " + ctpn.Dongianhap + "),'" + ctpn.Donvitinh + "')"); }
private void buttonThem_Click(object sender, EventArgs e) { //load du lieu loadPhieuNhap(XL_PhieuNhap.LayDuLieuPhieuNhap()); //co hieu int cohieu = 1; //phieu nhap string maphieunhap = textBoxMaPhieuNhap.Text; string ngaynhap = dateTimePickerNgayNhap.Value.ToString(); string hanthanhtoan = dateTimePickerHanThanhToan.Value.ToString(); string manhanvien = gridLookUpEditNhanVien.Text; string kho = gridLookUpEditKho.Text; string manhacungcap = gridLookUpEditNCC.Text; string dieukhoan = gridLookUpEditDieuKhoanThanhToan.Text; string hinhthucthanhtoan = gridLookUpEditHinhThucThanhToan.Text; string tientratruoc = textBoxTienTraTruoc.Text; //tien double TongTien = 0; int soluong; float gia; for (int i = 0; i < dataGridViewCTPhieuNhap.Rows.Count; i++) { //object m = dataGridViewCTPhieuNhap["SoLuong", i].Value; //object n = dataGridViewCTPhieuNhap["GiaLucNhap", i].Value; object n = dataGridViewCTPhieuNhap.Rows[i].Cells["GiaLucNhap"].Value; object m = dataGridViewCTPhieuNhap.Rows[i].Cells["SoLuong"].Value; if (m != null && n != null) { soluong = int.Parse(m.ToString()); gia = float.Parse(n.ToString()); double thue = (soluong * gia) * 0.1; TongTien += ((soluong * gia) + thue); } } textBoxTongTien.Text = TongTien.ToString(); //xet ma hoa don for (int i = 0; i < pn.Count; i++) { if (maphieunhap == pn[i].MaPhieuNhap) { cohieu = 0; break; } } //phieunhap if (maphieunhap != "" && cohieu == 1 && ngaynhap != "" && hanthanhtoan != "" && manhanvien != "" && kho != "" && manhacungcap != "" && dieukhoan != "" && hinhthucthanhtoan != "" && tientratruoc != "" && dataGridViewCTPhieuNhap.Rows.Count - 1 != 0) { bool ThemPhieuNhap = XL_PhieuNhap.ThemPhieuNhap(maphieunhap, ngaynhap, manhanvien, kho, manhacungcap, hinhthucthanhtoan, dieukhoan, TongTien, hanthanhtoan, tientratruoc); if (ThemPhieuNhap == true) { List <bool> ThemCTPhieuNhap = new List <bool>(); int lengt = dataGridViewCTPhieuNhap.Rows.Count; //ct phieu nhap int sl = ctpn.Count; for (int i = 0; i < lengt; i++) { // object m = dataGridViewCTPhieuNhap.Rows[i].Cells["MaSP"].Value; object n = dataGridViewCTPhieuNhap.Rows[i].Cells["GiaLucNhap"].Value; object o = dataGridViewCTPhieuNhap.Rows[i].Cells["SoLuong"].Value; if (m != null && n != null && o != null) { CTPhieuNhap temp = new CTPhieuNhap(); //cap phat ma ct phieu nhap tu dong sl += 1; temp.MaChiTietNhap = string.Format("CTPN" + sl.ToString()); temp.MaPhieuNhap = maphieunhap; temp.MaSP = m.ToString(); temp.DonGiaSP = float.Parse(n.ToString()); temp.SoLuongMua = int.Parse(o.ToString()); float thue = 0.1f; temp.Thue = thue; //tien moi loai sp float soluongsp = int.Parse(o.ToString()); float giasp = float.Parse(n.ToString()); double tienthue = (soluongsp * giasp * 0.1); double tien = ((soluongsp * giasp) + tienthue); temp.ThanhTien = float.Parse(tien.ToString()); bool Them = XL_CTPhieuNhap.ThemCTPhieuNhap(temp.MaChiTietNhap, temp.MaPhieuNhap, temp.MaSP, temp.DonGiaSP, temp.ThanhTien, temp.Thue, temp.SoLuongMua); bool Sua = XL_CTPhieuNhap.CapNhatSanPham(kho, temp.MaSP, temp.SoLuongMua); ThemCTPhieuNhap.Add(Them); } } //bien dem xem co luu dc tat ca k int dem = 0; for (int i = 0; i < ThemCTPhieuNhap.Count; i++) { if (ThemCTPhieuNhap[i] == true) { dem++; } } if (dem == ThemCTPhieuNhap.Count) { MessageBox.Show("Thêm thành công!"); this.Close(); } else { MessageBox.Show("Thêm thất bại!"); this.Close(); } } } }
// Xóa chi tiết phiếu nhập public void XoaCTPN(CTPhieuNhap ctpn) { dah.ThucThiCauLenhSQL("DELETE FROM tblCTPN where MaPN ='" + ctpn.Mapn + "'"); }
// Thêm chi tiết phiếu nhập public void ThemCTPN(CTPhieuNhap ctpn) { dal.ThemCTPN(ctpn); }
// Sửa chi tiết phiếu nhập public void SuaCTPN(CTPhieuNhap ctpn) { dal.SuaCTPN(ctpn); }
// Xóa chi tiết phiếu nhập public void XoaCTPN(CTPhieuNhap ctpn) { dal.XoaCTPN(ctpn); }
// Sửa chi tiết phiếu nhập public void SuaCTPN(CTPhieuNhap ctpn) { dah.ThucThiCauLenhSQL("UPDATE tblCTPN SET SoLuongNhap ='" + ctpn.Soluongnhap + "', DonGiaNhap ='" + ctpn.Dongianhap + "', ThanhTien =(" + ctpn.Soluongnhap + " * " + ctpn.Dongianhap + "), DonViTinh ='" + ctpn.Donvitinh + "' where MaPN ='" + ctpn.Mapn + "'"); }