public IHttpActionResult TrangThaiPO(string id, BH_DON_HANG_PO thongtinPO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var edit = db.BH_DON_HANG_PO.Where(x => x.MA_SO_PO == id).FirstOrDefault(); if (edit != null) { edit.DANG_DUYET = thongtinPO.DANG_DUYET; edit.DA_DUYET = thongtinPO.DA_DUYET; edit.DA_HUY = thongtinPO.DA_HUY; } try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BH_DON_HANG_POExists(id)) { return(NotFound()); } else { throw; } } return(Ok(edit.MA_SO_PO)); }
public IHttpActionResult PutBH_DON_HANG_PO(string id, BH_DON_HANG_PO bH_DON_HANG_PO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bH_DON_HANG_PO.MA_SO_PO) { return(BadRequest()); } db.Entry(bH_DON_HANG_PO).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BH_DON_HANG_POExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostBH_DON_HANG_PO(BH_DON_HANG_PO bH_DON_HANG_PO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.BH_DON_HANG_PO.Add(bH_DON_HANG_PO); try { db.SaveChanges(); } catch (DbUpdateException) { if (BH_DON_HANG_POExists(bH_DON_HANG_PO.MA_SO_PO)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = bH_DON_HANG_PO.MA_SO_PO }, bH_DON_HANG_PO)); }
public IHttpActionResult ThemPOTuKinhDoanh(ThongTinDonPO thongtinPO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } BH_DON_HANG_PO baogia = new BH_DON_HANG_PO(); baogia.MA_SO_PO = GenerateMaSoPO(); baogia.NGAY_LEN_PO = DateTime.Today.Date; baogia.MA_KHACH_HANG = thongtinPO.MA_KHACH_HANG; baogia.TEN_LIEN_HE = thongtinPO.TEN_LIEN_HE; baogia.HINH_THUC_THANH_TOAN = thongtinPO.HINH_THUC_THANH_TOAN; baogia.TONG_TIEN_THANH_TOAN = thongtinPO.TONG_TIEN_THANH_TOAN; baogia.TONG_TIEN_HANG = thongtinPO.TONG_TIEN_HANG; baogia.TONG_TIEN_THUE_GTGT = thongtinPO.TONG_TIEN_THUE_GTGT; baogia.SO_TIEN_VIET_BANG_CHU = thongtinPO.SO_TIEN_VIET_BANG_CHU; baogia.TRUC_THUOC = thongtinPO.TRUC_THUOC; baogia.NHAN_VIEN_QUAN_LY = thongtinPO.NHAN_VIEN_QUAN_LY; baogia.SO_BAO_GIA = thongtinPO.SO_BAO_GIA; baogia.PHI_VC = thongtinPO.PHI_VC; if (thongtinPO.NGAY_GIAO_HANG_KD != null) { baogia.NGAY_GIAO_HANG = thongtinPO.NGAY_GIAO_HANG_KD; } baogia.DIA_DIEM_GIAO_HANG = thongtinPO.DIA_DIEM_GIAO_HANG; baogia.CAN_LAY_HOA_DON = thongtinPO.CAN_LAY_HOA_DON; baogia.CAN_XUAT_NGAY = thongtinPO.CAN_XUAT_NGAY; db.BH_DON_HANG_PO.Add(baogia); db.SaveChanges(); foreach (var item in thongtinPO.ChiTietPO) { BH_CT_DON_HANG_PO lienhe = new BH_CT_DON_HANG_PO(); lienhe.MA_SO_PO = baogia.MA_SO_PO; lienhe.MA_HANG = item.MA_HANG; lienhe.MA_DIEU_CHINH = item.MA_DIEU_CHINH; lienhe.SO_LUONG = item.SO_LUONG; lienhe.DVT = item.DVT; lienhe.DON_GIA = item.DON_GIA; lienhe.THANH_TIEN_HANG = item.THANH_TIEN_HANG; lienhe.THUE_GTGT = thongtinPO.THUE_SUAT_GTGT; lienhe.TIEN_THUE_GTGT = ((Convert.ToDouble(item.THANH_TIEN_HANG) * (thongtinPO.THUE_SUAT_GTGT / 100))); lienhe.TIEN_THANH_TOAN = Convert.ToDouble(lienhe.THANH_TIEN_HANG) + lienhe.TIEN_THUE_GTGT; db.BH_CT_DON_HANG_PO.Add(lienhe); } try { db.SaveChanges(); } catch (DbUpdateException) { throw; } return(Ok(baogia.MA_SO_PO)); }
public ActionResult DeleteConfirmed(string id) { BH_DON_HANG_PO bH_DON_HANG_PO = db.BH_DON_HANG_PO.Find(id); db.BH_DON_HANG_PO.Remove(bH_DON_HANG_PO); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult GetBH_DON_HANG_PO(string id) { BH_DON_HANG_PO bH_DON_HANG_PO = db.BH_DON_HANG_PO.Find(id); if (bH_DON_HANG_PO == null) { return(NotFound()); } return(Ok(bH_DON_HANG_PO)); }
public ActionResult Edit([Bind(Include = "MA_SO_PO,NGAY_LEN_PO,MA_KHACH_HANG,TEN_LIEN_HE,HINH_THUC_THANH_TOAN,THUE_SUAT_GTGT,TIEN_THUE_GTGT,TONG_TIEN_THANH_TOAN,SO_TIEN_VIET_BANG_CHU,NHAN_VIEN_QUAN_LY")] BH_DON_HANG_PO bH_DON_HANG_PO) { if (ModelState.IsValid) { db.Entry(bH_DON_HANG_PO).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MA_KHACH_HANG = new SelectList(db.KHs, "MA_KHACH_HANG", "TEN_CONG_TY", bH_DON_HANG_PO.MA_KHACH_HANG); ViewBag.NHAN_VIEN_QUAN_LY = new SelectList(db.CCTC_NHAN_VIEN, "USERNAME", "GIOI_TINH", bH_DON_HANG_PO.NHAN_VIEN_QUAN_LY); return(View(bH_DON_HANG_PO)); }
public IHttpActionResult DeleteBH_DON_HANG_PO(string id) { BH_DON_HANG_PO bH_DON_HANG_PO = db.BH_DON_HANG_PO.Find(id); if (bH_DON_HANG_PO == null) { return(NotFound()); } db.BH_DON_HANG_PO.Remove(bH_DON_HANG_PO); db.SaveChanges(); return(Ok(bH_DON_HANG_PO)); }
// GET: DonHangPO/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BH_DON_HANG_PO bH_DON_HANG_PO = db.BH_DON_HANG_PO.Find(id); if (bH_DON_HANG_PO == null) { return(HttpNotFound()); } return(View(bH_DON_HANG_PO)); }
public IHttpActionResult PostBH_DON_HANG_PO(BH_DON_HANG_PO bH_DON_HANG_PO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } BH_DON_HANG_PO edit = new BH_DON_HANG_PO(); edit.MA_SO_PO = GenerateMaSoPO(); edit.NGAY_LEN_PO = DateTime.Today.Date; edit.MA_KHACH_HANG = bH_DON_HANG_PO.MA_KHACH_HANG; edit.TEN_LIEN_HE = bH_DON_HANG_PO.TEN_LIEN_HE; edit.HINH_THUC_THANH_TOAN = bH_DON_HANG_PO.HINH_THUC_THANH_TOAN; edit.TONG_TIEN_THANH_TOAN = bH_DON_HANG_PO.TONG_TIEN_THANH_TOAN; edit.SO_TIEN_VIET_BANG_CHU = bH_DON_HANG_PO.SO_TIEN_VIET_BANG_CHU; edit.PHI_VC = bH_DON_HANG_PO.PHI_VC; if (bH_DON_HANG_PO.NGAY_GIAO_HANG != null) { edit.NGAY_GIAO_HANG = xlnt.Xulydatetime(bH_DON_HANG_PO.NGAY_GIAO_HANG.ToString()); } edit.DIA_DIEM_GIAO_HANG = bH_DON_HANG_PO.DIA_DIEM_GIAO_HANG; edit.TONG_TIEN_THANH_TOAN = bH_DON_HANG_PO.TONG_TIEN_THANH_TOAN; edit.TONG_TIEN_THUE_GTGT = bH_DON_HANG_PO.TONG_TIEN_THUE_GTGT; edit.NHAN_VIEN_QUAN_LY = bH_DON_HANG_PO.NHAN_VIEN_QUAN_LY; edit.TRUC_THUOC = bH_DON_HANG_PO.TRUC_THUOC; edit.DA_BAN_HANG = bH_DON_HANG_PO.DA_BAN_HANG; edit.CAN_XUAT_NGAY = bH_DON_HANG_PO.CAN_XUAT_NGAY; edit.CAN_LAY_HOA_DON = bH_DON_HANG_PO.CAN_LAY_HOA_DON; db.BH_DON_HANG_PO.Add(edit); try { db.SaveChanges(); } catch (DbUpdateException) { if (BH_DON_HANG_POExists(bH_DON_HANG_PO.MA_SO_PO)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = bH_DON_HANG_PO.MA_SO_PO }, bH_DON_HANG_PO)); }
public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BH_DON_HANG_PO bH_DON_HANG_PO = db.BH_DON_HANG_PO.Find(id); if (bH_DON_HANG_PO == null) { return(HttpNotFound()); } ViewBag.MA_KHACH_HANG = new SelectList(db.KHs, "MA_KHACH_HANG", "TEN_CONG_TY", bH_DON_HANG_PO.MA_KHACH_HANG); ViewBag.NHAN_VIEN_QUAN_LY = new SelectList(db.CCTC_NHAN_VIEN, "USERNAME", "GIOI_TINH", bH_DON_HANG_PO.NHAN_VIEN_QUAN_LY); return(View(bH_DON_HANG_PO)); }
public IHttpActionResult DeleteBH_DON_HANG_PO(string id) { BH_DON_HANG_PO bH_DON_HANG_PO = db.BH_DON_HANG_PO.Find(id); if (bH_DON_HANG_PO == null) { return(NotFound()); } List <BH_CT_DON_HANG_PO> listChiTiet = new List <BH_CT_DON_HANG_PO>(); listChiTiet = db.BH_CT_DON_HANG_PO.Where(x => x.MA_SO_PO == id).ToList(); foreach (var item in listChiTiet) { db.BH_CT_DON_HANG_PO.Remove(item); } db.BH_DON_HANG_PO.Remove(bH_DON_HANG_PO); db.SaveChanges(); return(Ok(bH_DON_HANG_PO)); }
public IHttpActionResult PostDon_Hang_PO(ThongTinDonPO thongtinPO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } BH_DON_HANG_PO baogia = new BH_DON_HANG_PO(); baogia.MA_SO_PO = GenerateMaSoPO(); baogia.NGAY_LEN_PO = DateTime.Today.Date; baogia.MA_KHACH_HANG = thongtinPO.MA_KHACH_HANG; baogia.TEN_LIEN_HE = thongtinPO.TEN_LIEN_HE; baogia.HINH_THUC_THANH_TOAN = thongtinPO.HINH_THUC_THANH_TOAN; baogia.TONG_TIEN_THANH_TOAN = thongtinPO.TONG_TIEN_THANH_TOAN; baogia.TONG_TIEN_HANG = thongtinPO.TONG_TIEN_HANG; baogia.TONG_TIEN_THUE_GTGT = thongtinPO.TONG_TIEN_THUE_GTGT; baogia.SO_TIEN_VIET_BANG_CHU = thongtinPO.SO_TIEN_VIET_BANG_CHU; baogia.PHI_VC = thongtinPO.PHI_VC; baogia.TRUC_THUOC = thongtinPO.TRUC_THUOC; baogia.DA_BAN_HANG = thongtinPO.DA_BAN_HANG; baogia.NHAN_VIEN_QUAN_LY = thongtinPO.NHAN_VIEN_QUAN_LY; baogia.SO_BAO_GIA = thongtinPO.SO_BAO_GIA; if (thongtinPO.NGAY_GIAO_HANG != null) { baogia.NGAY_GIAO_HANG = xlnt.Xulydatetime(thongtinPO.NGAY_GIAO_HANG.ToString()); } baogia.DIA_DIEM_GIAO_HANG = thongtinPO.DIA_DIEM_GIAO_HANG; baogia.CAN_LAY_HOA_DON = thongtinPO.CAN_LAY_HOA_DON; baogia.CAN_XUAT_NGAY = thongtinPO.CAN_XUAT_NGAY; db.BH_DON_HANG_PO.Add(baogia); db.SaveChanges(); foreach (var item in thongtinPO.ChiTietPO) { var query = db.TONKHO_HOPLONG.Where(x => x.MA_HANG == item.MA_HANG).ToList(); //tongton = 0; //if (query != null) //{ // foreach (var tonkho in query) // { // tongton = tongton + tonkho.SL_HOPLONG; // } //} else //{ // tongton = 0; //} BH_CT_DON_HANG_PO lienhe = new BH_CT_DON_HANG_PO(); lienhe.MA_SO_PO = baogia.MA_SO_PO; lienhe.MA_HANG = item.MA_HANG; lienhe.MA_DIEU_CHINH = item.MA_DIEU_CHINH; lienhe.SO_LUONG = item.SO_LUONG; lienhe.DVT = item.DVT; lienhe.DON_GIA = item.DON_GIA; lienhe.THANH_TIEN_HANG = item.THANH_TIEN_HANG; lienhe.THUE_GTGT = thongtinPO.THUE_SUAT_GTGT; lienhe.TIEN_THUE_GTGT = ((Convert.ToDouble(item.THANH_TIEN_HANG) * (thongtinPO.THUE_SUAT_GTGT / 100))); lienhe.TIEN_THANH_TOAN = Convert.ToDouble(lienhe.THANH_TIEN_HANG) + lienhe.TIEN_THUE_GTGT; //if(item.SO_LUONG <= tongton) //{ // lienhe.CAN_GIU_HANG = true; // lienhe.CAN_DAT_HANG = false; //} else if(item.SO_LUONG > tongton) //{ // lienhe.CAN_GIU_HANG = false; // lienhe.CAN_DAT_HANG = true; //} db.BH_CT_DON_HANG_PO.Add(lienhe); } try { db.SaveChanges(); } catch (DbUpdateException) { throw; } return(Ok(baogia.MA_SO_PO)); }