public DetailInvoicePOVendorViewModel UpdateInvoice(DetailInvoicePOVendorViewModel model) { var dc = new eprocdbDataContext(); var result = (from custpo in dc.CUSTOMPOs where custpo.PONUMBER == model.PONumber select custpo).SingleOrDefault(); if (result != null) { result.TGLGI = model.ClearingDate; result.MODIFIED_DATE = DateTime.Now; result.MODIFIED_BY = System.Web.HttpContext.Current.Session["UserID"].ToString(); var result2 = (from custbpkb in dc.CUSTOMBPKBs where custbpkb.PONUMBER == model.PONumber select custbpkb).SingleOrDefault(); if (result2 != null) { result2.NOFAKTUR = model.NoSeriFakturPajak == null ? "" : model.NoSeriFakturPajak; result2.MODIFIED_DATE = DateTime.Now; result2.MODIFIED_BY = System.Web.HttpContext.Current.Session["UserID"].ToString(); } var result3 = (from custgr in dc.CUSTOMGRs where custgr.PONUMBER == model.PONumber select custgr).SingleOrDefault(); if (result3 != null) { result3.STATUSDELIVERYUNIT = model.StatusDeliveryUnit; result3.MODIFIED_DATE = DateTime.Now; result3.MODIFIED_BY = System.Web.HttpContext.Current.Session["UserID"].ToString(); } var result4 = (from custir in dc.CUSTOMIRs where custir.PONUMBER == model.PONumber select custir).SingleOrDefault(); if (result4 != null) { result4.NOFAKTURPAJAK = model.NoSeriFakturPajak; result4.INVNO = model.InvoiceNo; result4.INVDATE = model.InvoiceDate; result4.MODIFIED_DATE = DateTime.Now; result4.MODIFIED_BY = System.Web.HttpContext.Current.Session["UserID"].ToString(); } dc.SubmitChanges(); UpdateStatus(model.PONumber); UpdateInvoiceStatus(model.PONumber); } return(model); }
public ActionResult DetailInvoice(DetailInvoicePOVendorViewModel model, HttpPostedFileBase postedFile, IEnumerable <HttpPostedFileBase> txtFileName) { try { if (txtFileName != null) { foreach (var x in txtFileName) { string path = Server.MapPath("~/Uploads/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } x.SaveAs(path + Path.GetFileName(x.FileName)); } } if (postedFile != null) { string path = Server.MapPath("~/Uploads/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } postedFile.SaveAs(path + Path.GetFileName(postedFile.FileName)); this.AddNotification("Your Data Has Been Successfully Updated. ", NotificationType.SUCCESS); } ITransaksiPOVendorService svc = new TransaksiPOVendorService(); //if (model.strInvoiceDate != "" && model.strInvoiceDate != null) //{ // model.InvoiceDate = DateTime.Parse(model.strInvoiceDate); //} //if (model.strPoDate != "" && model.strPoDate != null) //{ // model.PODate = DateTime.Parse(model.strPoDate); //} //if (model.strPromiseDeliveryDate != "" && model.strPromiseDeliveryDate != null) //{ // model.PromiseDeliveryDate = DateTime.Parse(model.strPromiseDeliveryDate); //} //if (model.strExpectedDateDelivered != "" && model.strExpectedDateDelivered != null) //{ // model.ExpectedDateDelivered = DateTime.Parse(model.strExpectedDateDelivered); //} //if (model.strPayPlan != "" && model.strPayPlan != null) //{ // model.PayPlan = DateTime.Parse(model.strPayPlan); //} //if (model.strClearingDate != "" && model.strClearingDate != null) //{ // model.ClearingDate = DateTime.Parse(model.strClearingDate); //} var result = svc.UpdateInvoice(model); this.AddNotification("Your Data Has Been Successfully Updated. ", NotificationType.SUCCESS); return(RedirectToAction("Index")); } catch (Exception ex) { general.AddLogError("POVendor DetailInvoice", ex.Message, ex.StackTrace); return(View("~/Views/Transaksi/Vendor/Index.cshtml", model)); } }