public ActionResult Detail(int?id, string msg, AlertMsgType?msgType) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");; System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");; TblJobOrder ob = uow.Modules.JobOrder.Get(id ?? 0); return(ViewDetail(ob, msg, msgType)); }
private ActionResult ViewDetail(TblJobOrder ob, string msg, AlertMsgType?msgType) { try { TblSaleOrder saleOrder = null; TblCustomer customer = null; if (ob == null) { throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง"); } if (!string.IsNullOrWhiteSpace(msg)) { WidgetAlertModel alert = new WidgetAlertModel() { Message = msg }; if (msgType.HasValue) { alert.Type = msgType.Value; } ViewBag.Alert = alert; } AccountPermission permission = new AccountPermission(); permission = GetPermissionSale(CurrentUID, ob.CreatedBy.HasValue ? ob.CreatedBy.Value : 0); ViewData["JobOrderDetail"] = uow.Modules.JobOrder.Gets(); ViewData["SysCategoryDetail"] = uow.Modules.SysCategory.Gets(); ViewData["SaleorderDetail"] = uow.Modules.SaleOrder.Gets(); ViewData["Saleorder"] = saleOrder = uow.Modules.SaleOrder.Get(ob.SaleOrderId.HasValue ? ob.SaleOrderId.Value : -1); ViewData["TeamOperation"] = uow.Modules.TeamOperation.Gets(); ViewData["optCustomer"] = customer = uow.Modules.Customer.Get(saleOrder.CustomerId.HasValue ? saleOrder.CustomerId.Value : -1); ViewData["optProduct"] = uow.Modules.Product.Gets().Where(o => o.CategoryId == 1).ToList(); ViewData["optAttachment"] = uow.Modules.SaleOrderAttachment.Gets(ob.SaleOrderId.HasValue ? ob.SaleOrderId.Value : -1); // ViewData["optCustomerAddress"] = uow.Modules.CustomerAddress.Get(customer.addHasValue ? saleOrder.CustomerId.Value : -1); ViewData["optPermission"] = permission; return(View(ob)); } catch (Exception ex) { return(RedirectToAction("Index", MVCController, new { area = MVCArea, msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); } }
public ActionResult Detail(int?id, string msg, AlertMsgType?msgType) { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");; System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");; TblJobOrder ob = uow.Modules.JobOrder.Get(id ?? 0); if (ob != null && ob.StatusId == null) { ob.StatusId = 0; } ViewData["optEmployee"] = uow.Modules.Employee.Gets(); ViewData["userAccount"] = CurrentUser; ViewData["SurveyTemplate"] = uow.Modules.Survey.GetList(); return(ViewDetail(ob, msg, msgType)); }
//[Authorized] public ActionResult UpdateJobOrderDate(TblJobOrder setJobOrder) { List <TblJobOrder> result = null; System.Globalization.CultureInfo _cultureUSInfo = new System.Globalization.CultureInfo("en-US"); try { TblJobOrder ob = uow.Modules.JobOrder.GetHeaderByPK(setJobOrder.JobOrderId); if (setJobOrder.StartDateToString != null) { var dd = setJobOrder.StartDateToString + " 00:00:00"; ob.StartDate = dd.ParseDate(DateFormat.yyyyMMddHHmmss, culInfo: _cultureUSInfo); ob.EndDate = dd.ParseDate(DateFormat.yyyyMMddHHmmss, culInfo: _cultureUSInfo); } uow.Modules.JobOrder.UpdateDate(ob); uow.SaveChanges(); result = uow.Modules.JobOrder.GetByDate("", ""); //saleOrder.Customer = uow.Modules.Customer.GetByCondition(saleOrder.CustomerId.Value); // saleOrder.Sale = uow.Modules.Employee.GetByCondition(saleOrder.SaleId.Value); // TblCustomer objCustomer = uow.Modules.Customer.Get(Convert.ToInt32(ob.CustomerId)); return(Json(result)); // return RedirectToAction("Detail", MVCController, new { id = jobOrderId, tab = "Product", msg = "ลบข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success }); } catch (Exception ex) { return(Json(result)); } }
public ActionResult SetDetail(TblJobOrder jobOrder) { System.Globalization.CultureInfo _cultureTHInfo = new System.Globalization.CultureInfo("en-US"); List <TblJobOrderProjectType> projectType = null; List <TblJobOrderEquipmentType> EquipmentType = null; List <TblJobOrderLandType> LandType = null; List <TblJobOrderUndergroundType> UndergroundType = null; List <TblJobOrderObstructionType> ObstructionType = null; List <TblJobOrderAttachmentType> AttachmentType = null; int approveStatus = Request.Form["StatusId"] != null ? Request.Form["StatusId"].ParseInt() : 0; string JobOrderId = this.Request.Form["JobOrderId"]; string StartHH = this.Request.Form["StartHH"]; string StartMM = this.Request.Form["StartMM"]; string EndHH = this.Request.Form["EndHH"]; string EndMM = this.Request.Form["EndMM"]; string SaleName = this.Request.Form["SaleName"]; string SaleMobile = this.Request.Form["SaleMobile"]; string hddProject = this.Request.Form["hddProject"]; string hddEquipmentType = this.Request.Form["hddEquipmentType"]; string hddLandType = this.Request.Form["hddLandType"]; string hddUndergroundType = this.Request.Form["hddUndergroundType"]; string hddObstructionType = this.Request.Form["hddObstructionType"]; string hddAttachmentType = this.Request.Form["hddAttachmentType"]; jobOrder.ProductId = this.Request.Form["ProductId"].ParseInt(); jobOrder.StartWorkingTime = StartHH + ":" + StartMM; jobOrder.EndWorkingTime = EndHH + ":" + EndMM; if (JobOrderId == null || JobOrderId == "" || JobOrderId == "0") { jobOrder.JobOrderNo = getJobId(); jobOrder.CreatedDate = DateTime.Now; jobOrder.CreatedBy = CurrentUID; } else { jobOrder.CreatedDate = // jobOrder = uow.Modules.JobOrder.GetHeaderByPK(JobOrderId.ParseInt()); jobOrder.UpdatedDate = DateTime.Now; jobOrder.UpdatedBy = CurrentUID; } jobOrder.StatusId = approveStatus; if (approveStatus == 2) { jobOrder.ApprovedBy = CurrentUID; } if (Request.Form["StartDate"].ToString() != "") { var dd = Request.Form["StartDate"] + " 00:00:00"; jobOrder.StartDate = dd.ParseDate(DateFormat.ddMMyyyyHHmmss, culInfo: _cultureTHInfo); } if (Request.Form["EndDate"].ToString() != "") { var dd = Request.Form["EndDate"].Split(' ')[0] + " 00:00:00"; jobOrder.EndDate = dd.ParseDate(DateFormat.ddMMyyyyHHmmss, culInfo: _cultureTHInfo); } /*# hddProject # hddEquipmentType # hddLandType # hddUndergroundType # hddObstructionType # hddAttachmentType */ try { // uow.Modules.JobOrder.Set(jobOrder); // uow.SaveChanges(); #region Project Type projectType = new List <TblJobOrderProjectType>(); if (hddProject != null && hddProject.Length > 0) { foreach (string id in hddProject.Split(',')) { projectType.Add(new TblJobOrderProjectType() { JobOrderId = jobOrder.JobOrderId, ProjectTypeId = id.ParseInt() }); } jobOrder.ProjectType = projectType; } #endregion #region EquipmentType EquipmentType = new List <TblJobOrderEquipmentType>(); if (hddEquipmentType != null && hddEquipmentType.Length > 0) { foreach (string id in hddEquipmentType.Split(',')) { EquipmentType.Add(new TblJobOrderEquipmentType() { JobOrderId = jobOrder.JobOrderId, EquipmentTypeId = id.ParseInt() }); } jobOrder.EquipmentType = EquipmentType; } #endregion #region LandType LandType = new List <TblJobOrderLandType>(); if (hddLandType != null && hddLandType.Length > 0) { foreach (string id in hddLandType.Split(',')) { LandType.Add(new TblJobOrderLandType() { JobOrderId = jobOrder.JobOrderId, LandTypeId = id.ParseInt() }); } jobOrder.LandType = LandType; } #endregion #region UndergroundType UndergroundType = new List <TblJobOrderUndergroundType>(); if (hddUndergroundType != null && hddUndergroundType.Length > 0) { foreach (string id in hddUndergroundType.Split(',')) { UndergroundType.Add(new TblJobOrderUndergroundType() { JobOrderId = jobOrder.JobOrderId, UndergroundTypeId = id.ParseInt() }); } jobOrder.UndergroundType = UndergroundType; } #endregion #region ObstructionType ObstructionType = new List <TblJobOrderObstructionType>(); if (hddObstructionType != null && hddObstructionType.Length > 0) { foreach (string id in hddObstructionType.Split(',')) { ObstructionType.Add(new TblJobOrderObstructionType() { JobOrderId = jobOrder.JobOrderId, ObstructionTypeId = id.ParseInt() }); } jobOrder.ObstructionType = ObstructionType; } #endregion #region TblJobOrderAttachmentType AttachmentType = new List <TblJobOrderAttachmentType>(); if (hddAttachmentType != null && hddAttachmentType.Length > 0) { foreach (string id in hddAttachmentType.Split(',')) { AttachmentType.Add(new TblJobOrderAttachmentType() { JobOrderId = jobOrder.JobOrderId, AttachmentTypeId = id.ParseInt() }); } jobOrder.AttachmentType = AttachmentType; } #endregion uow.Modules.JobOrder.Set(jobOrder); uow.SaveChanges(); return(RedirectToAction("Detail", MVCController, new { id = jobOrder.JobOrderId, msg = "บันทึกข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success })); } catch (Exception ex) { string msg = ex.GetMessage(true); return(ViewDetail(jobOrder, msg, AlertMsgType.Danger)); } return(RedirectToAction("Detail", MVCController, new { id = 1, msg = "บันทึกข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success })); }