public JsonResult LoadGenerateStorageAndForceFeeCustomersByTimespan(string startTime, string endTime) { string strErrText; CustomerSystem customer = new CustomerSystem(); List<Customer> listCustomer = customer.LoadGenerateStorageAndForceFeeCustomersByTimespan(startTime, endTime, LoginAccountId, LoginStaffName, out strErrText); if (listCustomer == null) { throw new Exception(strErrText); } var ret = from c in listCustomer select new { Id = c.Id.ToString(), Name = c.Name, FullName = c.FullName }; return Json(ret, JsonRequestBehavior.AllowGet); }
public JsonResult LoadCustomerTransportPrice(string planId, string carType) { string strErrText; CustomerSystem customer = new CustomerSystem(); CustomerTransportPrice data = customer.LoadCustomerTransportPriceByPlanId(long.Parse(planId), carType, LoginAccountId, LoginStaffName, out strErrText); if (data == null) { return Json(0, JsonRequestBehavior.AllowGet); } else { return Json(data.TransportPrice, JsonRequestBehavior.AllowGet); } }
public JsonResult LoadGenerateBusinessPayersByTimespan(string startTime, string endTime) { string strErrText; CustomerSystem customer = new CustomerSystem(); List<Customer> listPayer = customer.LoadGenerateBusinessPayersByTimespan(startTime, endTime, LoginAccountId, LoginStaffName, out strErrText); if (listPayer == null) { throw new Exception(strErrText); } var ret = from p in listPayer orderby p.Name select new { Id = p.Id.ToString(), Name = p.Name, FullName = p.FullName }; return Json(ret, JsonRequestBehavior.AllowGet); }
public JsonResult LoadCustomerByName(string strName) { string strErrText; CustomerSystem customer = new CustomerSystem(); Customer data = customer.LoadCustomerByName(strName, LoginAccountId, LoginStaffName, out strErrText); if (data == null) { return Json(null, JsonRequestBehavior.AllowGet); } else { decimal decLoadingForceFeePrice = 0; decimal decUnloadingForceFeePrice = 0; CustomerForceFeePrice data1 = customer.LoadCustomerForceFeePrice(data.Id, DateTime.Now, LoginAccountId, LoginStaffName, out strErrText); if (data1 != null) { decLoadingForceFeePrice = data1.LoadingForceFeePrice; decUnloadingForceFeePrice = data1.UnloadingForceFeePrice; } decimal decStorageFeePrice = 0; CustomerStorageFeePrice data2 = customer.LoadCustomerStorageFeePrice(data.Id, DateTime.Now, LoginAccountId, LoginStaffName, out strErrText); if (data2 != null) { decStorageFeePrice = data2.StorageFeePrice; } var ret = new { Id = data.Id, Name = data.Name, LoadingForceFeePrice = decLoadingForceFeePrice, UnloadingForceFeePrice = decUnloadingForceFeePrice, StorageFeePrice = decStorageFeePrice, OwnOrganId = data.OwnOrganId }; return Json(ret, JsonRequestBehavior.AllowGet); } }
public JsonResult LoadCustomers() { string strErrText = string.Empty; CustomerSystem customer = new CustomerSystem(); List<Customer> listCustomer = customer.LoadCustomers(LoginAccountId, LoginStaffName, out strErrText); if (listCustomer == null) { throw new Exception(strErrText); } var ret = from c in listCustomer select new { c.Id, c.Name }; return Json(ret, JsonRequestBehavior.AllowGet); }
public JsonResult LoadCustomerFullNames(string term) { //读取所有客户数据 string strErrText = string.Empty; CustomerSystem customer = new CustomerSystem(); List<Customer> listCustomer = customer.LoadCustomers(LoginAccountId, LoginStaffName, out strErrText); if (listCustomer == null) { listCustomer = new List<Customer>(); } //提取客户全称中包含关键字的记录 var ret = ( from c in listCustomer where c.FullName.Contains(term) select c.FullName).ToArray(); return Json(ret, JsonRequestBehavior.AllowGet); }
public JsonResult LoadCustomerNames(string term) { //读取所有客户数据 string strErrText = string.Empty; CustomerSystem customer = new CustomerSystem(); List<Customer> listCustomer = customer.LoadCustomerNamesByName(term, LoginAccountId, LoginStaffName, out strErrText); if (listCustomer == null) { listCustomer = new List<Customer>(); } var ret = (from c in listCustomer select c.Name).ToArray(); return Json(ret, JsonRequestBehavior.AllowGet); }
public ActionResult NewCustomer(CustomerViewModel model) { if (ModelState.IsValid) { //创建数据 Customer data = new Customer(); data.Name = model.Name; data.FullName = model.FullName; data.WarningStock = model.WarningStock; data.StopStock = model.StopStock; data.SettlementExpression = model.SettlementExpression; data.ValuationMode = model.ValuationMode; data.GrossWeightRate = decimal.Parse(model.GrossWeightRate); data.OwnOrganId = model.OwnOrganId; data.Remark = model.Remark ?? string.Empty; List<CustomerTransportPrice> listTransportPrice = new List<CustomerTransportPrice>(); if (model.TransportPrices != null) { foreach (CustomerTransportPriceViewModel m in model.TransportPrices) { CustomerTransportPrice p = new CustomerTransportPrice(); p.CustomerId = m.CustomerId; p.StartCountry = m.StartCountry; p.StartProvince = m.StartProvince; p.StartCity = m.StartCity; p.DestCountry = m.DestCountry; p.DestProvince = m.DestProvince; p.DestCity = m.DestCity; p.MinTunnagesOrPiles = m.MinTunnagesOrPiles; p.MaxTunnagesOrPiles = m.MaxTunnagesOrPiles; p.StartTime = DateTime.Parse(m.StartTime); p.EndTime = DateTime.Parse(m.EndTime); p.CarType = m.CarType; p.TransportPrice = m.TransportPrice; p.RiverCrossingCharges = m.RiverCrossingCharges; listTransportPrice.Add(p); } } List<CustomerForceFeePrice> listForceFeePrice = new List<CustomerForceFeePrice>(); if (model.ForceFeePrices != null) { foreach (CustomerForceFeePriceViewModel m in model.ForceFeePrices) { CustomerForceFeePrice p = new CustomerForceFeePrice(); p.CustomerId = m.CustomerId; p.StartTime = DateTime.Parse(m.ForceFeePriceStartTime); p.EndTime = DateTime.Parse(m.ForceFeePriceEndTime); p.LoadingForceFeePrice = m.LoadingForceFeePrice; p.UnloadingForceFeePrice = m.UnloadingForceFeePrice; listForceFeePrice.Add(p); } } List<CustomerStorageFeePrice> listStorageFeePrice = new List<CustomerStorageFeePrice>(); if (model.StorageFeePrices != null) { foreach (CustomerStorageFeePriceViewModel m in model.StorageFeePrices) { CustomerStorageFeePrice p = new CustomerStorageFeePrice(); p.CustomerId = m.CustomerId; p.StartTime = DateTime.Parse(m.StorageFeePriceStartTime); p.EndTime = DateTime.Parse(m.StorageFeePriceEndTime); p.StorageFeePrice = m.StorageFeePrice; listStorageFeePrice.Add(p); } } //保存数据 string strErrText; CustomerSystem customer = new CustomerSystem(); if (customer.InsertCustomer(data, listTransportPrice, listForceFeePrice, listStorageFeePrice, LoginAccountId, LoginStaffName, out strErrText) > 0) { return Json(string.Empty); } else { return Json(strErrText); } } return View(model); }
public ActionResult UploadCustomersFile() { try { if (Request.Files.Count > 0) { HttpPostedFileBase uploadFile = Request.Files[0] as HttpPostedFileBase; if (uploadFile.ContentLength > 0) { //上传文件 string strDestFolder = HttpContext.Server.MapPath("/AttachFiles") + @"\" + DateTime.Now.ToString("yyyy-MM-dd"); if (!Directory.Exists(strDestFolder)) Directory.CreateDirectory(strDestFolder); string filePath = strDestFolder + @"\" + Guid.NewGuid().ToString() + Path.GetExtension(uploadFile.FileName); uploadFile.SaveAs(filePath); //读取数据 string strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\""; using (OleDbConnection conn = new System.Data.OleDb.OleDbConnection(strConnectionString)) { conn.Open(); using (DataTable dtExcelSchema = conn.GetSchema("Tables")) { string strSheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString(); string strQuery = "SELECT * FROM [" + strSheetName + "]"; OleDbDataAdapter adapter = new OleDbDataAdapter(strQuery, conn); DataSet ds = new DataSet(); adapter.Fill(ds, "Items"); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Customer data = new Customer(); data.Name = ds.Tables[0].Rows[i][1].ToString(); data.FullName = ds.Tables[0].Rows[i][2].ToString(); data.WarningStock = int.Parse(ds.Tables[0].Rows[i][6].ToString()); data.StopStock = int.Parse(ds.Tables[0].Rows[i][7].ToString()); data.SettlementExpression = ds.Tables[0].Rows[i][8].ToString(); data.ValuationMode = ds.Tables[0].Rows[i][9].ToString(); data.GrossWeightRate = decimal.Parse(ds.Tables[0].Rows[i][10].ToString()); data.OwnOrganId = long.Parse(ds.Tables[0].Rows[i][11].ToString()); data.Remark = ds.Tables[0].Rows[i][12].ToString(); string strErrText; CustomerSystem customer = new CustomerSystem(); if (customer.InsertCustomer(data, new List<CustomerTransportPrice>(), new List<CustomerForceFeePrice>(), new List<CustomerStorageFeePrice>(), LoginAccountId, LoginStaffName, out strErrText) <= 0) { return Content(string.Format(InnoSoft.LS.Resources.Strings.ImportFailed, strErrText, i + 2)); } } } } } } } } return Content(string.Empty); } catch (Exception e) { return Content(e.Message); } }
public ActionResult ModifyCustomer(string id) { string strErrText; //生成Model数据 CustomerSystem customer = new CustomerSystem(); Customer data = customer.LoadCustomer(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText); if (data == null) { throw new Exception(strErrText); } CustomerViewModel model = new CustomerViewModel(); model.Id = data.Id; model.Name = data.Name; model.FullName = data.FullName; model.WarningStock = data.WarningStock; model.StopStock = data.StopStock; model.SettlementExpression = data.SettlementExpression; model.ValuationMode = data.ValuationMode; model.GrossWeightRate = data.GrossWeightRate.ToString("#0.######"); model.OwnOrganId = data.OwnOrganId; model.Remark = data.Remark; model.TransportPrices = new List<CustomerTransportPriceViewModel>(); model.TransportPrices.Add(new CustomerTransportPriceViewModel()); model.ForceFeePrices = new List<CustomerForceFeePriceViewModel>(); model.ForceFeePrices.Add(new CustomerForceFeePriceViewModel()); model.StorageFeePrices = new List<CustomerStorageFeePriceViewModel>(); model.StorageFeePrices.Add(new CustomerStorageFeePriceViewModel()); //生成所属组织部门下拉列表项 OrganizationSystem organ = new OrganizationSystem(); List<Organization> listOrgan = organ.LoadOrganizations(LoginAccountId, LoginStaffName, out strErrText); if (listOrgan == null) { throw new Exception(strErrText); } Organization root = listOrgan.Find(delegate(Organization o) { return o.ParentId == 0; }); List<SelectListItem> selectListOrgan = new List<SelectListItem>(); selectListOrgan.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListOrgan.AddRange(from o in listOrgan where o.ParentId == root.Id select new SelectListItem { Text = o.Name, Value = o.Id.ToString() }); ViewData["OwnOrgans"] = new SelectList(selectListOrgan, "Value", "Text", model.OwnOrganId.ToString()); //生成国家下拉列表项 DDSystem dd = new DDSystem(); List<Country> listCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listCountry == null) { throw new Exception(strErrText); } List<SelectListItem> selectListCountry = new List<SelectListItem>(); selectListCountry.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListCountry.AddRange(from c in listCountry select new SelectListItem { Text = c.Name, Value = c.Name }); ViewData["Countrys"] = new SelectList(selectListCountry, "Value", "Text"); //生成空的省份下拉列表项 List<Province> listState = new List<Province>(); List<SelectListItem> selectListState = new List<SelectListItem>(); selectListState.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListState.AddRange(from s in listState select new SelectListItem { Text = s.Name, Value = s.Name }); ViewData["Provinces"] = new SelectList(selectListState, "Value", "Text"); //生成空的城市下拉列表项 List<City> listCity = new List<City>(); List<SelectListItem> selectListCity = new List<SelectListItem>(); selectListCity.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListCity.AddRange(from ci in listCity select new SelectListItem { Text = ci.Name, Value = ci.Name }); ViewData["Citys"] = new SelectList(selectListCity, "Value", "Text"); return View(model); }
public ActionResult ExportCustomers() { string strErrText; //读取全部数据 CustomerSystem customer = new CustomerSystem(); List<Customer> listCustomer = customer.LoadCustomers(LoginAccountId, LoginStaffName, out strErrText); if (listCustomer == null) { throw new Exception(strErrText); } //生成GridView BoundField colCustomerId = new BoundField(); colCustomerId.HeaderText = InnoSoft.LS.Resources.Labels.CustomerId; colCustomerId.DataField = "CustomerId"; BoundField colName = new BoundField(); colName.HeaderText = InnoSoft.LS.Resources.Labels.CustomerName; colName.DataField = "Name"; BoundField colFullName = new BoundField(); colFullName.HeaderText = InnoSoft.LS.Resources.Labels.CustomerFullName; colFullName.DataField = "FullName"; BoundField colWarningStock = new BoundField(); colWarningStock.HeaderText = InnoSoft.LS.Resources.Labels.WarningStock; colWarningStock.DataField = "WarningStock"; BoundField colStopStock = new BoundField(); colStopStock.HeaderText = InnoSoft.LS.Resources.Labels.StopStock; colStopStock.DataField = "StopStock"; BoundField colSettlementExpression = new BoundField(); colSettlementExpression.HeaderText = InnoSoft.LS.Resources.Labels.SettlementExpression; colSettlementExpression.DataField = "SettlementExpression"; BoundField colValuationMode = new BoundField(); colValuationMode.HeaderText = InnoSoft.LS.Resources.Labels.ValuationMode; colValuationMode.DataField = "ValuationMode"; BoundField colGrossWeightRate = new BoundField(); colGrossWeightRate.HeaderText = InnoSoft.LS.Resources.Labels.GrossWeightRate; colGrossWeightRate.DataField = "GrossWeightRate"; BoundField colOwnOrganId = new BoundField(); colOwnOrganId.HeaderText = InnoSoft.LS.Resources.Labels.OwnOrganId; colOwnOrganId.DataField = "OwnOrganId"; BoundField colOwnOrganName = new BoundField(); colOwnOrganName.HeaderText = InnoSoft.LS.Resources.Labels.OwnOrganName; colOwnOrganName.DataField = "OwnOrganName"; BoundField colRemark = new BoundField(); colRemark.HeaderText = InnoSoft.LS.Resources.Labels.Remark; colRemark.DataField = "Remark"; var grid = new GridView(); grid.Columns.Add(colCustomerId); grid.Columns.Add(colName); grid.Columns.Add(colFullName); grid.Columns.Add(colWarningStock); grid.Columns.Add(colStopStock); grid.Columns.Add(colSettlementExpression); grid.Columns.Add(colValuationMode); grid.Columns.Add(colGrossWeightRate); grid.Columns.Add(colOwnOrganId); grid.Columns.Add(colOwnOrganName); grid.Columns.Add(colRemark); grid.AutoGenerateColumns = false; grid.DataSource = from c in listCustomer select new { CustomerId = c.Id, Name = c.Name, FullName = c.FullName, WarningStock = c.WarningStock > 0 ? c.WarningStock.ToString() : string.Empty, StopStock = c.StopStock > 0 ? c.StopStock.ToString() : string.Empty, SettlementExpression = c.SettlementExpression, ValuationMode = c.ValuationMode, GrossWeightRate = c.GrossWeightRate > 0 ? c.GrossWeightRate.ToString("#0.######") : string.Empty, OwnOrganId = c.OwnOrganId, OwnOrganName = c.OwnOrganName, Remark = c.Remark }; grid.DataBind(); //导出GridView Response.ClearContent(); Response.Charset = InnoSoft.LS.Resources.Encoding.ExcelCharset; Response.ContentEncoding = System.Text.Encoding.GetEncoding(InnoSoft.LS.Resources.Encoding.ExcelContent); Response.ContentType = "application/ms-excel"; Response.Write("<meta http-equiv=Content-Type content=text/html charset=" + InnoSoft.LS.Resources.Encoding.ExcelCharset + ">"); Response.AddHeader("content-disposition", "attachment; filename=Customer.xls"); StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); grid.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); return View("SetCustomer"); }
public ActionResult ModifyAccount(string id) { string strErrText; //生成Model数据 long nAccountId = long.Parse(id); AuthenticateSystem auth = new AuthenticateSystem(); Account data = auth.LoadAccount(nAccountId, LoginAccountId, LoginStaffName, out strErrText); if (data == null) { throw new Exception(strErrText); } AccountViewModel model = new AccountViewModel(); model.Id = data.Id; model.Name = data.Name; model.Password = data.Password; model.AccountType = data.AccountType; model.OrganId = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? data.OrganId : 0; model.StaffId = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? data.StaffId : 0; model.CustomerId = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? 0 : data.OrganId; model.ContactName = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? string.Empty : data.StaffName; model.IsCancel = data.IsCancel; if (data.AccountType == InnoSoft.LS.Resources.Options.Staff) { //生成组织部门下拉列表 OrganizationSystem organ = new OrganizationSystem(); List<Organization> listOrganization = organ.LoadOrganizations(LoginAccountId, LoginStaffName, out strErrText); if (listOrganization == null) { throw new Exception(strErrText); } List<SelectListItem> selectListOrganization = new List<SelectListItem>(); selectListOrganization.Add(new SelectListItem { Text = string.Empty, Value = "0" }); selectListOrganization.AddRange(from o in listOrganization orderby o.FullName select new SelectListItem { Text = o.FullName, Value = o.Id.ToString() }); ViewData["Organizations"] = new SelectList(selectListOrganization, "Value", "Text", model.OrganId); //生成空的客户下拉列表 List<Customer> listCustomer = new List<Customer>(); List<SelectListItem> selectListCustomer = new List<SelectListItem>(); selectListCustomer.Add(new SelectListItem { Text = string.Empty, Value = "0" }); selectListCustomer.AddRange(from c in listCustomer select new SelectListItem { Text = c.Name, Value = c.Id.ToString() }); ViewData["Customers"] = new SelectList(selectListCustomer, "Value", "Text"); } else { //生成空的组织部门下拉列表 { List<Organization> listOrganization = new List<Organization>(); List<SelectListItem> selectListOrganization = new List<SelectListItem>(); selectListOrganization.Add(new SelectListItem { Text = string.Empty, Value = "0" }); selectListOrganization.AddRange(from o in listOrganization select new SelectListItem { Text = o.FullName, Value = o.Id.ToString() }); ViewData["Organizations"] = new SelectList(selectListOrganization, "Value", "Text"); } //生成客户下拉列表 CustomerSystem customer = new CustomerSystem(); List<Customer> listCustomer = customer.LoadCustomers(LoginAccountId, LoginStaffName, out strErrText); if (listCustomer == null) { throw new Exception(strErrText); } List<SelectListItem> selectListCustomer = new List<SelectListItem>(); selectListCustomer.Add(new SelectListItem { Text = string.Empty, Value = "0" }); selectListCustomer.AddRange(from c in listCustomer orderby c.Name select new SelectListItem { Text = c.Name, Value = c.Id.ToString() }); ViewData["Customers"] = new SelectList(selectListCustomer, "Value", "Text", model.OrganId); } //生成员工下拉列表 if (data.AccountType == InnoSoft.LS.Resources.Options.Staff) { StaffSystem staff = new StaffSystem(); List<Staff> listStaff = staff.LoadStaffsByOrganId(model.OrganId, LoginAccountId, LoginStaffName, out strErrText); if (listStaff == null) { throw new Exception(strErrText); } List<SelectListItem> selectListStaff = new List<SelectListItem>(); selectListStaff.Add(new SelectListItem { Text = string.Empty, Value = "0" }); selectListStaff.AddRange(from s in listStaff select new SelectListItem { Text = s.FullName, Value = s.Id.ToString() }); ViewData["Staffs"] = new SelectList(selectListStaff, "Value", "Text", model.StaffId); } else { List<Staff> listStaff = new List<Staff>(); List<SelectListItem> selectListStaff = new List<SelectListItem>(); selectListStaff.Add(new SelectListItem { Text = string.Empty, Value = "0" }); selectListStaff.AddRange(from s in listStaff select new SelectListItem { Text = s.Name, Value = s.Id.ToString() }); ViewData["Staffs"] = new SelectList(selectListStaff, "Value", "Text"); } return View(model); }
public ActionResult DeleteCustomer(string id) { //删除数据 string strErrText; CustomerSystem customer = new CustomerSystem(); if (customer.DeleteCustomer(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText)) { return Json(string.Empty); } else { return Json(strErrText); } }
public JsonResult LoadCustomerTransportPriceGrid(string id, string sidx, string sord, int page, int rows) { //读取全部数据 string strErrText; CustomerSystem customer = new CustomerSystem(); List<CustomerTransportPrice> listPrice = customer.LoadCustomerTransportPricesByCustomerId(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText); if (listPrice == null) { throw new Exception(strErrText); } //提取当前页面数据 int nTotalRows = listPrice.Count; int nPageIndex = page; int nPageSize = rows; int nTotalPages = nTotalRows / nPageSize; if (nTotalRows % nPageSize > 0) nTotalPages++; string sortExpression = (sidx ?? "Id") + " " + (sord ?? "ASC"); var data = listPrice.OrderBy(sortExpression).Skip((nPageIndex - 1) * nPageSize).Take(nPageSize).ToList(); //生成表格数据 var ret = new { total = nTotalPages, page = nPageIndex, records = nTotalRows, rows = ( from p in data select new { id = p.Id, cell = new string[] { p.Id.ToString(), p.StartCountry, p.StartProvince, p.StartCity, p.DestCountry, p.DestProvince, p.DestCity, p.MinTunnagesOrPiles.ToString("#0.######"), p.MaxTunnagesOrPiles.ToString("#0.######"), p.StartTime.ToString("yyyy-MM-dd"), p.EndTime.ToString("yyyy-MM-dd"), p.CarType, p.TransportPrice.ToString("#0.######"), p.RiverCrossingCharges.ToString() } }).ToArray() }; return Json(ret, JsonRequestBehavior.AllowGet); }
public JsonResult LoadCustomersGrid(string sidx, string sord, int page, int rows, string customerName) { //读取全部数据 string strErrText; CustomerSystem customer = new CustomerSystem(); List<Customer> listCustomer = customer.LoadCustomersByConditions(customerName, LoginAccountId, LoginStaffName, out strErrText); if (listCustomer == null) { throw new Exception(strErrText); } //提取当前页面数据 int nTotalRows = listCustomer.Count; int nPageIndex = page; int nPageSize = rows; int nTotalPages = nTotalRows / nPageSize; if (nTotalRows % nPageSize > 0) nTotalPages++; string sortExpression = (sidx ?? "CustomerId") + " " + (sord ?? "ASC"); var data = listCustomer.OrderBy(sortExpression).Skip((nPageIndex - 1) * nPageSize).Take(nPageSize).ToList(); //生成表格数据 var ret = new { total = nTotalPages, page = nPageIndex, records = nTotalRows, rows = ( from c in data select new { id = c.Id, cell = new string[] { c.Id.ToString(), c.Name, c.FullName, c.WarningStock.ToString(), c.StopStock.ToString(), c.SettlementExpression, c.ValuationMode, c.GrossWeightRate.ToString("#0.######"), c.OwnOrganName, c.Remark } }).ToArray() }; return Json(ret, JsonRequestBehavior.AllowGet); }
public ActionResult CustomerNewPaperPlan() { string strErrText; //创建空的Model PaperPlanViewModel model = new PaperPlanViewModel(); model.CreateTime = DateTime.Now.ToString("yyyy-MM-dd"); model.Goods = new List<PaperPlanGoodsViewModel>(); model.Goods.Add(new PaperPlanGoodsViewModel()); //设置客户信息和付款单位信息 if (LoginAccountType == InnoSoft.LS.Resources.Options.Customer) { model.CustomerId = LoginOrganId; model.CustomerName = LoginOrganName; model.PayerId = model.CustomerId; model.PayerName = model.CustomerName; //读取客户所属办事处数据 CustomerSystem customer = new CustomerSystem(); Customer dataCustomer = customer.LoadCustomer(model.CustomerId, LoginAccountId, LoginStaffName, out strErrText); if (dataCustomer == null) { throw new Exception(strErrText); } OrganizationSystem organ = new OrganizationSystem(); Organization dataOrgan = organ.LoadOrganization(dataCustomer.OwnOrganId, LoginAccountId, LoginStaffName, out strErrText); if (dataOrgan == null) { throw new Exception(strErrText); } model.StartCountry = dataOrgan.CountryName; model.StartProvince = dataOrgan.ProvinceName; model.StartCity = dataOrgan.CityName; } //生成讫点国家下拉列表项 DDSystem dd = new DDSystem(); List<Country> listDestCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listDestCountry == null) { throw new Exception(strErrText); } List<SelectListItem> selectListDestCountry = new List<SelectListItem>(); selectListDestCountry.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListDestCountry.AddRange(from c in listDestCountry select new SelectListItem { Text = c.Name, Value = c.Name }); ViewData["DestCountrys"] = new SelectList(selectListDestCountry, "Value", "Text"); //生成空的讫点省份下拉列表项 List<Province> listDestProvince = new List<Province>(); List<SelectListItem> selectListDestProvince = new List<SelectListItem>(); selectListDestProvince.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListDestProvince.AddRange(from s in listDestProvince select new SelectListItem { Text = s.Name, Value = s.Name }); ViewData["DestProvinces"] = new SelectList(selectListDestProvince, "Value", "Text"); //生成空的讫点城市下拉列表项 List<City> listDestCity = new List<City>(); List<SelectListItem> selectListDestCity = new List<SelectListItem>(); selectListDestCity.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListDestCity.AddRange(from ci in listDestCity select new SelectListItem { Text = ci.Name, Value = ci.Name }); ViewData["DestCitys"] = new SelectList(selectListDestCity, "Value", "Text"); //生成起点国家下拉列表项 List<Country> listStartCountry = dd.LoadCountrys(LoginAccountId, LoginStaffName, out strErrText); if (listStartCountry == null) { throw new Exception(strErrText); } List<SelectListItem> selectListStartCountry = new List<SelectListItem>(); selectListStartCountry.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListStartCountry.AddRange(from c in listStartCountry select new SelectListItem { Text = c.Name, Value = c.Name }); ViewData["StartCountrys"] = new SelectList(selectListStartCountry, "Value", "Text", model.StartCountry); //生成起点省份下拉列表项 List<Province> listStartProvince = null; if (!string.IsNullOrEmpty(model.StartCountry)) { listStartProvince = dd.LoadProvincesByCountry(model.StartCountry, LoginAccountId, LoginStaffName, out strErrText); if (listStartProvince == null) { throw new Exception(strErrText); } } else { listStartProvince = new List<Province>(); } List<SelectListItem> selectListStartProvince = new List<SelectListItem>(); selectListStartProvince.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListStartProvince.AddRange(from p in listStartProvince select new SelectListItem { Text = p.Name, Value = p.Name }); ViewData["StartProvinces"] = new SelectList(selectListStartProvince, "Value", "Text", model.StartProvince); //生成起点城市下拉列表项 List<City> listStartCity = null; if (!string.IsNullOrEmpty(model.StartProvince)) { listStartCity = dd.LoadCitysByProvince(model.StartCountry, model.StartProvince, LoginAccountId, LoginStaffName, out strErrText); if (listStartCity == null) { throw new Exception(strErrText); } } else { listStartCity = new List<City>(); } List<SelectListItem> selectListStartCity = new List<SelectListItem>(); selectListStartCity.Add(new SelectListItem { Text = string.Empty, Value = string.Empty }); selectListStartCity.AddRange(from ci in listStartCity select new SelectListItem { Text = ci.Name, Value = ci.Name }); ViewData["StartCitys"] = new SelectList(selectListStartCity, "Value", "Text", model.StartCity); return View(model); }