private void Form1_Load(object sender, EventArgs e) { //Create a DataSet from the XML file string filePath = "..\\..\\Employees.xml"; DataSet ds = new DataSet(); ds.ReadXml(filePath); //Create and add barcode column DataColumn dc = new DataColumn("BarcodeImage", typeof(byte[])); ds.Tables[0].Columns.Add(dc); //We'll use Code 128 Barcode Symbology BaseBarcode b = BarcodeFactory.GetBarcode(Symbology.Code128); b.Height = 50; b.FontHeight = 0.3F; //Now, generate and fill barcode images foreach (DataRow dr in ds.Tables[0].Rows) { //We'll encode the ID column b.Number = (string)dr["ID"]; //Create bitmap and save it to BarcodeImage column MemoryStream ms = new MemoryStream(); b.Save(ms, ImageType.Png); dr["BarcodeImage"] = ms.GetBuffer(); } CrystalReport1 report = new CrystalReport1(); report.SetDataSource(ds); crystalReportViewer1.ReportSource = report; }
public IBarcode Add(string barcodeString, SaleStatus status) { //匹配已存在商品(1、状态相同(Promotion促销状态此时默认与正常状态为同一状态)2、条码相同(一品多码、多条码串、主条目)3、该商品不能为称重商品 4、商品要允许改价) var product = OrderList.Where(o => o.Details.EnableEditNum && (o.Details.SaleStatus == status || (status == SaleStatus.Normal && o.Details.SaleStatus == SaleStatus.Promotion)) && o.ProductType != ProductType.Weigh && !o.HasEditPrice && o.SameProduct(barcodeString)).FirstOrDefault(); if (product != null) { product.SaleNumber++; } else { product = BarcodeFactory.Factory(MachineInformation.StoreId, MachineInformation.MachineSn, MachineInformation.CompanyId, barcodeString, status); switch (status) { case SaleStatus.POSGift: case SaleStatus.ActivityGifts: product.SalePrice = 0; break; } OrderList.Add(product); } //移除活动赠品 ResetProduct(status); return(product); }
public void ProcessGatewayRequest(IContext context, IRegisteredComponent component) { BaseBarcode b = BarcodeFactory.GetBarcode(Symbology.EAN128); b.Number = _number; WriteBarcodeImageToStream(b); }
/// <summary> /// 增加退换货商品 /// </summary> /// <param name="barcodeStr"></param> /// <param name="storeId"></param> /// <param name="machineSn"></param> /// <param name="companyToken"></param> /// <returns></returns> public object Add(string barcodeStr, string storeId, string machineSn, int companyToken, bool status) { var changingItem = ChangingList.Where(o => VerfyProduct(new ChangeProduct() { IsChange = status, MainBarcode = barcodeStr, }, o)).FirstOrDefault(); if (changingItem == null) { var barcode = BarcodeFactory.Factory(storeId, machineSn, companyToken, barcodeStr); ChangingList.Add(new ChangeProduct(barcode, status)); } else { if (status) { changingItem.ChangeNumber++; } else { changingItem.ChangeNumber--; } changingItem.Total = changingItem.ChangeNumber * changingItem.ChangePrice; } return(new { ChangingList, Difference, PaySn = CustomOrderSn }); }
public void Generate(IData data, IFile file) { var barcode = BarcodeFactory.GetBarcode(data); var generator = new Genarator(barcode, file); generator.Generate(); }
private void button1_Click(object sender, EventArgs e) { BaseBarcode b = BarcodeFactory.GetBarcode(Symbology.I2of5); b.Number = "123456789"; b.ChecksumAdd = true; b.Rotation = RotationType.Degrees90; pictureBox1.Image = b.Render(); }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { this.barcodeControl1.Render(e.Graphics, 100, 100); BaseBarcode b = BarcodeFactory.GetBarcode(Symbology.I2of5); b.Number = "123456789"; b.ChecksumAdd = true; b.Rotation = RotationType.Degrees90; // 92 dots per inch (screen resolution) * 1.5 cm /2.54 inch b.Height = (int)(92.0F * 1.5 / 2.54); // 1.5 cm b.NarrowBarWidth = (int)(92.0F * 0.05 / 2.54); // 0.5 mm b.Render(e.Graphics, 300, 100); }
private void buttonGenerate_Click(object sender, EventArgs e) { BaseBarcode barcode = BarcodeFactory.GetBarcode(Symbology.EAN13); barcode.Number = tbEan.Text; if (cbControlSum.Checked == true) { barcode.ChecksumAdd = true; } else { barcode.ChecksumAdd = false; } pbBarCode.Image = barcode.Render(); barcode.Save("barcode.png", ImageType.Png); }
private void Generate_Click(object sender, EventArgs e) { BaseBarcode barcode = BarcodeFactory.GetBarcode(Symbology.EAN13); barcode.Number = textBoxEAN.Text; if (checkBoxSumCtrl.Checked) { barcode.ChecksumAdd = true; } else { barcode.ChecksumAdd = false; } pictureBoxBarcode.Image = barcode.Render(); barcode.Save("barcode.png", ImageType.Png); }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.PageUnit = GraphicsUnit.Pixel; BaseBarcode b = BarcodeFactory.GetBarcode(Symbology.I2of5); b.Number = "123456789"; b.ChecksumAdd = true; b.Rotation = RotationType.Degrees90; b.Height = CentimetersToPixels(2.5, e.Graphics.DpiY); // 2.5 cm b.NarrowBarWidth = CentimetersToPixels(0.05, e.Graphics.DpiX); // 0.05 cm = 0.5 mm b.Render(e.Graphics, CentimetersToPixels(1.0, e.Graphics.DpiX), CentimetersToPixels(1.0, e.Graphics.DpiY)); }
private IBarcode GetBarcode() { BarcodeTypes bt; switch (this.Type.ToUpper()) { case "EAN128": bt = BarcodeTypes.Ean_128; break; case "GS1-128": bt = BarcodeTypes.Gs1_128; break; default: throw new NotSupportedException($"Barcode type [{this.Type}] - not supported"); } return(BarcodeFactory.Create(bt)); }
static void Main(string[] args) { // Later we will set the resolution to 300 dpi (dots per inch) // 36 PostScript points = 0.5 inches (1.27 cm) BaseBarcode barcode = BarcodeFactory.GetBarcode(Symbology.Code39Ext); barcode.Number = "1234567890"; barcode.NarrowBarWidth = 12; // 12 dots / 300 dpi = 0.04 inch (0.1 cm) barcode.ChecksumAdd = true; barcode.ChecksumVisible = true; barcode.Height = 600; // Barcode image after printing will be 2 inches high (600 dots / 300 dpi) including the text barcode.FontHeight = 0.25f; // font size will be 0.5 inch (1.27 cm) height (2 inch * 0.25) which is 36 PostScript points // here we set the resolution barcode.Save(_fileName, ImageType.Png, 300, 300); Console.WriteLine("Barcode saved to: '{0}'", Path.GetFullPath(_fileName)); Console.ReadKey(true); }
/// <summary> /// 匹配促销信息 /// </summary> /// <param name="shoppingCart">购物车</param> /// <param name="outObj">输出促销匹配结果</param> /// <param name="zuHeMinus">组合立减金额</param> /// <param name="manYuanMinus">满元立减金额</param> /// <returns>总额促销</returns> public decimal Match(ShoppingCart shoppingCart, out IEnumerable <MarketingContext> outObj, out decimal zuHeMinus, out decimal manYuanMinus) { zuHeMinus = 0; //默认 manYuanMinus = 0; //默认 var tempRules = CurrentRules; //防止自动更新促销信息时,匹配促销活动方式资源争抢,造成死锁 List <MarketingContext> result = new List <MarketingContext>(); decimal totalPreferential = 0; if (tempRules == null || tempRules.Count() == 0) { goto Return; } var marketingGroups = tempRules.GroupBy(o => o.Type).OrderBy(p => p.Key).ToList();//促销优惠顺序 单品折扣-》买赠促销-》组合促销-》满元促销 foreach (var child in marketingGroups) { List <ActiveMarketingRule> marketings; if (child.Key == MarketingType.Manyuan) { marketings = child.OrderByDescending(o => o.RuleNumber).ToList();//满元同等促销顺序 按最新规则金额为最优 } else { marketings = child.OrderByDescending(o => o.CreateRuleDate).ToList();//同等促销顺序 按最新创建日期为最优 } foreach (var item in marketings) { var context = item.Match(shoppingCart, StoreId); if (context != MarketingContext.Empty) { switch (context.MarketingRule.MarketingAction.MarketingActionMode) { case MarketingActionMode.DiscountAmount: if (context.MarketingRule.MeteringMode == MeteringMode.GuDingLiang) { foreach (var product in context.MatchRanges) { var num = product.SaleNumber - context.MarketingRule.RuleNumber; if (num > 0) { var barcode = BarcodeFactory.Factory(shoppingCart.MachineInformation.StoreId, shoppingCart.MachineInformation.MachineSn, shoppingCart.MachineInformation.CompanyId, product.MainBarcode, product.Details.SaleStatus, product.Details.MarketingRuleId); barcode.SaleNumber = num; barcode.MarketingPrice = barcode.SalePrice; barcode.Details.CollectionMarketingPrice = product.MarketingPrice; barcode.Details.Total = barcode.SalePrice * num; barcode.Details.SaleStatus = SaleStatus.Normal; barcode.MarketingMarks = new List <ActiveMarketingRule>(); var index = shoppingCart.OrderList.IndexOf(product); shoppingCart.OrderList.Insert(index + 1, barcode); product.SaleNumber = context.MarketingRule.RuleNumber; } product.MarketingPrice = context.MarketingRule.MarketingAction.DiscountAmount / context.MarketingRule.RuleNumber; product.Details.CollectionMarketingPrice = product.MarketingPrice; product.Details.Total = context.MarketingRule.MarketingAction.DiscountAmount; product.Details.SaleStatus = SaleStatus.Promotion; product.Details.EnableEditNum = false; } } break; case MarketingActionMode.RepetitionDiscountAmount: if (context.MarketingRule.MeteringMode == MeteringMode.GuDingLiang) { foreach (var product in context.MatchRanges) { var saleNum = product.SaleNumber; var num = saleNum % context.MarketingRule.RuleNumber; var index = shoppingCart.OrderList.IndexOf(product); product.SaleNumber = context.MarketingRule.RuleNumber; product.MarketingPrice = context.MarketingRule.MarketingAction.DiscountAmount / context.MarketingRule.RuleNumber; product.Details.CollectionMarketingPrice = product.MarketingPrice; product.Details.Total = product.MarketingPrice * product.SaleNumber; product.Details.SaleStatus = SaleStatus.Promotion; var saleNumber = saleNum - num - context.MarketingRule.RuleNumber; while (saleNumber > 0) { var barcode = BarcodeFactory.Factory(shoppingCart.MachineInformation.StoreId, shoppingCart.MachineInformation.MachineSn, shoppingCart.MachineInformation.CompanyId, product.MainBarcode, product.Details.SaleStatus, product.Details.MarketingRuleId); barcode.SaleNumber = context.MarketingRule.RuleNumber; saleNumber -= context.MarketingRule.RuleNumber; barcode.MarketingPrice = context.MarketingRule.MarketingAction.DiscountAmount / context.MarketingRule.RuleNumber; barcode.Details.CollectionMarketingPrice = barcode.MarketingPrice; barcode.Details.Total = barcode.MarketingPrice * barcode.SaleNumber; barcode.Details.SaleStatus = SaleStatus.Promotion; barcode.MarketingMarks = product.MarketingMarks; shoppingCart.OrderList.Insert(++index, barcode); } if (num > 0) { var barcode = BarcodeFactory.Factory(shoppingCart.MachineInformation.StoreId, shoppingCart.MachineInformation.MachineSn, shoppingCart.MachineInformation.CompanyId, product.MainBarcode, product.Details.SaleStatus, product.Details.MarketingRuleId); barcode.SaleNumber = num; barcode.MarketingPrice = barcode.SalePrice; barcode.Details.CollectionMarketingPrice = product.MarketingPrice; barcode.Details.Total = barcode.SalePrice * num; barcode.Details.SaleStatus = SaleStatus.Normal; barcode.MarketingMarks = new List <ActiveMarketingRule>(); shoppingCart.OrderList.Insert(++index, barcode); } } } break; case MarketingActionMode.Discount: foreach (var product in context.MatchRanges) { product.MarketingPrice = product.MarketingPrice * (context.MarketingRule.MarketingAction.Discount / 10); product.Details.CollectionMarketingPrice = product.MarketingPrice; product.Details.Total = product.MarketingPrice * product.SaleNumber; product.Details.SaleStatus = SaleStatus.Promotion; } break; case MarketingActionMode.NowCash: //组合或者 满元 if (context.MarketingRule.IsRepeatMarketing) { decimal multiple = 1m; switch (context.MarketingRule.MeteringMode) { case MeteringMode.ManYuan: multiple = (int)(context.ProductTotal / context.MarketingRule.RuleNumber); manYuanMinus += context.MarketingRule.MarketingAction.Amount * multiple; break; case MeteringMode.QiGouLiang: multiple = (int)(context.ProductCount / context.MarketingRule.RuleNumber); zuHeMinus += context.MarketingRule.MarketingAction.Amount * multiple; break; } totalPreferential += context.MarketingRule.MarketingAction.Amount * multiple; foreach (var record in context.MatchRanges) { //record.Details.SaleStatus = SaleStatus.Promotion; record.Details.CollectionMarketingPrice -= context.MarketingRule.MarketingAction.Amount * multiple * (record.Details.CollectionMarketingPrice / context.ProductTotal); } } else { totalPreferential += context.MarketingRule.MarketingAction.Amount; switch (context.MarketingRule.MeteringMode) { case MeteringMode.ManYuan: manYuanMinus += context.MarketingRule.MarketingAction.Amount; break; case MeteringMode.QiGouLiang: zuHeMinus += context.MarketingRule.MarketingAction.Amount; break; } foreach (var record in context.MatchRanges) { // record.Details.SaleStatus = SaleStatus.Promotion; record.Details.CollectionMarketingPrice -= context.MarketingRule.MarketingAction.Amount * (record.Details.CollectionMarketingPrice / context.ProductTotal); } } break; case MarketingActionMode.Gift: if (context != null && context.MarketingRule != null && context.MarketingRule.MarketingAction != null && context.MarketingRule.MarketingAction.Gifts != null) { if (context.MarketingRule.MarketingAction.Gifts.Count() == 1) { decimal multiple = 1m; if (context.MarketingRule.IsRepeatMarketing) { switch (context.MarketingRule.MeteringMode) { case MeteringMode.ManYuan: multiple = (int)(context.ProductTotal / context.MarketingRule.RuleNumber); break; case MeteringMode.QiGouLiang: multiple = (int)(context.ProductCount / context.MarketingRule.RuleNumber); break; } } var saleStatus = SaleStatus.ActivityGifts; if (context.MarketingRule.MarketingAction.MarketingActionMode == MarketingActionMode.AddMoneyToGive) { saleStatus = SaleStatus.ActivityAddMoneyGifts; } var barcode = shoppingCart.OrderList.FirstOrDefault(o => o.Details.SaleStatus == saleStatus && o.Details.MarketingRuleId == context.MarketingRule.Id); var gift = context.MarketingRule.MarketingAction.Gifts.FirstOrDefault(); var giftNumber = gift.Value * multiple; if (barcode != null) { barcode.Details.IsActivityGiftsTimeOut = false; barcode.EnableMarketing = false; if (barcode.SaleNumber != giftNumber) { barcode.SalePrice = context.MarketingRule.MarketingAction.AddMoney; barcode.MarketingPrice = context.MarketingRule.MarketingAction.AddMoney; barcode.Details.CollectionMarketingPrice = context.MarketingRule.MarketingAction.AddMoney; barcode.SaleNumber = giftNumber; barcode.Details.Total = barcode.MarketingPrice * barcode.SaleNumber;; barcode.MarketingMarks = new List <ActiveMarketingRule>(); barcode.EnableMarketing = false; } } else { barcode = BarcodeFactory.Factory(shoppingCart.MachineInformation.StoreId, shoppingCart.MachineInformation.MachineSn, shoppingCart.MachineInformation.CompanyId, gift.Key, saleStatus, context.MarketingRule.Id); barcode.SaleNumber = giftNumber; barcode.SalePrice = context.MarketingRule.MarketingAction.AddMoney; barcode.Details.IsActivityGiftsTimeOut = false; barcode.MarketingMarks = new List <ActiveMarketingRule>(); barcode.EnableMarketing = false; barcode.MarketingPrice = context.MarketingRule.MarketingAction.AddMoney; barcode.Details.CollectionMarketingPrice = context.MarketingRule.MarketingAction.AddMoney; barcode.Details.Total = barcode.MarketingPrice * barcode.SaleNumber; shoppingCart.OrderList.Insert(shoppingCart.OrderList.Count, barcode); } barcode.EnableMarketing = false; } } break; default: //foreach (var record in context.MatchRanges) //{ // record.Details.SaleStatus = SaleStatus.Promotion; //} break; } result.Add(context); } } } Return: outObj = result; return(totalPreferential); }
public bool LoadConfig(string config) { if (!File.Exists(config)) { return(false); } try { XmlDocument doc = new XmlDocument(); doc.Load(config); XmlNodeList nods = doc.SelectNodes("labels/label"); foreach (XmlNode nod in nods) { if (nod.Attributes["name"] != null) { TPCPrintLabel label = new TPCPrintLabel(); label.Name = nod.Attributes["name"].Value; //读取margin if (nod.Attributes["margin"] != null) { label.MarginWidth = Convert.ToSingle(nod.Attributes["margin"].Value); } //读取线宽 if (nod.Attributes["line-width"] != null) { label.LineWidth = Convert.ToSingle(nod.Attributes["line-width"].Value); } XmlNodeList nodItems = nod.SelectNodes("item"); foreach (XmlNode nodItem in nodItems) { LabelItem item = new LabelItem(); if (nodItem.Attributes["text"] != null) { item.Text = nodItem.Attributes["text"].Value; } if (nodItem.Attributes["state"] != null) { //item.State = (nodItem.Attributes["state"].Value.Equals("fixed")) ? TextState.state_fixed : TextState.state_dynamic; switch (nodItem.Attributes["state"].Value) { case "iconRoHS": item.State = TextState.state_iconRoHS; break; case "iconHF": item.State = TextState.state_iconHF; break; case "fixed": item.State = TextState.state_fixed; break; case "dynamic": default: item.State = TextState.state_dynamic; break; } } if (nodItem.Attributes["image"] != null) { item.IsImage = (nodItem.Attributes["image"].Value.Equals("false")) ? false : true; } if (nodItem.Attributes["offset"] != null) { string[] val = nodItem.Attributes["offset"].Value.Split(','); item.Offset = new PointF(Convert.ToSingle(val[0]), Convert.ToSingle(val[1])); } if (nodItem.Attributes["position"] != null) { string[] val = nodItem.Attributes["position"].Value.Split(','); item.Position = new PointF(Convert.ToSingle(val[0]), Convert.ToSingle(val[1])); } if (nodItem.Attributes["size"] != null) { string[] val = nodItem.Attributes["size"].Value.Split(','); item.Width = Convert.ToSingle(val[0]); item.Height = Convert.ToSingle(val[1]); } if (nodItem.Attributes["border"] != null) { string[] val = nodItem.Attributes["border"].Value.Split('|'); item.Border = BorderStyle.border_none; foreach (string v in val) { if (v.Equals("left")) { item.Border = item.Border | BorderStyle.border_left; } else if (v.Equals("right")) { item.Border = item.Border | BorderStyle.border_right; } else if (v.Equals("top")) { item.Border = item.Border | BorderStyle.border_top; } else if (v.Equals("bottom")) { item.Border = item.Border | BorderStyle.border_bottom; } } } if (item.IsImage) { //读入Code信息 XmlNode nodCode = nodItem.SelectSingleNode("code"); if (nodCode.InnerText.Equals("code39")) { item.Barcode = BarcodeFactory.CreateBarcode(BarcodeType.Code_39); } else if (nodCode.InnerText.Equals("code128")) { item.Barcode = BarcodeFactory.CreateBarcode(BarcodeType.Code_128); } else if (nodCode.InnerText.Equals("codeQR")) { item.Barcode = BarcodeFactory.CreateBarcode(BarcodeType.Code_QR); } else if (nodCode.InnerText.Equals("codeQRMini")) { item.Barcode = BarcodeFactory.CreateBarcode(BarcodeType.Code_QR_Mini); } } else { //读入Font信息 XmlNode nodFont = nodItem.SelectSingleNode("font"); string face = nodFont.Attributes["face"].Value; int size = Convert.ToInt32(nodFont.Attributes["size"].Value); item.TextFont = new Font(face, size, FontStyle.Regular); } //读取条码Size XmlNode nodSize = nodItem.SelectSingleNode("size"); if (nodSize != null) { string[] val = nodSize.InnerText.Split(','); item.BarcodeWidth = Convert.ToSingle(val[0]); item.BarcodeHeight = Convert.ToSingle(val[1]); } label.Items.Add(item); } m_Labels.Add(label.Name, label); } } } catch (Exception e) { return(false); } return(true); }
public async Task <ActionResult> TakeOrder(Models.Front.OrderViewModel model) { if (ModelState.IsValid) { try { var userManager = new UserManager(); string barcode = BarcodeFactory.GetBarcode(); bool isInsurance = !(model.CargoValue == null || model.CargoValue == ""); string senderPostcode = string.Empty; //寄方邮编 string receiverPostcode = string.Empty; //收方邮编 string senderLocation = string.Empty; //寄方地址经纬度 string receiverLocation = string.Empty; //收方地址经纬度 string region = string.Empty; //寄方邮编 string jsonPath = Server.MapPath("~/App_Data/PostCode.json"); string province = model.SLocation.Trim().Split(' ')[0]; string city = model.SLocation.Trim().Split(' ')[1] == "市辖区" ? province : model.SLocation.Trim().Split(' ')[1]; string district = model.SLocation.Trim().Split(' ')[2]; string address = model.SAddress; string key = ConfigurationManager.AppSettings["PostCodeKey"].ToString(); string url = "http://v.juhe.cn/postcode/search"; region = Region.GetRegion(province); if (model.SAddress.Contains("乡") || model.SAddress.Contains("镇")) { string paddress = address.Contains("乡") ? address.Substring(0, address.IndexOf("乡") + 1) : address.Substring(0, address.IndexOf("镇") + 1); senderPostcode = WebRequestService.QueryPostCodeByName(url, key, province, city, district, paddress, jsonPath); } else { senderPostcode = WebRequestService.QueryPostCodeByName(url, key, province, city, district, jsonPath); } //收方邮编 string rprovince = model.RLocation.Trim().Split(' ')[0]; string rcity = model.RLocation.Trim().Split(' ')[1] == "市辖区" ? rprovince : model.RLocation.Trim().Split(' ')[1]; string rdistrict = model.RLocation.Trim().Split(' ')[2]; string raddress = model.RAddress; if (model.RAddress.Contains("乡") || model.RAddress.Contains("镇")) { string paddress = raddress.Contains("乡") ? raddress.Substring(0, raddress.IndexOf("乡") + 1) : raddress.Substring(0, raddress.IndexOf("镇") + 1); receiverPostcode = WebRequestService.QueryPostCodeByName(url, key, rprovince, rcity, rdistrict, paddress, jsonPath); } else { receiverPostcode = WebRequestService.QueryPostCodeByName(url, key, rprovince, rcity, rdistrict, jsonPath); } //寄方地址经纬度 string locationUrl = "https://restapi.amap.com/v3/geocode/geo"; string lkey = ConfigurationManager.AppSettings["GdAppKey"].ToString(); string sk = ConfigurationManager.AppSettings["GdSecretKey"].ToString(); senderLocation = WebRequestService.QueryGDLocationByName(locationUrl, lkey, sk, province + city + district + address, city); //收方地址经纬度 receiverLocation = WebRequestService.QueryGDLocationByName(locationUrl, lkey, sk, rprovince + rcity + rdistrict + raddress, rcity); double freight = MaverickCost.CalcFreight(Convert.ToDouble(model.CargoWeight) * Convert.ToDouble(model.CargoUnit), Convert.ToDouble(model.CargoVolume) * Convert.ToDouble(model.CargoUnit)); double serviceCharge = 0; //得到起始网点 var webLocations = userManager.GetAllWebSiteLocationByType("1", city); string origns = string.Join("|", webLocations.Values); List <string> res = WebRequestService.CalcGroupDistance(origns, senderLocation, lkey, sk); string min = res[1]; int minIndex = 0, flag = 0; Guid webSiteId = new Guid(); for (int i = 1; i < res.Count; i++) { if (int.Parse(res[i]) < int.Parse(min)) { min = res[i]; minIndex = i; } } foreach (var locationkey in webLocations.Keys) { if (minIndex == flag) { webSiteId = locationkey; break; } ++flag; } var orderInfo = new LogisticsSystem.DTO.OrderInfoDto() { SName = model.SenderName, SMobliePhone = model.SMobliePhone.Trim(), SProvince = province + city + district, SAddress = model.SAddress.Trim(), SPostCode = senderPostcode, STelPhone = string.IsNullOrEmpty(model.STelPhone) ? "NULL" : model.STelPhone.Trim(), SFirmName = string.IsNullOrEmpty(model.SCompany) ? "NULL" : model.SCompany.Trim(), SLocation = senderLocation, RName = model.ReceiverName.Trim(), RMobliePhone = model.RMobliePhone.Trim(), RProvince = rprovince + rcity + rdistrict, RAddress = raddress, RPostCode = receiverPostcode, RTelPhone = string.IsNullOrEmpty(model.RTelPhone) ? "NULL" : model.RTelPhone.Trim(), RFirmName = string.IsNullOrEmpty(model.RCompany) ? "NULL" : model.RCompany.Trim(), RLocation = receiverLocation, BarCode = barcode, Region = region, Freight = freight, IsInsured = isInsurance, CargoName = model.CargoName.Trim(), CargoWeight = model.CargoWeight.Trim(), CargoVolume = model.CargoVolume.Trim(), UitNum = model.CargoUnit.Trim(), PayType = model.PayType.Trim() == "1", Mark = string.IsNullOrEmpty(model.Mark) ? "NULL" : model.Mark.Trim().Replace(' ', ','), TakeTime = model.TakeTime.Trim(), Risk = string.IsNullOrEmpty(model.Risk) ? "NULL" : model.Risk.Trim(), CargoValue = string.IsNullOrEmpty(model.CargoValue) ? "NULL" : model.CargoValue.Trim(), ServiceCharge = serviceCharge, StartWebsiteId = webSiteId }; await userManager.CreateOrder(orderInfo); } catch (Exception error) { return(Content("<script>alert('" + error.Message + "');history.go(-1);</script>")); } } else { return(Content("<script>alert('数据丢失了!');history.go(-1);</script>")); } return(Content("<script>alert('下单成功,感谢对本公司的信任!');window.location.href='/User/MainPage';</script>")); }