| | |
| | | //WorkBookTypeBLL _WorkBookTypeBLL = new WorkBookTypeBLL(); |
| | | CoreCmsPlanOrderItemBLL _coreCmsPlanOrderItemBLL = new CoreCmsPlanOrderItemBLL(); |
| | | EC_OrderPrintParameterBLL _OrderPrintParameterBLL = new EC_OrderPrintParameterBLL(); |
| | | OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL(); |
| | | public string orderkeyid = ""; |
| | | |
| | | protected void Page_Load(object sender, EventArgs e) |
| | |
| | | //{ |
| | | // quxian = this.selectCounty.SelectedItem.Text; |
| | | //} |
| | | this.RepSubjeSetctList.DataSource = _PlanOrderBLL.SelectModelPage(pa, HideKeyid.Value, selstatus.Value, sheng, shi |
| | | this.RepSubjeSetctList.DataSource = _PlanOrderBLL.SelectModelPage(pa, HideKeyid.Value, "", sheng, shi |
| | | , quxian, txtpianqu.Value ,txtshipAddress.Value,txtshipName.Value,txtshipMobile.Value,txtshouhuoAddress.Value,"",""); |
| | | |
| | | this.RepSubjeSetctList.DataBind(); |
| | |
| | | return; |
| | | } |
| | | var lie = new List<JiHuaOrder>(); |
| | | var jiHuaOrderDetails = new List<JiHuaOrderDetail>(); |
| | | using (var fileStream = file.InputStream) |
| | | { |
| | | // 使用HSSFWorkbook打开.xls格式的文件 |
| | |
| | | // 获取第一个工作表 |
| | | ISheet sheet = workbook.GetSheetAt(0); |
| | | |
| | | // 迭代工作表中的所有行 |
| | | for (int i = 1; i <= sheet.LastRowNum; i++) |
| | | |
| | | //获取表头作业本名称 |
| | | for (int i = 0; i < 1; i++) |
| | | { |
| | | IRow row = sheet.GetRow(i); |
| | | int j = 5; |
| | | while (true) |
| | | { |
| | | var jiHuaOrderDetail = new JiHuaOrderDetail(); |
| | | |
| | | ICell cell1 = row.GetCell(j); |
| | | if (cell1 == null) |
| | | { |
| | | break; |
| | | } |
| | | jiHuaOrderDetail.name = getcellvalue(cell1); |
| | | if (string.IsNullOrEmpty(jiHuaOrderDetail.name)) |
| | | { |
| | | break; |
| | | } |
| | | j += 1; |
| | | jiHuaOrderDetails.Add(jiHuaOrderDetail); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // 迭代工作表中的所有行 |
| | | for (int i = 1; i <= sheet.LastRowNum; i++) |
| | | { |
| | | var hang = new JiHuaOrder(); |
| | | var jiHuaOrderDetails1 = new List<JiHuaOrderDetail>(); |
| | | |
| | | |
| | | IRow row = sheet.GetRow(i); |
| | | if (row == null) continue; // 跳过空行 |
| | | |
| | |
| | | ICell cell0 = row.GetCell(0); |
| | | if (cell0 == null) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "市不能为空", this); |
| | | JavaScript.MessageBox("第" + (i + 1) + "片区不能为空", this); |
| | | return; |
| | | } |
| | | hang.shi = getcellvalue(cell0); |
| | | hang.pianqu = getcellvalue(cell0); |
| | | |
| | | ICell cell1 = row.GetCell(1); |
| | | if (cell1 == null) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "区县不能为空", this); |
| | | JavaScript.MessageBox("第" + (i + 1) + "学校不能为空", this); |
| | | return; |
| | | } |
| | | hang.quxian = getcellvalue(cell1); |
| | | hang.shipAddress = getcellvalue(cell1); |
| | | |
| | | ICell cell2 = row.GetCell(2); |
| | | if (cell2 == null) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "片区不能为空", this); |
| | | JavaScript.MessageBox("第" + (i + 1) + "联系人不能为空", this); |
| | | return; |
| | | } |
| | | hang.pianqu = getcellvalue(cell2); |
| | | hang.shipName = getcellvalue(cell2); |
| | | |
| | | ICell cell3 = row.GetCell(3); |
| | | if (cell3 == null) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "学校不能为空", this); |
| | | JavaScript.MessageBox("第" + (i + 1) + "联系电话不能为空", this); |
| | | return; |
| | | } |
| | | hang.shipAddress = getcellvalue(cell3); |
| | | hang.shipMobile = getcellvalue(cell3); |
| | | |
| | | ICell cell4 = row.GetCell(4); |
| | | if (cell4 == null) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "联系人不能为空", this); |
| | | return; |
| | | } |
| | | hang.shipName = getcellvalue(cell4); |
| | | |
| | | ICell cell5 = row.GetCell(5); |
| | | if (cell5 == null) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "联系电话不能为空", this); |
| | | return; |
| | | } |
| | | hang.shipMobile = getcellvalue(cell5); |
| | | |
| | | ICell cell6 = row.GetCell(6); |
| | | if (cell6 == null) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "收货地址不能为空", this); |
| | | return; |
| | | } |
| | | hang.shouhuoAddress = getcellvalue(cell6); |
| | | hang.shouhuoAddress = getcellvalue(cell4); |
| | | |
| | | ICell cell7 = row.GetCell(7); |
| | | if (cell7 == null) |
| | | |
| | | |
| | | for(int j=0; j< jiHuaOrderDetails.Count; j++) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "商品名称不能为空", this); |
| | | return ; |
| | | } |
| | | hang.name = getcellvalue(cell7); |
| | | |
| | | var jiHuaOrderDetail = new JiHuaOrderDetail(); |
| | | |
| | | ICell cell8 = row.GetCell(8); |
| | | if (cell8 == null) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "规格不能为空", this); |
| | | return ; |
| | | } |
| | | hang.specification = getcellvalue(cell8); |
| | | |
| | | jiHuaOrderDetail.name = jiHuaOrderDetails[j].name; |
| | | |
| | | //ICell cell9 = row.GetCell(9); |
| | | //if (cell9 == null) |
| | | ICell cell9 = row.GetCell(j+5); |
| | | if (cell9 == null) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "数量不能为空", this); |
| | | return; |
| | | } |
| | | int aaa = 0; |
| | | int.TryParse(getcellvalue(cell9), out aaa); |
| | | jiHuaOrderDetail.nums = aaa; |
| | | |
| | | jiHuaOrderDetails1.Add(jiHuaOrderDetail); |
| | | } |
| | | |
| | | |
| | | |
| | | //ICell cell7 = row.GetCell(7); |
| | | //if (cell7 == null) |
| | | //{ |
| | | // JavaScript.MessageBox("第" + (i + 1) + "单价(元)不能为空", this); |
| | | // JavaScript.MessageBox("第" + (i + 1) + "商品名称不能为空", this); |
| | | // return ; |
| | | //} |
| | | //hang.price = decimal.Parse(getcellvalue(cell9)); |
| | | //hang.name = getcellvalue(cell7); |
| | | |
| | | |
| | | ICell cell9 = row.GetCell(9); |
| | | if (cell9 == null) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "数量不能为空", this); |
| | | return ; |
| | | } |
| | | int aaa = 0; |
| | | int.TryParse(getcellvalue(cell9), out aaa); |
| | | hang.nums = aaa; |
| | | //ICell cell8 = row.GetCell(8); |
| | | //if (cell8 == null) |
| | | //{ |
| | | // JavaScript.MessageBox("第" + (i + 1) + "规格不能为空", this); |
| | | // return ; |
| | | //} |
| | | //hang.specification = getcellvalue(cell8); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | hang.jiHuaOrderDetails = jiHuaOrderDetails1; |
| | | |
| | | lie.Add(hang); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | if (lie != null && lie.Count > 0) |
| | | { |
| | | if (string.IsNullOrEmpty(lie[0].shi)) |
| | | { |
| | | JavaScript.MessageBox("第" + 1 + "市不能为空", this); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(lie[0].quxian)) |
| | | { |
| | | JavaScript.MessageBox("第" + 1 + "区县不能为空", this); |
| | | return; |
| | | } |
| | | |
| | | |
| | | for (int i = 0; i < lie.Count; i++) |
| | | { |
| | | if (!string.IsNullOrEmpty(lie[i].shipAddress)) |
| | |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | if (string.IsNullOrEmpty(lie[i].name)) |
| | | |
| | | for(int j = 0;j< lie[i].jiHuaOrderDetails.Count; j++) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "商品名称不能为空", this); |
| | | return; |
| | | if (string.IsNullOrEmpty(lie[i].jiHuaOrderDetails[j].name)) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "商品名称不能为空", this); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(lie[i].specification)) |
| | | { |
| | | JavaScript.MessageBox("第" + (i + 1) + "规格不能为空", this); |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | //if (string.IsNullOrEmpty(lie[i].specification)) |
| | | //{ |
| | | // JavaScript.MessageBox("第" + (i + 1) + "规格不能为空", this); |
| | | // return; |
| | | //} |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | var orderid = HideKeyid.Value; |
| | | var sys_CitySites = bll_Sys_CitySiteBLL.SelectAllModel(null).ToList(); |
| | | var eC_OrderPrintParameter = _OrderPrintParameterBLL.GetModel(orderid.ToInt32().Value); ; |
| | | InquiryCommonModel model = SerializationHelper.DeSerialize(typeof(InquiryCommonModel), eC_OrderPrintParameter.PrintParameter) as InquiryCommonModel; |
| | | |
| | | |
| | | var eC_OrderBasic = _eC_OrderBasicBLL.SelectModelById(orderid.ToInt32().Value); |
| | | var Province = ""; |
| | | var City = ""; |
| | | var County = ""; |
| | | int Provinceid = 0; |
| | | int Cityid = 0; |
| | | int Countyid = 0; |
| | | if (eC_OrderBasic != null) |
| | | { |
| | | |
| | | var customerCommunications = bll_OA_CorporateClientsBLL.GetModel_CustomerCommunications(eC_OrderBasic.BuyerId); |
| | | Province = customerCommunications.Province; |
| | | City = customerCommunications.City; |
| | | County = customerCommunications.County; |
| | | |
| | | var sys_CitySite = bll_Sys_CitySiteBLL.GetModelByName(Province); |
| | | if (sys_CitySite != null) |
| | | { |
| | | Provinceid = sys_CitySite.Keyid; |
| | | var sys_CitySite1 = bll_Sys_CitySiteBLL.SelectAllNextModel(sys_CitySite.Keyid, 0, 2).FirstOrDefault(x => x.Name == City); |
| | | if (sys_CitySite1 != null) |
| | | { |
| | | Cityid = sys_CitySite1.Keyid; |
| | | var sys_CitySite2 = bll_Sys_CitySiteBLL.SelectAllNextModel(sys_CitySite.Keyid, sys_CitySite1.Keyid, 3).FirstOrDefault(x => x.Name == County); |
| | | if (sys_CitySite2 != null) |
| | | { |
| | | Countyid = sys_CitySite2.Keyid; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, |
| | | new TransactionOptions |
| | |
| | | string pianqu = ""; |
| | | if (lie != null && lie.Count > 0) |
| | | { |
| | | var order = new List<JiHuaOrder>(); |
| | | for (int i = 0; i < lie.Count; i++) |
| | | |
| | | for (int j = 0; j < lie.Count; j++) |
| | | { |
| | | if (i == 0) |
| | | var coreCmsPlanOrder = _PlanOrderBLL.GetModelByorderid(HideKeyid.Value.ToInt32().Value).Where(x => x.shipAddress == lie[j].shipAddress && x.shouhuoAddress == lie[j].shouhuoAddress).FirstOrDefault(); |
| | | if (coreCmsPlanOrder == null) |
| | | { |
| | | CoreCmsPlanOrder order = new CoreCmsPlanOrder(); |
| | | order.status = 1; |
| | | order.shipMobile = lie[j].shipMobile; |
| | | order.shipAddress = lie[j].shipAddress; |
| | | order.shipName = lie[j].shipName; |
| | | order.shouhuoAddress = lie[j].shouhuoAddress; |
| | | order.userMobile = lie[j].shipMobile; |
| | | order.createBy = CurrentUser.ShortName; |
| | | order.createTime = DateTime.Now; |
| | | order.upDataBy = CurrentUser.ShortName; |
| | | order.upDataTime = DateTime.Now; |
| | | order.isdelete = false; |
| | | order.orderkeyid = HideKeyid.Value.ToInt32(); |
| | | order.FirmId = CurrentUser.MemberId; |
| | | order.sheng = Province; |
| | | order.shi = City; |
| | | order.quxian = County; |
| | | order.shengId = Provinceid; |
| | | order.shiId = Cityid; |
| | | order.quxianId = Countyid; |
| | | |
| | | order.Add(lie[i]); |
| | | pianqu = lie[i].pianqu; |
| | | |
| | | } |
| | | else |
| | | { |
| | | if (string.IsNullOrEmpty(lie[i].shipAddress)) |
| | | order.pianqu = lie[j].pianqu; |
| | | |
| | | var jiHuaOrders = lie[j].jiHuaOrderDetails; |
| | | decimal orderAmount = 0; |
| | | var cmsPlanOrderItems = new List<CoreCmsPlanOrderItem>(); |
| | | for (int i = 0; i < jiHuaOrders.Count; i++) |
| | | { |
| | | order.Add(lie[i]); |
| | | } |
| | | else |
| | | { |
| | | //保存订单 |
| | | //jm = await _coreCmsPlanOrderServices.ToAddJiHua(order, _user.ID, _user.Name); |
| | | //if (jm.code == 1) |
| | | //{ |
| | | // return jm; |
| | | //} |
| | | string res = saveorder(order,model.InquiryWorkBookList,sys_CitySites); |
| | | if (!string.IsNullOrEmpty(res)) |
| | | var workbook = model.InquiryWorkBookList.FirstOrDefault(x => (x.WorkBookSizeTxt + x.WorkBookNameTxt ) == jiHuaOrders[i].name || (x.WorkBookNameTxt + x.WorkBookSizeTxt ) == jiHuaOrders[i].name); |
| | | if (workbook == null) |
| | | { |
| | | JavaScript.MessageBox(res, this); |
| | | JavaScript.MessageBox(jiHuaOrders[i].name + "没找到单价", this); |
| | | return; |
| | | } |
| | | order = new List<JiHuaOrder>(); |
| | | if (string.IsNullOrEmpty(lie[i].shi)) |
| | | { |
| | | lie[i].shi = lie[0].shi; |
| | | } |
| | | if (string.IsNullOrEmpty(lie[i].quxian)) |
| | | { |
| | | lie[i].quxian = lie[0].quxian; |
| | | } |
| | | if (string.IsNullOrEmpty(lie[i].pianqu)) |
| | | { |
| | | lie[i].pianqu = pianqu; |
| | | } |
| | | else |
| | | { |
| | | pianqu = lie[i].pianqu; |
| | | } |
| | | order.Add(lie[i]); |
| | | var item = new CoreCmsPlanOrderItem(); |
| | | item.orderId = 0; |
| | | item.name = workbook.WorkBookNameTxt; |
| | | item.specification = workbook.WorkBookSizeTxt; |
| | | item.price = workbook.WorkBookPrice.ToDecimal2().Value;//jiHuaOrders[i].price; |
| | | item.fengmian = string.IsNullOrEmpty(workbook.fengmian) ? "" : workbook.fengmian; |
| | | item.neiye = string.IsNullOrEmpty(workbook.neiye) ? "" : workbook.neiye; |
| | | item.nums = jiHuaOrders[i].nums; ; |
| | | item.amount = item.price * (decimal)jiHuaOrders[i].nums; |
| | | item.createBy = CurrentUser.ShortName; |
| | | item.createTime = DateTime.Now; |
| | | item.upDataBy = CurrentUser.ShortName; |
| | | item.upDataTime = DateTime.Now; |
| | | item.isdelete = false; |
| | | item.isOld = true; |
| | | cmsPlanOrderItems.Add(item); |
| | | orderAmount += item.amount; |
| | | } |
| | | |
| | | order.orderAmount = orderAmount; |
| | | order.oldOrderAmount = orderAmount; |
| | | order.keYongAmount = 0; |
| | | order.huaFeiAmount = 0; |
| | | |
| | | |
| | | var id = _PlanOrderBLL.InsertModelIden(order); |
| | | var ssss = false; |
| | | foreach (var cmsPlanOrderItem in cmsPlanOrderItems) |
| | | { |
| | | cmsPlanOrderItem.orderId = id; |
| | | ssss = _PlanOrderBLL.insertModelOrderItem(cmsPlanOrderItem); |
| | | } |
| | | } |
| | | |
| | | if (i == lie.Count - 1) |
| | | { |
| | | //保存订单 |
| | | //jm = await _coreCmsPlanOrderServices.ToAddJiHua(order, _user.ID, _user.Name); |
| | | //if (jm.code == 1) |
| | | //{ |
| | | // return jm; |
| | | //} |
| | | string res = saveorder(order, model.InquiryWorkBookList, sys_CitySites); |
| | | if (!string.IsNullOrEmpty(res)) |
| | | { |
| | | JavaScript.MessageBox(res, this); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |