public async Task <ActionResult> Deletes(int id, string quaylai) { if (quaylai != null) { return(RedirectToAction("Index")); } PhieuXuatKho huyPhieuXuatKho = (PhieuXuatKho)await _phieuXuatKhoBus.Find(id); if (huyPhieuXuatKho == null) { SetAlert("Đã xảy ra lỗi! Bạn hãy hủy lại", "error"); return(RedirectToAction("Edit")); } else { try { await _phieuXuatKhoBus.HuyPhieuXuatKho(huyPhieuXuatKho); SetAlert("Đã hủy phiếu xuất kho thành công!!!", "success"); } catch { SetAlert("Đã xảy ra lỗi! Bạn hãy hủy lại", "error"); return(RedirectToAction("Edit")); } } return(RedirectToAction("Index")); }
public ActionResult LuuPhieuXuatKho(PhieuXuatKho phieuXuatKho) { PhieuXuatKho pxk = new PhieuXuatKho { NgayXuatKho = phieuXuatKho.NgayXuatKho, MaNguoiDung = phieuXuatKho.MaNguoiDung, LyDoXuat = phieuXuatKho.LyDoXuat, TongTien = phieuXuatKho.TongTien, IsDeleted = phieuXuatKho.IsDeleted, NgayChinhSua = DateTime.Now.Date }; bool status = false; try { db.PhieuXuatKhoes.Add(pxk); db.SaveChanges(); SaveAllCTPXK(phieuXuatKho.ChiTietPhieuXuatKhoes, pxk.SoPhieuXuatKho); status = true; } catch { status = false; throw; } return(new JsonResult { Data = new { status = status } }); }
public JsonResult ThemPhieuXuat(int idktv) { //if(db.PhieuXuatKhoes.SingleOrDefault(x => (x.NgayXuat == dtnow && x.IDKTV == idktv)) == null) //{ PhieuXuatKho phieuXuatKho = new PhieuXuatKho(); phieuXuatKho.IDKTV = idktv; phieuXuatKho.NgayXuat = DateTime.Now; phieuXuatKho.KiemDuyet = false; phieuXuatKho.Status = 0; db.PhieuXuatKhoes.Add(phieuXuatKho); db.SaveChanges(); return(Json(new { status = true, idpx = phieuXuatKho.ID })); //} //else //{ // return Json(new // { // status = false, // }); //} }
public async Task <ActionResult <PhieuXuatKho> > PostPhieuXuatKho(PhieuXuatKho phieuXuatKho) { _context.PhieuXuatKhos.Add(phieuXuatKho); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPhieuXuatKho", new { id = phieuXuatKho.Id }, phieuXuatKho)); }
public ActionResult SuaPhieuXuatKho(PhieuXuatKho phieuXuatKho) { bool status = false; try { var phieunhapkho = db.PhieuXuatKhoes.SingleOrDefault(pxk => pxk.SoPhieuXuatKho == phieuXuatKho.SoPhieuXuatKho); if (phieunhapkho != null) { phieunhapkho.NgayXuatKho = phieuXuatKho.NgayXuatKho; phieunhapkho.MaNguoiDung = phieuXuatKho.MaNguoiDung; phieunhapkho.LyDoXuat = phieuXuatKho.LyDoXuat; phieunhapkho.TongTien = phieuXuatKho.TongTien; phieunhapkho.NgayChinhSua = DateTime.Now.Date; DeleteAllCTPXK(phieunhapkho.SoPhieuXuatKho); SaveAllCTPXK(phieuXuatKho.ChiTietPhieuXuatKhoes, phieunhapkho.SoPhieuXuatKho); db.SaveChanges(); status = true; } else { status = false; } } catch { status = false; throw; } return(new JsonResult { Data = new { status = status } }); }
public async Task <IActionResult> PutPhieuXuatKho(int id, PhieuXuatKho phieuXuatKho) { if (id != phieuXuatKho.Id) { return(BadRequest()); } _context.Entry(phieuXuatKho).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhieuXuatKhoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public JsonResult UpdatePhieuXuat(string px) { try { JavaScriptSerializer serializer = new JavaScriptSerializer(); PhieuXuatKho px_edit = serializer.Deserialize <PhieuXuatKho>(px); if (px_edit.IDKTV != 0) { PhieuXuatKho phieuXuatKho = db.PhieuXuatKhoes.SingleOrDefault(x => x.ID == px_edit.ID); phieuXuatKho.IDKTV = px_edit.IDKTV; db.SaveChanges(); return(Json(new { status = true })); } else { return(Json(new { status = false })); } } catch { return(Json(new { status = false })); } }
public async Task Create(PhieuXuatKhoViewModel O) { PhieuXuatKho phieuXuat = new PhieuXuatKho { SoPhieuXuatKho = O.soPhieuXuatKho, NgayXuat = O.ngayXuatKho, MaNhanVien = O.maNhanVien, TongTien = O.tongTien, LyDoXuat = O.lyDoXuat, TrangThai = true, NgayChinhSua = DateTime.Now, }; //DateTime today = DateTime.Now; //int thang = today.Month; //int nam = today.Year; foreach (var i in O.chiTietPhieuXuatKho) { phieuXuat.ChiTietPhieuXuatKhos.Add(i); //_hangHoaBus.CapNhatHangHoaKhiTaoPhieuXuat(i.MaHangHoa, i.SoLuong); //_hangHoaBus.CapNhatHangHoaVaoBaoCaoTonKhoKhiTaoPhieuXuat(i.MaHangHoa, i.SoLuong, thang, nam); } await _phieuXuatKhoRepo.InsertAsync(phieuXuat); }
public ActionResult DeleteConfirmed(int id) { PhieuXuatKho phieuXuatKho = db.PhieuXuatKhoes.Find(id); db.PhieuXuatKhoes.Remove(phieuXuatKho); db.SaveChanges(); SetAlert("Xóa phiếu kiểm kho thành công!", "success"); return(RedirectToAction("Index")); }
public JsonResult LapPhieu(List <int> listDC) { if (listDC == null) { return(Json(new { status = false, mess = "Bạn chưa chọn dụng cụ" })); } else { string name = HttpContext.User.Identity.Name; var ktv = db.NhanViens.SingleOrDefault(x => x.Username.Equals(name) && x.Status == 1); if (ktv == null) { return(Json(new { status = false, mess = "Có lỗi xảy ra" })); } PhieuXuatKho px = new PhieuXuatKho(); px.IDKTV = ktv.ID; px.KiemDuyet = false; px.NgayXuat = DateTime.Now; px.Status = 0; foreach (int value in listDC) { var vd = db.KhoVatDungs.Find(value); if (vd == null || vd.Status == 2) { return(Json(new { status = false, mess = "Có lỗi xảy ra" })); } else { vd.Status = 2; } CTPhieuXuatKho ct = new CTPhieuXuatKho(); ct.IDVatDung = value; px.CTPhieuXuatKhoes.Add(ct); } db.PhieuXuatKhoes.Add(px); db.SaveChanges(); return(Json(new { status = true })); } }
public async Task HuyPhieuXuatKho(object editModel) { try { PhieuXuatKho editPhieuXuatKho = (PhieuXuatKho)editModel; editPhieuXuatKho.TrangThai = false; await _phieuXuatKhoRepo.EditAsync(editPhieuXuatKho); } catch (Exception) { } }
private void btnInPhieuXuatKho_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (Kiemtra() == false) { return; } var r = new PhieuXuatKho(data, data.PhieuDatHang.FirstOrDefault(), data.CTPhieuDatHang); r.ShowPreview(); }
public bool InsertPhieuXuatKho(PhieuXuatKho phieuXuat, DataGridView dataGridView) { bool result = false; PhieuXuatDAL phieuXuatDAL = new PhieuXuatDAL(); ChiTietPhieuXuatDAL chiTietPhieuXuatDAL = new ChiTietPhieuXuatDAL(); try { if (!DatabaseDAL.TestConnection()) { DatabaseDAL.CreatConn(); } DatabaseDAL.Transaction(); try { result = phieuXuatDAL.InsertPhieuXuatHang(phieuXuat); for (int i = 0; i < dataGridView.RowCount; i++) { if (dataGridView.Rows[i].Cells["STT"].Value != null) { ChiTietPhieuXuat chiTietPhieu = new ChiTietPhieuXuat(); chiTietPhieu.SoChungTu = phieuXuat.SoChungTu; chiTietPhieu.MaHang = dataGridView.Rows[i].Cells["MaHang"].Value?.ToString(); chiTietPhieu.TenHang = dataGridView.Rows[i].Cells["TenHang"].Value?.ToString(); chiTietPhieu.DonViTinh = dataGridView.Rows[i].Cells["DonVitinh"].Value?.ToString(); chiTietPhieu.SoLuongXuat = Convert.ToInt32(dataGridView.Rows[i].Cells["SoLuongXuat"].Value?.ToString()); chiTietPhieu.DonGia = Convert.ToInt32(dataGridView.Rows[i].Cells["DonGia"]?.Value?.ToString()); chiTietPhieu.ThanhTien = Convert.ToDecimal(dataGridView.Rows[i].Cells["ThanhTien"].Value?.ToString()); if (!isEmptyOrNullOrSpecialCharacters(chiTietPhieu.SoChungTu) && !isEmptyOrNullOrSpecialCharacters(chiTietPhieu.MaHang) && !isEmptyOrNullOrSpecialCharacters(chiTietPhieu.TenHang) && !isEmptyOrNullOrSpecialCharacters(chiTietPhieu.DonViTinh) && !isEmptyOrNotNumber(chiTietPhieu.SoLuongXuat) && !isEmptyOrNotNumber(chiTietPhieu.DonGia) && !isEmptyOrNotNumber(chiTietPhieu.ThanhTien)) { result = chiTietPhieuXuatDAL.InsertChiTietPhieuXuat(chiTietPhieu); } } } DatabaseDAL.Commit(); DatabaseDAL.CloseConnection(); return(result); } catch (Exception) { DatabaseDAL.Rollback(); DatabaseDAL.CloseConnection(); return(false); } } catch (Exception) { DatabaseDAL.CloseConnection(); return(false); } }
// GET: PhieuXuatKho/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuXuatKho phieuXuatKho = db.PhieuXuatKhoes.Find(id); if (phieuXuatKho == null) { return(HttpNotFound()); } return(View(phieuXuatKho)); }
public ActionResult Edit([Bind(Include = "SoPhieuXuatKho,NgayXuatKho,MaNguoiDung,LyDoXuat,TongTien,IsDeleted,NgayChinhSua")] PhieuXuatKho phieuXuatKho) { if (ModelState.IsValid) { db.Entry(phieuXuatKho).State = EntityState.Modified; db.SaveChanges(); SetAlert("Sửa phiếu kiểm kho thành công!", "success"); return(RedirectToAction("Index")); } var user = (NguoiDung)Session["Account"]; ViewBag.MaNguoiDung = new SelectList(db.NguoiDungs.Where(nd => nd.MaNguoiDung == user.MaNguoiDung), "MaNguoiDung", "TenNguoiDung"); ViewBag.MaHangHoa = new SelectList(db.HangHoas.Where(i => i.IsDeleted != true), "MaHangHoa", "TenHangHoa"); return(View(phieuXuatKho)); }
// GET: PhieuXuatKho/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuXuatKho phieuXuatKho = db.PhieuXuatKhoes.Find(id); var user = (NguoiDung)Session["Account"]; ViewBag.MaNguoiDung = new SelectList(db.NguoiDungs.Where(nd => nd.MaNguoiDung == user.MaNguoiDung), "MaNguoiDung", "TenNguoiDung"); if (phieuXuatKho == null) { return(HttpNotFound()); } return(View(phieuXuatKho)); }
// GET: PhieuXuatKho/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuXuatKho phieuXuatKho = db.PhieuXuatKhoes.Find(id); if (phieuXuatKho == null) { return(HttpNotFound()); } var user = (NguoiDung)Session["Account"]; ViewBag.MaNguoiDung = new SelectList(db.NguoiDungs.Where(nd => nd.MaNguoiDung == user.MaNguoiDung), "MaNguoiDung", "TenNguoiDung"); ViewBag.MaHangHoa = new SelectList(db.HangHoas.Where(i => i.IsDeleted != true), "MaHangHoa", "TenHangHoa"); return(View(phieuXuatKho)); }
public int taophieuxuatkho(ePhieuXuatKho e) { if (ktranv(e.MaNV, e.MaKho)) { throw new Exception("Bạn không phải nhân viên kho này"); } PhieuXuatKho px = new PhieuXuatKho(); px.soPXK = e.SoPXK; px.manhanvien = e.MaNV; px.ngaylap = e.NgayLap; px.makho = e.MaKho; UpdateSoLuong(e.SoPXK); tinhtrang(e.SoPXK); db.PhieuXuatKhos.InsertOnSubmit(px); db.SubmitChanges(); return(1); }
public async Task Create(PhieuXuatKhoViewModel O) { PhieuXuatKho order = new PhieuXuatKho { SoPhieuXuatKho = O.soPhieuXuatKho, NgayXuat = DateTime.Now, MaNhanVien = O.maNhanVien, TongTien = O.tongTien, LyDoXuat = O.lyDoXuat, TrangThai = true, NgayChinhSua = DateTime.Now, }; foreach (var i in O.chiTietPhieuXuatKho) { order.ChiTietPhieuXuatKhos.Add(i); } await _phieuXuatKhoRepo.InsertAsync(order); }
private void btnGhiSo_Click(object sender, EventArgs e) { PhieuXuatBLL bLL = new PhieuXuatBLL(); PhieuXuatKho phieuXuat = new PhieuXuatKho(); phieuXuat.SoChungTu = txbSohieu.Text; phieuXuat.MaKho = ((DataRowView)cbKhoNhap.SelectedItem)["MaKho"].ToString(); phieuXuat.NgayLapPhieu = dateTimePickerNgayLapPhieu.Value.Date; phieuXuat.NguoiLapPhieu = txbTenNV.Text; phieuXuat.NguoiNhanHang = txbNguoigiao.Text; if (bLL.InsertPhieuXuatKho(phieuXuat, dtgvDsHangXuat)) { MessageBox.Show("Đã thêm thành công phiếu xuất!"); } else { MessageBox.Show("Không thể thêm phiếu xuất!"); } }
private void btnInPhieuXuat_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var p = customGridView1.GetFocusedDataRow() as CRMData.PhieuDatHangRow; if (p == null) { return; } var ctAD = new CRMDataTableAdapters.CTPhieuDatHangTableAdapter(); var spAD = new CRMDataTableAdapters.SanPhamTableAdapter(); spAD.Fill(data.SanPham); var dtCT = ctAD.GetDataBySoPhieu(p.SoPhieu); var r = new PhieuXuatKho(data, p, dtCT); r.ShowPreview(); }
public async Task HuyPhieuXuatKho(object editModel) { try { PhieuXuatKho editPhieuXuatKho = (PhieuXuatKho)editModel; editPhieuXuatKho.TrangThai = false; await _phieuXuatKhoRepo.EditAsync(editPhieuXuatKho); //var phieuXuatKho = dbContext.ChiTietPhieuXuatKhoes.Where(x => x.SoPhieuXuatKho == editPhieuXuatKho.SoPhieuXuatKho); //int thang = dbContext.PhieuXuatKhoes.SingleOrDefault(x => x.SoPhieuXuatKho == editPhieuXuatKho.SoPhieuXuatKho).NgayXuat.Month; //int nam = dbContext.PhieuXuatKhoes.SingleOrDefault(x => x.SoPhieuXuatKho == editPhieuXuatKho.SoPhieuXuatKho).NgayXuat.Year; //foreach (var i in phieuXuatKho) //{ // _hangHoaBus.CapNhatHangHoaKhiXoaPhieuXuat(i.MaHangHoa, i.SoLuong); // _hangHoaBus.CapNhatHangHoaVaoBaoCaoTonKhoKhiXoaPhieuXuat(i.MaHangHoa, i.SoLuong, thang, nam); //} } catch (Exception) { } }
public JsonResult ChangeStatusPhieu(int idphieuxuat) { PhieuXuatKho px = db.PhieuXuatKhoes.SingleOrDefault(x => x.ID == idphieuxuat); if (px.Status == 0) { px.Status = 1; px.NgayTra = DateTime.Now; List <CTPhieuXuatKho> listct = db.CTPhieuXuatKhoes.Where(x => x.IDPhieuXuat == idphieuxuat).ToList(); foreach (CTPhieuXuatKho item in listct) { KhoVatDung vatDung = db.KhoVatDungs.SingleOrDefault(x => x.ID == item.IDVatDung); vatDung.Status = 1; db.SaveChanges(); } } else { px.Status = 0; px.NgayTra = null; List <CTPhieuXuatKho> listct = db.CTPhieuXuatKhoes.Where(x => x.IDPhieuXuat == idphieuxuat).ToList(); foreach (CTPhieuXuatKho item in listct) { KhoVatDung vatDung = db.KhoVatDungs.SingleOrDefault(x => x.ID == item.IDVatDung); vatDung.Status = 2; db.SaveChanges(); } } db.SaveChanges(); return(Json(new { status = true })); }
public bool InsertPhieuXuatHang(PhieuXuatKho phieuXuat) { int result = DatabaseDAL.ExecuteNonQuery("exec USP_InsertPhieuXuatKho @sochungtu , @makho , @nguoilapphieu , @ngaylapphieu , @nguoinhan ", new object[] { phieuXuat.SoChungTu, phieuXuat.MaKho, phieuXuat.NguoiLapPhieu, phieuXuat.NgayLapPhieu, phieuXuat.NguoiNhanHang }); return(result > 0); }