public ActionResult Datatuhuytour(string idhoadon, decimal?ppv, decimal?tygia, string tour, string tkno, string tkco, string list) { tygia = string.IsNullOrEmpty(tygia.ToString()) ? 1 : tygia; var idList = JsonConvert.DeserializeObject <List <DataTuVetour> >(list); foreach (var i in idList) { Huycthdvat ct = new Huycthdvat(); ct.Idhoadon = idhoadon; ct.serial = i.serial; ct.diengiai = i.diengiai; ct.xuatve = Convert.ToDateTime(i.xuatve); ct.tenkhach = i.tenkhach; ct.sgtcode = i.sgtcode; ct.sotiennt = -((i.sotiennt - i.doanhthunn) * i.tygia); ct.ppv = Convert.ToDecimal(ppv); ct.vat = i.vat; ct.tygia = (decimal)tygia; ct.sotien = -((i.sotiennt - i.doanhthunn) * i.tygia);// Convert.ToDecimal(i.sotiennt * tygia); ct.ghichu = i.ghichu; ct.tkco = tkco; ct.tkno = tkno; ct.ngaytao = System.DateTime.Now; ct.khachhuy = false; ct.httc = ""; ct.dichvu = ""; ct.loaitien = i.loaitien; ct.tour = tour; ct.logfile = "===================" + System.Environment.NewLine + "User " + HttpContext.Session.GetString("username") + " thêm chi tiết từ tour " + tour + " vào lúc: " + System.DateTime.Now.ToString(); // _huycthdvatRepository.Create(ct); } return(RedirectToAction("Edit", new { id = idhoadon })); }
public ActionResult Themhuycthd_1(Huycthdvat entity) { entity.ngaytao = System.DateTime.Now; entity.tour = "OB"; entity.chinhanh = HttpContext.Session.GetString("chinhanh"); entity.serial = entity.serial ?? ""; entity.hoadonhuy = entity.hoadonhuy ?? ""; entity.httc = entity.httc ?? ""; entity.diengiai = entity.diengiai ?? ""; entity.sgtcode = entity.sgtcode ?? ""; entity.tenkhach = entity.tenkhach ?? ""; entity.sotien = -entity.sotien; entity.sotiennt = -entity.sotiennt; entity.logfile = "-User tạo chi tiết hoá đơn: " + _username + " vào lúc: " + System.DateTime.Now.ToString(); var result = _huycthdvatRepository.Create(entity); if (result != null) { SetAlert("Thêm huỷ chi tiết hoá đơn thành công", "success"); } else { SetAlert("Thêm huỷ chi tiết hoá đơn không thành công", "error"); } return(Redirect(HttpContext.Session.GetString("urlEditHoadonhuy"))); }
public ActionResult Themhuycthd_(string idhoadon, string listString) { var cthd = JsonConvert.DeserializeObject <List <cthdvat> >(listString); //List<Huycthdvat> a = new List<Huycthdvat>(); foreach (var c in cthd) { var ct = _cthdvatRepository.GetById(c.Id); var hd = _hoadonRepository.GetByTwoKey(ct.Idhoadon, HttpContext.Session.GetString("chinhanh")); Huycthdvat h = new Huycthdvat(); h.Idhoadon = idhoadon; h.chinhanh = HttpContext.Session.GetString("chinhanh"); h.diengiai = c.diengiai; h.sotien = c.sotien; h.serial = ct.serial; h.xuatve = ct.xuatve; h.tenkhach = ct.tenkhach; h.sgtcode = ct.sgtcode; h.sotiennt = -ct.sotiennt; h.sotien = -ct.sotien; h.loaitien = ct.loaitien; h.tygia = ct.tygia; h.ppv = ct.ppv; h.vat = ct.vat; h.ghichu = ct.ghichu; h.hoadonhuy = hd.hdvat; h.coupon = ct.coupon; h.tiencoupon = ct.tiencoupon; h.tour = ct.tour; h.httc = ct.httc; h.tkno = ct.tkno; h.tkco = ct.tkco; h.ngaytao = System.DateTime.Now; h.logfile = "User thêm chi tiết huỷ: " + _username + " vào lúc " + System.DateTime.Now; _huycthdvatRepository.Create(h); ct.hoadonhuy = idhoadon; ct.ngayhuy = System.DateTime.Now; _cthdvatRepository.Update(ct); } return(Redirect(HttpContext.Session.GetString("urlEditHoadonhuy"))); }
public ActionResult Themhuycthd_1(string idhoadon) { ViewBag.id = idhoadon; var ct = new Huycthdvat(); ct.Idhoadon = idhoadon; ListNgoaite("VND"); ListHttt("TM/CK"); Listhttc(""); Tkco("5113333336"); Tkno("1311110000"); ct.tygia = 1; var hd = _huyhdvatRepository.GetByTwoKey(ct.Idhoadon, HttpContext.Session.GetString("chinhanh")); if (!String.IsNullOrEmpty(hd.hdvat)) { SetAlert("Đây là hoá đơn điện tử, không được điều chỉnh thông tin khi đã xuất hoá đơn", "error"); return(Redirect(HttpContext.Session.GetString("urlEditHoadonhuy"))); } return(View(ct)); }
public ActionResult Capnhathuycthd(Huycthdvat entity) { temp = ""; log = ""; Huycthdvat ct = _huycthdvatRepository.GetById(entity.Id); if (ct.diengiai != entity.diengiai) { temp += String.Format("- Diễn giải thay đổi: {0}->{1}", ct.diengiai, entity.diengiai); } if (!string.IsNullOrEmpty(ct.tenkhach) != !string.IsNullOrEmpty(entity.tenkhach)) { temp += String.Format("- Tên khách thay đổi: {0}->{1}", ct.tenkhach, entity.tenkhach); } if (!string.IsNullOrEmpty(ct.sgtcode) != !string.IsNullOrEmpty(entity.sgtcode)) { temp += String.Format("- Tour code thay đổi: {0}->{1}", ct.sgtcode, entity.sgtcode); } if (ct.sk != entity.sk) { temp += String.Format("- Số khách thay đổi: {0}->{1}", ct.sk, entity.sk); } if (Math.Abs(ct.sotiennt) != Math.Abs(entity.sotiennt)) { temp += String.Format("- Tiền NT thay đổi: {0:#,##0.0}->{1:#,##0.0}", ct.sotiennt, entity.sotiennt); } if (ct.loaitien != entity.loaitien) { temp += String.Format("- Loại tiền thay đổi thay đổi: {0}->{1}", ct.loaitien, entity.loaitien); } if (ct.tygia != entity.tygia) { temp += String.Format("- Tỷ giá thay đổi: {0}->{1}", ct.tygia, entity.tygia); } if (Math.Abs(ct.sotien) != Math.Abs(entity.sotien)) { temp += String.Format("- Tiền VNĐ thay đổi: {0:#,##0}->{1:#,##0}", ct.sotien, entity.sotien); } if (ct.ppv != entity.ppv) { temp += String.Format("- Phí phục vụ thay đổi: {0}->{1}", ct.ppv, entity.ppv); } if (!string.IsNullOrEmpty(ct.httc) != !string.IsNullOrEmpty(entity.httc)) { temp += String.Format("- HTTC thay đổi: {0}->{1}", ct.httc, entity.httc); } if (ct.tkno != entity.tkno) { temp += String.Format("- Tài khoản nợ thay đổi: {0}->{1}", ct.tkno, entity.tkno); } if (ct.tkco != entity.tkco) { temp += String.Format("- Tài khoản có thay đổi: {0}->{1}", ct.tkco, entity.tkco); } if (ct.ghichu != entity.ghichu) { temp += String.Format("- Ghi chú thay đổi: {0}->{1}", ct.sgtcode, entity.sgtcode); } ct.diengiai = entity.diengiai; ct.tenkhach = entity.tenkhach; ct.sgtcode = entity.sgtcode; ct.sotiennt = -entity.sotiennt; ct.loaitien = entity.loaitien; ct.tygia = entity.tygia; ct.sotien = -entity.sotien; ct.ppv = entity.ppv; ct.vat = entity.vat; ct.httc = entity.httc; ct.tkno = entity.tkno; ct.tkco = entity.tkco; ct.ghichu = entity.ghichu; ct.sk = entity.sk; if (temp.Length > 0) { log = System.Environment.NewLine; log += "============="; log += System.Environment.NewLine; log += temp + " -User cập nhật huỷ chi tiết hoá đơn: " + _username + " vào lúc: " + System.DateTime.Now.ToString("dd/MM/yyyy HH:mm"); ct.logfile = ct.logfile + log; } var result = _huycthdvatRepository.Update(ct); if (result != null) { SetAlert("Cập nhật chi tiết hoá đơn thành công", "success"); } else { SetAlert("Cập nhật chi tiết hoá đơn không thành công", "error"); } return(Redirect(HttpContext.Session.GetString("urlEditHoadonhuy"))); }