//สรุปรายการซ่อมประจำวัน public ActionResult ReportDay() { ViewBag.ReportList = "first active"; ReportDayViewModel model = new ReportDayViewModel(); model.Report = new ReportDay(); DateTime start = DateTime.Today; model.DateStart = start.AddYears(543); DateTime end = DateTime.Today.AddDays(1); model.DateEnd = Convert.ToDateTime(end.AddYears(543).ToString("MM/dd/yyyy")); model.Report.Repairs = ReportManager.ReportRepairDay(start); model.Report.Claims = ReportManager.ReportClaimDay(start); var workingstatus = WorkingStatusManager.GetAll().Where(m => m.iDefault>=5 && m.iDefault<=7); model.Report.WorkingStatuies = workingstatus.OrderBy(m => m.iDefault).ToList(); model.Report.Insurances = InsuranceManager.GetAll().OrderBy(m => m.sInsuranceName).ToList(); model.Report.TCStaffs = StaffManager.GetAll().Where(m => m.StaffPosition.sDescription == "ช่าง").OrderBy(m => m.sStaffName).ToList(); model.Report.STCStaffs = StaffManager.GetAll().Where(m => m.StaffPosition.sDescription == "หัวหน้าช่าง").OrderBy(m => m.sStaffName).ToList(); model.Report.QCStaffs = StaffManager.GetAll().Where(m => m.StaffPosition.sDescription == "ฝ่ายตรวจสอบคุณภาพ").OrderBy(m => m.sStaffName).ToList(); ViewBag.ReportHeader = String.Format("รายงานบริการประจำวันที่ {0}", DateExtension.DateThaiFormat(start)); return View(model); }
public JsonResult GetAll() { try { var items = WorkingStatusManager.GetAll(); return(Json(new { Result = "OK", Options = items.Select(m => new { DisplayText = m.sDescription, Value = m.kWorkingStatusId }) })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult GetClaimWorkingStatusByPosition() { try { var items = WorkingStatusManager.GetAll() .Where(m => m.iDefault == (int)Working.Claim || m.iDefault == (int)Working.Claiming || m.iDefault == (int)Working.ConfirmRepair) .ToList().OrderBy(m => m.sDescription); return(Json(new { Result = "OK", Options = items.Select(m => new { DisplayText = m.sDescription, Value = m.kWorkingStatusId }) })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public JsonResult GetWorkingStatusByStep(int step) { try { var items = WorkingStatusManager.GetAll(); //ªèÒ§ if (step == 1) { items = items.Where(m => m.iDefault == (int)Working.Claim || m.iDefault == (int)Working.QC || m.iDefault == (int)Working.Repair).ToList(); } // else if (step == 2) { items = items.Where(m => m.iDefault == (int)Working.Claim || m.iDefault == (int)Working.QC || m.iDefault == (int)Working.Repair).ToList(); } return(Json(new { Result = "OK", Options = items.Select(m => new { DisplayText = m.sDescription, Value = m.kWorkingStatusId }) })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public ActionResult Index() { ViewBag.ClientName = User.Identity.Name; ViewBag.ClaimList = "first active"; BookingClaimViewModel model = new BookingClaimViewModel(); ViewBag.WorkingStatus = new SelectList(WorkingStatusManager.GetAll().Where(m => m.iDefault > 0), "kWorkingStatusId", "sDescription"); if (!User.IsInRole("Admin")) { if (Staff.vStaffPositionDescription == "ฝ่ายเครม") { return(View("ListsCR", model)); } else { return(View("ListsUser", model)); } } return(View(model)); }
public ActionResult Create(BookingClaimViewModel model, FormCollection collection) { try { //initial working status var workingStatusId = WorkingStatusManager.GetAll().Where(m => m.iDefault == (int)Working.Claiming).SingleOrDefault(); if (model.Product != null) { model.Product.Brand = BrandManager.GetById(model.Product.kBrandId); } model.Product.ProductType = ProductTypeManager.GetById(model.Product.kProductTypeId); #region SAVE CUSTOMER var insCount = InsuranceManager.GetCountDuplicate(model.Insurance.sInsuranceName.Trim()); if (insCount.Count <= 0) { Insurance insurance = new Insurance { kInsuranceId = Guid.NewGuid(), sInsuranceName = model.Insurance.sInsuranceName, sAddress1 = model.Insurance.sAddress1, sCity = model.Insurance.sCity, sZip = model.Insurance.sZip, sPhone = model.Insurance.sPhone, sMobile = model.Insurance.sMobile, sFax = model.Insurance.sFax, sEmailAddress = model.Insurance.sEmailAddress }; InsuranceManager.Create(insurance); model.Claim.Insurance = insurance; } else { model.Claim.Insurance = insCount[0]; } #endregion #region SAVE Brand var brandCount = BrandManager.GetCountDuplicate(model.Product.Brand.sBrandName.Trim()); if (brandCount.Count <= 0) { Brand brand = new Brand { kBrandId = Guid.NewGuid(), sBrandName = model.Product.Brand.sBrandName }; BrandManager.Create(brand); model.Product.Brand = brand; } else { model.Product.Brand = brandCount[0]; } #endregion #region SAVE Product Type var productTypeCount = ProductTypeManager.GetCountDuplicate(model.Product.ProductType.sDescription.Trim()); if (productTypeCount.Count <= 0) { ProductType productType = new ProductType { kProductTypeId = Guid.NewGuid(), sDescription = model.Product.ProductType.sDescription }; ProductTypeManager.Create(productType); model.Product.ProductType = productType; } else { model.Product.ProductType = productTypeCount[0]; } #endregion #region SAVE PRODUCT var productCount = ProductManager.GetCountDuplicate( model.Product.sProductName.Trim() //, model.Product.Brand.sBrandName.Trim() //, model.Product.ProductType.sDescription.Trim() ); if (productCount.Count <= 0) { Product product = new Product { kProductId = Guid.NewGuid(), kProductTypeId = productTypeCount.SingleOrDefault().kProductTypeId, kBrandId = brandCount.SingleOrDefault().kBrandId, sProductName = model.Product.sProductName, sProductModel = model.Product.sProductModel }; ProductManager.Create(product); model.Product = product; } else { model.Product = productCount[0]; } #endregion #region SAVE CLAIM BOOKING var repair = RepairManager.GetByRepairNo(model.Claim.sRepairNo ?? ""); //initial booking first character string char_number = CharBooking.C.ToString(); Claim claim = new Claim(); claim.dtDateUpdate = DateTime.Now; claim.kClaimId = Guid.NewGuid(); claim.kStaffId = (Guid)Membership.GetUser().ProviderUserKey; claim.kOwnerId = repair.kOwnerId ?? (Guid)Membership.GetUser().ProviderUserKey; claim.kInsuranceId = model.Claim.Insurance.kInsuranceId; claim.kProductId = model.Product.kProductId; claim.sRepairNo = model.Claim.sRepairNo; claim.sClaimNo = String.Format("{0}{1}", char_number, ClaimNextItemNoManager.GetNextItemNo()); claim.sSerial = model.Claim.sSerial; if (model.Claim.dtInsuranceExpire != null) { claim.dtInsuranceExpire = model.Claim.dtInsuranceExpire.Value.AddYears(-543); } model.Claim = claim; ClaimManager.Create(model.Claim); ClaimNextItemNoManager.IncreaseNextItemNo(); #region also pdate repair side repair.dtDateUpdate = DateTime.Now; repair.kStaffId = (Guid)Membership.GetUser().ProviderUserKey; RepairManager.Edit(repair); #endregion #endregion #region SAVE REPAIR WORKING STATUS ClaimStatus claimStatus = new ClaimStatus { kClaimStatusId = Guid.NewGuid(), kWorkingStatusId = workingStatusId.kWorkingStatusId, kStaffId = (Guid)Membership.GetUser().ProviderUserKey, kClaimId = model.Claim.kClaimId }; ClaimStatusManager.Create(claimStatus); #endregion #region UPDATE REPAIR WORKING STATUS if (!String.IsNullOrEmpty(model.Claim.sRepairNo)) { repair = RepairManager.GetByRepairNo(model.Claim.sRepairNo); RepairStatus repairStatus = new RepairStatus { kRepairStatusId = Guid.NewGuid(), kWorkingStatusId = workingStatusId.kWorkingStatusId, kStaffId = (Guid)Membership.GetUser().ProviderUserKey, kRepairId = repair.kRepairId }; RepairStatusManager.Create(repairStatus); } #endregion #region SAVE CAUSE OF CLAIM //initial cause string keyname; string keyvalue; int countvalue = 0; for (int i = 0; i <= collection.Count - 1; i++) { keyname = collection.AllKeys[i]; keyvalue = collection[i]; if (keyname.Contains("cause")) { countvalue++; } } if (countvalue > 1) { model.ClaimCauses = new List <ClaimCause>(); for (int i = 1; i <= countvalue / 4; i++) { ClaimCause claimCause = new ClaimCause(); claimCause.kClaimCauseId = Guid.NewGuid(); claimCause.kClaimId = model.Claim.kClaimId; claimCause.kStaffId = (Guid)Membership.GetUser().ProviderUserKey; claimCause.sDescription = collection[String.Format("cause_description_{0}", i)]; claimCause.sNote = collection[String.Format("cause_note_{0}", i)]; if (!String.IsNullOrEmpty(claimCause.sDescription)) { int qty = 0; if (int.TryParse(collection[String.Format("cause_qty_{0}", i)], out qty)) { claimCause.iQty = qty; } Decimal price = 0; if (Decimal.TryParse(collection[String.Format("cause_price_{0}", i)], out price)) { claimCause.dPrice = price; } model.ClaimCauses.Add(claimCause); ClaimCourseManager.Create(claimCause); } } } if (model.ClaimCauses != null) { foreach (var item in model.ClaimCauses) { var causeCount = CauseManager.GetCountDuplicate(item.sDescription.Trim()); if (causeCount <= 0) { Cause cause = new Cause { kCauseId = Guid.NewGuid(), sDescription = item.sDescription.Trim() }; CauseManager.Create(cause); } } } #endregion } catch (Exception ex) { return(RedirectToAction("Error", "Home")); } Claim model2 = ClaimManager.GetById(model.Claim.kClaimId); //create remind for history RemindHistory remind = new RemindHistory { sRemind = model2.vMessage, kStaffId = model2.kStaffId }; RemindHistoryManager.Create(remind); var clientName = User.Identity.Name; Task.Factory.StartNew(() => { var clients = Hub.GetClients <RealTimeJTableDemoHub>(); clients.RecordCreated(clientName, model2); }); return(RedirectToAction("Index")); }