private void GenQuerySettledPodViewModel(SettledPodManageViewModel vm) { if (base.UserInfo.UserType == 2) { vm.Customers = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID) .Select(c => new SelectListItem() { Value = c.CustomerID.ToString(), Text = c.CustomerName }); vm.Shippers = ApplicationConfigHelper.GetProjectShippers(base.UserInfo.ProjectID) .Select(c => new SelectListItem() { Value = c.ShipperID.ToString(), Text = c.Name }); } else if (base.UserInfo.UserType == 0) { vm.Customers = new List <SelectListItem>() { new SelectListItem() { Value = base.UserInfo.CustomerOrShipperID.ToString(), Text = ApplicationConfigHelper.GetApplicationCustomers().First(c => c.ID == base.UserInfo.CustomerOrShipperID).Name } }; vm.Shippers = ApplicationConfigHelper.GetProjectShippers(base.UserInfo.ProjectID) .Select(c => new SelectListItem() { Value = c.ShipperID.ToString(), Text = c.Name }); } else { vm.Customers = ApplicationConfigHelper.GetProjectCustomers(base.UserInfo.ProjectID).Select(c => new SelectListItem() { Value = c.CustomerID.ToString(), Text = c.Name }); vm.Shippers = new List <SelectListItem> { new SelectListItem() { Value = base.UserInfo.CustomerOrShipperID.ToString(), Text = ApplicationConfigHelper.GetApplicationShippers().First(c => c.ID == base.UserInfo.CustomerOrShipperID).Name } }; } vm.ShipperTypes = ApplicationConfigHelper.GetSystemConfigs(base.UserInfo.ProjectID, WebConstants.SHIPPERTYPE) .Select(c => new SelectListItem() { Value = c.ID.ToString(), Text = c.Name }); vm.PODTypes = ApplicationConfigHelper.GetSystemConfigs(base.UserInfo.ProjectID, WebConstants.PODTYPE) .Select(c => new SelectListItem() { Value = c.ID.ToString(), Text = c.Name }); vm.TtlOrTpls = ApplicationConfigHelper.GetSystemConfigs(base.UserInfo.ProjectID, WebConstants.TTLORTPL) .Select(c => new SelectListItem() { Value = c.ID.ToString(), Text = c.Name }); }
public ActionResult SettledPodManage(int?SettledType, bool?ShowActionButton, bool?ShowSelectCheckBox, bool?IsForAudit, int?AuditType, bool?FinalAudit, bool?IsBatchAdjust) { SettledPodManageViewModel vm = new SettledPodManageViewModel(); vm.SearchCondition = new SettledPodSearchCondition(); vm.SearchCondition.ProjectID = base.UserInfo.ProjectID; this.GenQuerySettledPodViewModel(vm); vm.IsBatchAdjust = false; vm.SearchCondition.ActualDeliveryDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); vm.SearchCondition.EndActualDeliveryDate = vm.SearchCondition.ActualDeliveryDate.Value.AddMonths(1).AddDays(-1); vm.IsInnerUser = base.UserInfo.UserType == 2; vm.ProjectRoleID = base.UserInfo.ProjectRoleID; vm.SearchCondition.SettledType = SettledType ?? 0; vm.IsInvoiced = 0; vm.SearchCondition.IsForAudit = false; vm.Name = base.UserInfo.Name; vm.SearchCondition.IsAudit = true; vm.ShowActionButton = ShowActionButton.HasValue ? ShowActionButton.Value && vm.IsInvoiced == 0 : false; vm.ShowSelectCheckBox = ShowSelectCheckBox.HasValue ? ShowSelectCheckBox.Value && vm.IsInvoiced == 0 : false; vm.SearchCondition.UserType = base.UserInfo.UserType; if (!vm.IsInnerUser) { vm.SearchCondition.CustomerOrShipperID = base.UserInfo.CustomerOrShipperID; } if (IsForAudit != null && IsForAudit.Value) { vm.SearchCondition.IsForAudit = true; vm.IsForAudit = true; vm.ShowActionButton = false; vm.ShowSelectCheckBox = true; vm.SearchCondition.SettledType = 1; vm.AuditType = AuditType ?? 1; vm.SearchCondition.IsAudit = false; if (AuditType == null || AuditType.Value == 1) { vm.SearchCondition.SystemNumberSufixx = "-SD"; } else if (AuditType.Value == 2) { vm.SearchCondition.SystemNumberSufixx = "-DT"; } else if (AuditType.Value == 3) { vm.SearchCondition.SystemNumberSufixx = "-EP"; } else if (AuditType == 4) { vm.SearchCondition.IsManualSettled = true; } else { vm.SearchCondition.SystemNumberSufixx = "-NULL"; } vm.IsInvoiced = 0; vm.FinalAudit = FinalAudit ?? false; } if (IsBatchAdjust != null && IsBatchAdjust.Value) { vm.IsBatchAdjust = true; vm.IsForAudit = false; vm.ShowActionButton = false; vm.ShowSelectCheckBox = false; vm.IsInvoiced = 0; } return(View(vm)); }
public ActionResult SettledPodManage(SettledPodManageViewModel vm) { if (vm.SearchCondition.UserType == 2) { vm.SearchCondition.CustomerIDs = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID).Select(c => c.CustomerID); } if (vm.IsInvoiced == 1) { vm.SearchCondition.InvoiceID = 1; } vm.ShowActionButton = vm.ShowActionButton && vm.IsInvoiced == 0; vm.ShowSelectCheckBox = vm.ShowSelectCheckBox && vm.IsInvoiced == 0; this.GenQuerySettledPodViewModel(vm); var response = new SettledService().GetSettledPodsByCondition(new GetSettledPodsByConditionRequest() { SearchCondition = vm.SearchCondition }); if (response.IsSuccess && vm.IsExport) { DataTable dt = this.InitExportTable(response.Result); //ExcelHelper excelHelper = new ExcelHelper(); //string targetPath = Path.Combine(Runbow.TWS.Common.Constants.UPLOAD_FOLDER_PATH, base.UserInfo.ProjectID.ToString(), "Temp"); //string fileFullPath = Path.Combine(targetPath, "ExportSettledPods_" + base.UserInfo.Name + ".xlsx"); //excelHelper.CreateExcelByDataTable(fileFullPath, dt); //excelHelper.Dispose(); //string mimeType = "application/msexcel"; //FileStream fs = MyFile.Open(fileFullPath, FileMode.Open); //return File(fs, mimeType, "ExportSettledPods.xlsx"); return(ExportDataTableToExcel(dt, "ExportSettledPods.xls")); } if (response.IsSuccess) { vm.SettledPods = response.Result; if (vm.IsForAudit && vm.SettledPods != null && vm.SettledPods.Any()) { var auditResponse = new SettledService().GetSettledHistoryBySettledPodIDs(new GetSettledHistoryBySettledPodIDsRequest() { SettledPodIDs = response.Result.Select(i => i.ID) }); if (auditResponse.IsSuccess) { vm.SettledPodAuditHistoryCollection = auditResponse.Result; } else { vm.Message = "查询有误!"; } } } else { vm.Message = "查询有误"; } return(View(vm)); }