public IHttpActionResult PostDM_HANG_TON_KHO(DM_HANG_TON_KHO dM_HANG_TON_KHO) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.DM_HANG_TON_KHO.Add(dM_HANG_TON_KHO); try { db.SaveChanges(); } catch (DbUpdateException) { if (DM_HANG_TON_KHOExists(dM_HANG_TON_KHO.MA_HANG_HT)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = dM_HANG_TON_KHO.MA_HANG_HT }, dM_HANG_TON_KHO); }
public IHttpActionResult PutDM_HANG_TON_KHO(string id, DM_HANG_TON_KHO dM_HANG_TON_KHO) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != dM_HANG_TON_KHO.MA_HANG_HT) { return BadRequest(); } db.Entry(dM_HANG_TON_KHO).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DM_HANG_TON_KHOExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public ActionResult DeleteConfirmed(string id) { DM_HANG_TON_KHO dM_HANG_TON_KHO = db.DM_HANG_TON_KHO.Find(id); db.DM_HANG_TON_KHO.Remove(dM_HANG_TON_KHO); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult GetDM_HANG_TON_KHO(string id) { DM_HANG_TON_KHO dM_HANG_TON_KHO = db.DM_HANG_TON_KHO.Find(id); if (dM_HANG_TON_KHO == null) { return NotFound(); } return Ok(dM_HANG_TON_KHO); }
public ActionResult Edit([Bind(Include = "MA_HANG_HT,MA_KHO,SL_TON")] DM_HANG_TON_KHO dM_HANG_TON_KHO) { if (ModelState.IsValid) { db.Entry(dM_HANG_TON_KHO).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MA_HANG_HT = new SelectList(db.DM_HANG_HOA, "MA_HANG_HT", "MA_HANG_NHAP", dM_HANG_TON_KHO.MA_HANG_HT); ViewBag.MA_KHO = new SelectList(db.DM_KHO, "MA_KHO", "TEN_KHO", dM_HANG_TON_KHO.MA_KHO); return(View(dM_HANG_TON_KHO)); }
public IHttpActionResult DeleteDM_HANG_TON_KHO(string id) { DM_HANG_TON_KHO dM_HANG_TON_KHO = db.DM_HANG_TON_KHO.Find(id); if (dM_HANG_TON_KHO == null) { return NotFound(); } db.DM_HANG_TON_KHO.Remove(dM_HANG_TON_KHO); db.SaveChanges(); return Ok(dM_HANG_TON_KHO); }
// GET: TruongAnHCM/HangTonKhoTAHCM/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DM_HANG_TON_KHO dM_HANG_TON_KHO = db.DM_HANG_TON_KHO.Find(id); if (dM_HANG_TON_KHO == null) { return(HttpNotFound()); } return(View(dM_HANG_TON_KHO)); }
public ActionResult Import_HangTonKho(HttpPostedFileBase file) { try { if (Request != null) { HttpPostedFileBase filetonkho = Request.Files["UploadedFile"]; if ((filetonkho != null) && (filetonkho.ContentLength > 0) && !string.IsNullOrEmpty(filetonkho.FileName)) { string fileName = filetonkho.FileName; string fileContentType = filetonkho.ContentType; byte[] fileBytes = new byte[filetonkho.ContentLength]; var data = filetonkho.InputStream.Read(fileBytes, 0, Convert.ToInt32(filetonkho.ContentLength)); //var usersList = new List<Users>(); using (var package = new ExcelPackage(filetonkho.InputStream)) { var currentSheet = package.Workbook.Worksheets; var workSheet = currentSheet.First(); var noOfCol = workSheet.Dimension.End.Column; var noOfRow = workSheet.Dimension.End.Row; for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++) { DM_HANG_TON_KHO HH = new DM_HANG_TON_KHO(); HH.MA_HANG_HT = workSheet.Cells[rowIterator, 1].Value.ToString(); HH.MA_KHO = workSheet.Cells[rowIterator, 2].Value.ToString(); HH.SL_TON = Convert.ToInt32(workSheet.Cells[rowIterator, 3].Value.ToString()); db.DM_HANG_TON_KHO.Add(HH); db.SaveChanges(); so_dong_thanh_cong++; dong = rowIterator - 1; } } } } } catch (Exception Ex) { ViewBag.Error = " Đã xảy ra lỗi, Liên hệ ngay với admin. " + Environment.NewLine + " Thông tin chi tiết về lỗi:" + Environment.NewLine + Ex; ViewBag.Information = "Lỗi tại dòng thứ: " + dong; } finally { ViewBag.Message = "Đã import thành công " + so_dong_thanh_cong + " dòng"; } return(View("Index")); }
// GET: TruongAnHCM/HangTonKhoTAHCM/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DM_HANG_TON_KHO dM_HANG_TON_KHO = db.DM_HANG_TON_KHO.Find(id); if (dM_HANG_TON_KHO == null) { return(HttpNotFound()); } ViewBag.MA_HANG_HT = new SelectList(db.DM_HANG_HOA, "MA_HANG_HT", "MA_HANG_NHAP", dM_HANG_TON_KHO.MA_HANG_HT); ViewBag.MA_KHO = new SelectList(db.DM_KHO, "MA_KHO", "TEN_KHO", dM_HANG_TON_KHO.MA_KHO); return(View(dM_HANG_TON_KHO)); }
public List <DM_HANG_TON_KHO> Gettonkho(string mahang, string macongty) { var congty = db.CCTC_CONG_TY.Where(x => x.MA_CONG_TY == macongty).FirstOrDefault(); string tructhuoc = congty.CONG_TY_ME; List <DM_HANG_TON_KHO> listtonkho = new List <DM_HANG_TON_KHO>(); var dskho = db.DM_KHO.Where(x => (x.TRUC_THUOC == tructhuoc || x.TRUC_THUOC == "HOP_LONG")).ToList(); foreach (var item in dskho) { var vData = db.DM_HANG_TON_KHO.Where(x => x.MA_HANG_HT == mahang && x.MA_KHO == item.MA_KHO); if (vData.Count() > 0) { var data = vData.FirstOrDefault(); DM_HANG_TON_KHO tonkho = new DM_HANG_TON_KHO(); tonkho.MA_HANG_HT = data.MA_HANG_HT; tonkho.MA_KHO = data.MA_KHO; tonkho.SL_TON = data.SL_TON; listtonkho.Add(tonkho); } } var tonhang = db.DM_TONKHO_HANG.Where(x => x.MA_HANG_HT == mahang); if (tonhang.Count() > 0) { var data1 = tonhang.FirstOrDefault(); DM_HANG_TON_KHO tonkhohang = new DM_HANG_TON_KHO(); tonkhohang.MA_HANG_HT = data1.MA_HANG_HT; tonkhohang.MA_KHO = "TỒN TẠI HÃNG"; tonkhohang.SL_TON = data1.SL_TON; listtonkho.Add(tonkhohang); } var result = listtonkho.ToList().Select(x => new DM_HANG_TON_KHO() { MA_HANG_HT = x.MA_HANG_HT, MA_KHO = x.MA_KHO, SL_TON = x.SL_TON }).ToList(); return(result); }
// GET: api/Api_TonKhoHL public List <DM_HANG_TON_KHO> GetDM_HANG_TON_KHO(string id) { List <DM_HANG_TON_KHO> listtonkho = new List <DM_HANG_TON_KHO>(); var dskho = db.DM_KHO.Where(x => x.TRUC_THUOC == "HOPLONG").ToList(); foreach (var item in dskho) { var vData = db.DM_HANG_TON_KHO.Where(x => x.MA_HANG == id && x.MA_KHO == item.MA_KHO); if (vData.Count() > 0) { var data = vData.FirstOrDefault(); DM_HANG_TON_KHO tonkho = new DM_HANG_TON_KHO(); tonkho.MA_HANG = data.MA_HANG; tonkho.MA_KHO = data.MA_KHO; tonkho.SL_TON = data.SL_TON; listtonkho.Add(tonkho); } } var tonhang = db.DM_TONKHO_HANG.Where(x => x.MA_HANG == id); if (tonhang.Count() > 0) { var data1 = tonhang.FirstOrDefault(); DM_HANG_TON_KHO tonkhohang = new DM_HANG_TON_KHO(); tonkhohang.MA_HANG = data1.MA_HANG; tonkhohang.MA_KHO = "TỒN TẠI HÃNG"; tonkhohang.SL_TON = data1.SL_TON; listtonkho.Add(tonkhohang); } var result = listtonkho.ToList().Select(x => new DM_HANG_TON_KHO() { MA_HANG = x.MA_HANG, MA_KHO = x.MA_KHO, SL_TON = x.SL_TON }).ToList(); return(result); }