private void ProcessDetail() { IList <OrderInvoiceDetail> oidEnts = OrderInvoiceDetail.FindAllByProperty("OrderInvoiceId", ent.Id); foreach (OrderInvoiceDetail oidEnt in oidEnts) { oidEnt.DoDelete(); } oidEnts = entStrList.Select(tent => JsonHelper.GetObject <OrderInvoiceDetail>(tent) as OrderInvoiceDetail).ToList(); foreach (OrderInvoiceDetail oidEnt in oidEnts) { oidEnt.OrderInvoiceId = ent.Id; oidEnt.DoCreate(); OrdersPart opEnt = OrdersPart.Find(oidEnt.OrderDetailId); opEnt.BillingCount = (opEnt.BillingCount.HasValue ? opEnt.BillingCount : 0) + oidEnt.InvoiceCount;//顺便更新订单明细的开票数量 opEnt.DoUpdate(); } string[] orderIdArray = orderids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); foreach (string str in orderIdArray)//更新涉及订单的开票状态 { sql = @"select count(Id) from SHHG_AimExamine..OrdersPart where OId='" + str + "' and Count-isnull(ReturnCount,0)<>isnull(BillingCount,0)"; SaleOrder soEnt = SaleOrder.Find(str); if (DataHelper.QueryValue <int>(sql) == 0) { soEnt.InvoiceState = "已全部开发票"; } else { soEnt.InvoiceState = "已部分开发票"; } soEnt.DoUpdate(); } }
private void UpdateSaleOrder()//销售付款创建完毕后 如果该客户有应付款记录 开始执行对应操作 { if (ent.Name == "自动销账") { sql = @"select * from SHHG_AimExamine..SaleOrders where InvoiceType='收据' and CId='" + CId + "' and State is null and (PayState is null or PayState='部分付款') order by CreateTime asc"; IList <EasyDictionary> dics = DataHelper.QueryDictList(sql); decimal payamount = ent.Money.Value; ent.CorrespondInvoice = ""; foreach (EasyDictionary dic in dics) { if (payamount > 0) { SaleOrder oiEnt = SaleOrder.Find(dic.Get <string>("Id")); decimal unpayAmount = oiEnt.TotalMoney.Value - (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) - (oiEnt.DiscountAmount.HasValue ? oiEnt.DiscountAmount.Value : 0) - (oiEnt.ReturnAmount.HasValue ? oiEnt.ReturnAmount.Value : 0); if (payamount >= unpayAmount) { payamount = payamount - unpayAmount; oiEnt.ReceiptAmount = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + unpayAmount; oiEnt.PayState = "已全部付款"; ent.CorrespondInvoice += oiEnt.Number + "_" + unpayAmount + ","; } else { oiEnt.ReceiptAmount = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + payamount; ent.CorrespondInvoice += oiEnt.Number + "_" + payamount + ","; payamount = 0; } oiEnt.DoUpdate(); } } ent.CorrespondState = "已对应"; ent.DoUpdate(); } if (ent.Name == "手动销账") { string[] SaleOrderArray = ent.CorrespondInvoice.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); ent.CorrespondInvoice = ""; foreach (string str in SaleOrderArray) { SaleOrder oiEnt = SaleOrder.FindAllByProperty(SaleOrder.Prop_Number, str).FirstOrDefault <SaleOrder>(); decimal unpayAmount = oiEnt.TotalMoney.Value - (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) - (oiEnt.DiscountAmount.HasValue ? oiEnt.DiscountAmount.Value : 0) - (oiEnt.ReturnAmount.HasValue ? oiEnt.ReturnAmount.Value : 0); ent.CorrespondInvoice += oiEnt.Number + "_" + unpayAmount + ","; oiEnt.ReceiptAmount = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + unpayAmount; oiEnt.PayState = "已全部付款"; oiEnt.DoUpdate(); } ent.CorrespondState = "已对应"; ent.DoUpdate(); } if (ent.Name == "暂不销账") { ent.CorrespondInvoice = ""; ent.DoUpdate(); } }
protected void Page_Load(object sender, EventArgs e) { CC = RequestData.Get <string>("CC"); string ids = RequestData.Get <string>("ids"); switch (RequestActionString) { case "ResetSaleOrderDetail": if (!string.IsNullOrEmpty(ids)) { string[] idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); foreach (string oid in idArray) { IList <OrdersPart> opEnts = OrdersPart.FindAllByProperty(OrdersPart.Prop_OId, oid); foreach (OrdersPart opEnt in opEnts) { opEnt.BillingCount = null; opEnt.DoUpdate(); } soEnt = SaleOrder.Find(oid); soEnt.InvoiceState = null; soEnt.DoUpdate(); } } break; case "SetReceiptModel": if (!string.IsNullOrEmpty(ids)) { string[] idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < idArray.Length; i++) { soEnt = SaleOrder.Find(idArray[i]); soEnt.InvoiceType = "收据"; soEnt.DoUpdate(); } } break; case "DelayInvoice": if (!string.IsNullOrEmpty(ids)) { string[] idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < idArray.Length; i++) { soEnt = SaleOrder.Find(idArray[i]); soEnt.State = "暂缓开票"; soEnt.DoUpdate(); } } break; default: DoSelect(); break; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string saleorderId = RequestData.Get <string>("id"); //基本信息 SaleOrder soEntity = SaleOrder.Find(saleorderId); lbSaleOrderNo.Text = soEntity.Number; lbCustomerName.Text = soEntity.CName; lbInvoiceType.Text = soEntity.InvoiceType; lbTotalMoney.Text = soEntity.TotalMoney.ToString(); lbSalesman.Text = soEntity.Salesman; lbCreateName.Text = soEntity.CreateName; lbPayType.Text = soEntity.PayType; lbDeliveryMode.Text = soEntity.DeliveryMode; lbCreateTime.Text = soEntity.CreateTime.ToString(); lbRemark.Text = soEntity.Remark; lbReturnAmount.Text = soEntity.ReturnAmount + ""; lbDeState.Text = soEntity.DeState; lbInvoiceState.Text = soEntity.InvoiceState + ""; //销售详细信息 sql = @"select *,B.Number from SHHG_AimExamine..OrdersPart as A left join SHHG_AimExamine..SaleOrders as B on A.OId=B.Id where A.OId='" + saleorderId + "'"; rgSaleOrderDetail.DataSource = DataHelper.QueryDataTable(sql); rgSaleOrderDetail.DataBind(); //出库详细 sql = @"select A.*,D.Number from SHHG_AimExamine..DelieryOrderPart as A left join SHHG_AimExamine..DeliveryOrder as D on D.Id=A.DId left join SHHG_AimExamine..OrdersPart as B on A.PId=B.Id left join SHHG_AimExamine..SaleOrders as C on B.OId=C.Id where C.Id='" + saleorderId + "'"; rgDeliveryOrderDetail.DataSource = DataHelper.QueryDataTable(sql); rgDeliveryOrderDetail.DataBind(); sql = @"select A.* from SHHG_AimExamine..PaymentInvoice as A where PATINDEX('%" + soEntity.Number + "%', A.CorrespondInvoice) >0"; rgReceiveMoney.DataSource = DataHelper.QueryDataTable(sql); rgReceiveMoney.DataBind(); //发票明细 sql = @"select * from SHHG_AimExamine..OrderInvoice where OId like '%" + saleorderId + "%'"; rgSaleInvoice.DataSource = DataHelper.QueryDataTable(sql); rgSaleInvoice.DataBind(); //退货明细 sql = @"select A.*,B.Number from SHHG_AimExamine..ReturnOrderPart A left join SHHG_AimExamine..ReturnOrder as B on B.Id=A.ReturnOrderId where B.OrderNumber='" + soEntity.Number + "'"; rgReturnOrder.DataSource = DataHelper.QueryDataTable(sql); rgReturnOrder.DataBind(); //物流信息 string sql5 = @"select * from SHHG_AimExamine..Logistics where DeliveryId in (select Id from SHHG_AimExamine..DeliveryOrder where Pid='" + saleorderId + "')"; rgLogistics.DataSource = DataHelper.QueryDataTable(sql5); rgLogistics.DataBind(); } }
public void StartFlow() { string state = this.RequestData.Get <string>("state"); string id = this.RequestData.Get <string>("Id"); SaleOrder pb = SaleOrder.Find(id); pb.State = state; pb.Save(); string code = this.RequestData.Get <string>("FlowKey"); //启动流程 //表单路径,后面加上参数传入 string formUrl = "/SaleManagement/FrmOrdersView.aspx?op=u&id=" + id; Guid guid = Aim.WorkFlow.WorkFlow.StartWorkFlow(id, formUrl, "销售订单审批(" + pb.Number + ")[" + pb.CreateName + "]", code, this.UserInfo.UserID, this.UserInfo.Name); this.PageState.Add("FlowId", guid.ToString()); }
protected void Page_Load(object sender, EventArgs e) { string action = Request["action"]; string sql = ""; DataTable dt = null; PaymentInvoice piEnt = null; SaleOrder soEnt = null; switch (action) { case "loadpaytype": sql = @"select name from SysEnumeration where parentid=(select TOP 1 EnumerationID from SysEnumeration WHERE Code = 'PayType') order by sortindex asc "; dt = DataHelper.QueryDataTable(sql); Response.Write("{rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}"); Response.End(); break; case "loadbyorderid": soEnt = SaleOrder.Find(Request["orderid"]); Response.Write("{data:" + JsonHelper.GetJsonString(soEnt) + "}"); Response.End(); break; case "create": soEnt = SaleOrder.Find(Request["orderid"]); piEnt = JsonHelper.GetObject <PaymentInvoice>(Request["formdata"]); piEnt.BillType = "订单"; piEnt.CorrespondState = "已对应"; piEnt.CollectionType = "销售收款"; piEnt.Name = "手动销账"; piEnt.CorrespondInvoice = soEnt.Number + "_" + soEnt.TotalMoney; piEnt.DoCreate(); //创建完付款单后,更新订单状态 soEnt.PayState = "已付款"; soEnt.DoUpdate(); break; } }
protected void Page_Load(object sender, EventArgs e) { string db = ConfigurationManager.AppSettings["ExamineDB"]; op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); paid = RequestData.Get <string>("paid"); PAState = RequestData.Get <string>("PAState"); type = RequestData.Get <string>("type"); SaleOrder ent = null; IList <string> strList = RequestData.GetList <string>("data"); switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <SaleOrder>(); if (PAState == "Yes") { ent.PAState = "待审核"; ent.PANumber = DataHelper.QueryValue("select " + db + ".dbo.fun_getPriceAppNumber()") + ""; } else { ent.PAState = ""; ent.PANumber = ""; } ent.DoUpdate(); //处理OrdersPart表 //删除 OrdersPart.DeleteAll("OId='" + ent.Id + "'"); //添加 InsertProPart(ent, strList); //创建价格申请单 if (PAState == "Yes") { CreatePriceApply(ent); } #region 除出库单表并更新销售单状态 if (RequestData.Get <string>("del") == "yes") { DeliveryOrder[] dorders = DeliveryOrder.FindAllByProperty("PId", ent.Id); foreach (DeliveryOrder dorder in dorders) { DelieryOrderPart.DeleteAll("DId='" + dorder.Id + "'"); DeliveryOrder.DeleteAll("Id='" + dorder.Id + "'"); } //更新出库单状态 OrdersPart[] ops = OrdersPart.FindAllByProperty("OId", ent.Id); foreach (OrdersPart opt in ops) { if (opt != null) { opt.OutCount = 0; opt.DoSave(); } } //更新order的json string jsons = ""; ops = OrdersPart.FindAllByProperty("OId", ent.Id); foreach (OrdersPart opt in ops) { jsons += "{"; jsons += "Id:'" + opt.PId + "',"; jsons += "Isbn:'" + opt.Isbn + "',"; jsons += "Code:'" + opt.PCode + "',"; jsons += "Name:'" + opt.PName + "',"; jsons += "Unit:'" + opt.Unit + "',"; jsons += "MinSalePrice:'" + opt.MinSalePrice + "',"; jsons += "Price:'" + opt.SalePrice + "',"; jsons += "Amount:'" + opt.Amount + "',"; jsons += "Count:'" + opt.Count + "',"; jsons += "OutCount:'" + opt.OutCount + "',"; jsons += "Remark:'" + opt.Remark + "'"; jsons += "},"; } string count = DataHelper.QueryValue("select count(1) from " + db + "..OrdersPart where OId='" + ent.Id + "' and OutCount=[Count]") + ""; if (count == "0") { ent.DeliveryState = ""; } else { ent.DeliveryState = "部分生成出库单"; } ent.Child = "[" + jsons.Substring(0, jsons.Length - 1) + "]"; ent.DoUpdate(); } #endregion this.SetMessage("修改成功!"); break; case RequestActionEnum.Insert: case RequestActionEnum.Create: ent = this.GetPostedData <SaleOrder>(); if (PAState == "Yes") { ent.PAState = "待审核"; ent.PANumber = DataHelper.QueryValue("select " + db + ".dbo.fun_getPriceAppNumber()") + ""; } ent.PId = paid; //自动生成流水号 ent.Number = DataHelper.QueryValue("select " + db + ".dbo.fun_getOrderNumber()") + ""; ent.DoCreate(); //处理OrdersPart表 //添加 InsertProPart(ent, strList); //创建价格申请单 if (PAState == "Yes") { CreatePriceApply(ent); } this.SetMessage("新建成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SaleOrder>(); ent.DoDelete(); this.SetMessage("删除成功!"); return; default: if (RequestActionString == "submitfinish") { SaleOrder pc = SaleOrder.Find(this.RequestData.Get <string>("id")); pc.State = "End"; pc.DeliveryState = "已生成出库单"; pc.ApprovalState = this.RequestData.Get <string>("ApprovalState"); pc.Save(); //自动生成发货单 if (pc.ApprovalState == "同意") { DeliveryOrder dor = new DeliveryOrder { Child = pc.Child, CId = pc.Id, WarehouseId = pc.WarehouseId, WarehouseName = pc.WarehouseName, CName = pc.CName, CreateId = UserInfo.UserID, CreateName = UserInfo.Name, CreateTime = DateTime.Now, ExpectedTime = pc.ExpectedTime, Number = DateTime.Now.ToString("yyyyMMddHHmmss") }; dor.DoCreate(); } } else if (RequestActionString == "inputexcel") { string path = @"D:\RW\Files\AppFiles\Portal\Default\" + RequestData.Get <string>("path"); string strcn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';"; //连接字符串 #region 遍历整个excel //DataSet ds = GetDataFromExcel(path); ////遍历DataSet取数据 ////清除无效行 //ds.Tables[0].Rows.RemoveAt(0); //ds.Tables[0].Rows.RemoveAt(0); //ds.Tables[0].Rows.RemoveAt(0); //PageState.Add("error", "Tables:" + ds.Tables.Count + " Table[0]:" + ds.Tables[0].Select("F4 <> ''").Length + "数量" + ds.Tables[0].Rows[0][3]); //return; #endregion #region old try { string sql = "select * from [Sheet1$]"; OleDbDataAdapter oldr = new OleDbDataAdapter(sql, strcn); //读取数据,并填充到DATASET里 DataTable dt = new DataTable(); oldr.Fill(dt); if (dt.Rows.Count > 0) { string strjson = RequestData.Get <string>("json").Replace("[]", ""); if (strjson.Length > 0) { strjson = strjson.Substring(1, strjson.Length - 2) + ","; } DataRow row = null; for (int i = 0; i < dt.Rows.Count; i++) { row = dt.Rows[i]; strjson += "{"; strjson += "Id:'" + row["Id"] + "',"; strjson += "Isbn:'" + row["Isbn"] + "',"; strjson += "Code:'" + row["Code"] + "',"; strjson += "Name:'" + row["Name"] + "',"; strjson += "Unit:'" + row["Unit"] + "',"; strjson += "MinSalePrice:'" + row["MinSalePrice"] + "',"; strjson += "Price:'" + row["MinSalePrice"] + "',"; strjson += "Amount:'" + row["Amount"] + "',"; strjson += "Count:'" + row["Count"] + "',"; strjson += "Remark:'" + row["Remark"] + "'"; strjson += "},"; } if (strjson != "") { strjson = "[" + strjson.Substring(0, strjson.Length - 1) + "]"; PageState.Add("result", strjson); } } return; } catch (Exception ex) { PageState.Add("error", ex.Message); return; } #endregion } else if (RequestActionString == "updateAmount") { SaleOrder o = SaleOrder.TryFind(id); string TotalMoney = RequestData.Get <string>("TotalMoney"); o.DiscountAmount = RequestData.Get <decimal>("DiscountAmount"); o.TotalMoney = Convert.ToDecimal(TotalMoney); o.DoUpdate(); } break; } if (RequestActionString == "getSalesman") { string cid = RequestData.Get <string>("CId"); Customer customer = Customer.Find(cid); if (customer != null) { PageState.Add("Code", customer.Code); PageState.Add("SaleUser", customer.MagUser); PageState.Add("SaleUserId", customer.MagId); } } else if (op == "c" && !string.IsNullOrEmpty(paid)) { if (!string.IsNullOrEmpty(paid)) { PriceApply paent = PriceApply.TryFind(paid); if (paent != null) { paent.Reason = ""; paent.ApprovalState = ""; paent.ExpectedTime = null; paent.Id = ""; paent.Number = ""; paent.Remark = ""; paent.State = ""; this.SetFormData(paent); } } } else if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { ent = SaleOrder.Find(id); } this.SetFormData(ent); this.PageState.Add("State", ent.State); //查询子商品 string sql = "select Id, PId, PCode as Code, PName as Name, Isbn, Count, Unit, MinSalePrice, SalePrice as Price, Amount,CustomerOrderNo, Remark, OutCount,BillingCount from " + db + "..OrdersPart where OId='" + id + "'"; PageState.Add("DetailList", DataHelper.QueryDictList(sql)); } this.PageState.Add("FlowEnum", SysEnumeration.GetEnumDictList("WorkFlow.Simple")); PageState.Add("InvoiceType", SysEnumeration.GetEnumDict("InvoiceType")); PageState.Add("DeliveryMode", SysEnumeration.GetEnumDict("DeliveryMode")); PageState.Add("PayType", SysEnumeration.GetEnumDict("PayType")); PageState.Add("CalculateManner", SysEnumeration.GetEnumDict("CalculateManner")); }
protected void Page_Load(object sender, EventArgs e) { string db = ConfigurationManager.AppSettings["ExamineDB"]; op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); paid = RequestData.Get <string>("paid"); PAState = RequestData.Get <string>("PAState"); type = RequestData.Get <string>("type"); SaleOrder ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <SaleOrder>(); if (PAState == "Yes") { ent.PAState = "待审核"; ent.PANumber = "HGPA" + DateTime.Now.ToString("yyyyMMddHHmmss"); } ent.DoUpdate(); //处理OrdersPart表 //删除 OrdersPart.DeleteAll("OId='" + ent.Id + "'"); //添加 strjosn = ent.Child.Substring(1, ent.Child.Length - 2); objarr = strjosn.Replace("},{", "#").Split('#'); InsertProPart(ent); //创建价格申请单 if (PAState == "Yes") { CreatePriceApply(ent); } this.SetMessage("修改成功!"); break; case RequestActionEnum.Insert: case RequestActionEnum.Create: ent = this.GetPostedData <SaleOrder>(); if (PAState == "Yes") { ent.PAState = "待审核"; ent.PANumber = DataHelper.QueryValue("select " + db + ".dbo.fun_getPriceAppNumber()") + ""; } ent.PId = paid; //自动生成流水号 ent.Number = DataHelper.QueryValue("select " + db + ".dbo.fun_getOrderNumber()") + ""; ent.DoCreate(); //处理OrdersPart表 //添加 strjosn = ent.Child.Substring(1, ent.Child.Length - 2); objarr = strjosn.Replace("},{", "#").Split('#'); InsertProPart(ent); //创建价格申请单 if (PAState == "Yes") { CreatePriceApply(ent); } this.SetMessage("新建成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SaleOrder>(); ent.DoDelete(); this.SetMessage("删除成功!"); return; default: if (RequestActionString == "submitfinish") { SaleOrder pc = SaleOrder.Find(this.RequestData.Get <string>("id")); pc.State = "End"; pc.DeliveryState = "已生成出库单"; pc.ApprovalState = this.RequestData.Get <string>("ApprovalState"); pc.Save(); //自动生成发货单 if (pc.ApprovalState == "同意") { DeliveryOrder dor = new DeliveryOrder { Child = pc.Child, CId = pc.Id, WarehouseId = pc.WarehouseId, WarehouseName = pc.WarehouseName, CName = pc.CName, CreateId = UserInfo.UserID, CreateName = UserInfo.Name, CreateTime = DateTime.Now, ExpectedTime = pc.ExpectedTime, Number = DateTime.Now.ToString("yyyyMMddHHmmss") }; dor.DoCreate(); } } else if (RequestActionString == "inputexcel") { string path = @"D:\RW\Files\AppFiles\Portal\Default\" + RequestData.Get <string>("path"); string strcn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';"; //连接字符串 #region 遍历整个excel //DataSet ds = GetDataFromExcel(path); ////遍历DataSet取数据 ////清除无效行 //ds.Tables[0].Rows.RemoveAt(0); //ds.Tables[0].Rows.RemoveAt(0); //ds.Tables[0].Rows.RemoveAt(0); //PageState.Add("error", "Tables:" + ds.Tables.Count + " Table[0]:" + ds.Tables[0].Select("F4 <> ''").Length + "数量" + ds.Tables[0].Rows[0][3]); //return; #endregion #region old try { string sql = "select * from [Sheet1$]"; OleDbDataAdapter oldr = new OleDbDataAdapter(sql, strcn); //读取数据,并填充到DATASET里 DataTable dt = new DataTable(); oldr.Fill(dt); if (dt.Rows.Count > 0) { string strjson = RequestData.Get <string>("json").Replace("[]", ""); if (strjson.Length > 0) { strjson = strjson.Substring(1, strjson.Length - 2) + ","; } DataRow row = null; for (int i = 0; i < dt.Rows.Count; i++) { row = dt.Rows[i]; strjson += "{"; strjson += "Id:'" + row["Id"] + "',"; strjson += "Isbn:'" + row["Isbn"] + "',"; strjson += "Code:'" + row["Code"] + "',"; strjson += "Name:'" + row["Name"] + "',"; strjson += "Unit:'" + row["Unit"] + "',"; strjson += "MinSalePrice:'" + row["MinSalePrice"] + "',"; strjson += "Price:'" + row["MinSalePrice"] + "',"; strjson += "Amount:'" + row["Amount"] + "',"; strjson += "Count:'" + row["Count"] + "',"; strjson += "Remark:'" + row["Remark"] + "'"; strjson += "},"; } if (strjson != "") { strjson = "[" + strjson.Substring(0, strjson.Length - 1) + "]"; PageState.Add("result", strjson); } } return; } catch (Exception ex) { PageState.Add("error", ex.Message); return; } #endregion } break; } if (RequestActionString == "getSalesman") { string cid = RequestData.Get <string>("CId"); Customer customer = Customer.Find(cid); if (customer != null) { PageState.Add("Code", customer.Code); } } else if (op == "c" && !string.IsNullOrEmpty(paid)) { if (!string.IsNullOrEmpty(paid)) { PriceApply paent = PriceApply.TryFind(paid); if (paent != null) { paent.Reason = ""; paent.ApprovalState = ""; paent.ExpectedTime = null; paent.Id = ""; paent.Number = ""; paent.Remark = ""; paent.State = ""; this.SetFormData(paent); } } } else if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { ent = SaleOrder.Find(id); } this.SetFormData(ent); this.PageState.Add("State", ent.State); } this.PageState.Add("FlowEnum", SysEnumeration.GetEnumDictList("WorkFlow.Simple")); PageState.Add("InvoiceType", SysEnumeration.GetEnumDict("InvoiceType")); PageState.Add("DeliveryMode", SysEnumeration.GetEnumDict("DeliveryMode")); PageState.Add("PayType", SysEnumeration.GetEnumDict("PayType")); PageState.Add("CalculateManner", SysEnumeration.GetEnumDict("CalculateManner")); }
protected void Page_Load(object sender, EventArgs e) { string ids = RequestData.Get <string>("ids"); string[] idArray = null; if (!string.IsNullOrEmpty(ids)) { idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } id = RequestData.Get <string>("id"); if (!string.IsNullOrEmpty(id)) { piEnt = PaymentInvoice.Find(id); } switch (RequestActionString) { case "CancelCorrespond": foreach (string str in idArray) //可以同时对多个付款进行撤销对应 { piEnt = PaymentInvoice.Find(str); string[] invoiceArray = piEnt.CorrespondInvoice.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < invoiceArray.Length; i++) { int index = invoiceArray[i].IndexOf("_"); string number = invoiceArray[i].Substring(0, index); //找到对应的发票号和销账金额 对发票进行回滚 decimal amount = Convert.ToDecimal(invoiceArray[i].Substring(index + 1)); SaleOrder oiEnt = SaleOrder.FindAllByProperty(SaleOrder.Prop_Number, number).FirstOrDefault <SaleOrder>(); oiEnt.ReceiptAmount = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) - amount; oiEnt.PayState = oiEnt.ReceiptAmount > 0 ? "部分付款" : null; oiEnt.DoUpdate(); } piEnt.CorrespondInvoice = ""; piEnt.CorrespondState = ""; piEnt.Name = "暂不销账"; piEnt.DoUpdate(); } break; case "AutoCorrespond": sql = @"select sum(TotalMoney-isnull(DiscountAmount,0)-isnull(ReturnAmount,0)-isnull(ReceiptAmount,0)) from SHHG_AimExamine..SaleOrders where CId='" + piEnt.CId + "' and State is null and InvoiceType='收据' and (PayState is null or PayState='部分付款')"; decimal TotalArrearage = DataHelper.QueryValue <decimal>(sql); if (TotalArrearage >= piEnt.Money) { sql = @"select * from SHHG_AimExamine..SaleOrders where InvoiceType='收据' and CId='" + piEnt.CId + "' and State is null and (PayState is null or PayState='部分付款') order by CreateTime asc"; IList <EasyDictionary> dics = DataHelper.QueryDictList(sql); decimal payamount = piEnt.Money.Value; piEnt.CorrespondInvoice = ""; foreach (EasyDictionary dic in dics) { if (payamount > 0) { SaleOrder oiEnt = SaleOrder.Find(dic.Get <string>("Id")); decimal unpayAmount = oiEnt.TotalMoney.Value - (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) - (oiEnt.DiscountAmount.HasValue ? oiEnt.DiscountAmount.Value : 0) - (oiEnt.ReturnAmount.HasValue ? oiEnt.ReturnAmount.Value : 0); if (payamount >= unpayAmount) { payamount = payamount - unpayAmount; oiEnt.ReceiptAmount = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + unpayAmount; oiEnt.PayState = "已全部付款"; piEnt.CorrespondInvoice += oiEnt.Number + "_" + unpayAmount + ","; } else { oiEnt.ReceiptAmount = (oiEnt.ReceiptAmount.HasValue ? oiEnt.ReceiptAmount.Value : 0) + payamount; piEnt.CorrespondInvoice += oiEnt.Number + "_" + payamount + ","; payamount = 0; } oiEnt.DoUpdate(); } } piEnt.CorrespondState = "已对应"; piEnt.Name = "自动销账"; piEnt.DoUpdate(); PageState.Add("Result", "T"); } else { PageState.Add("Result", "F"); } break; case "delete": foreach (string str in idArray) { piEnt = PaymentInvoice.Find(str); piEnt.DoDelete(); } break; default: DoSelect(); break; } }
protected void Page_Load(object sender, EventArgs e) { Index = RequestData.Get <string>("Index"); CC = RequestData.Get <string>("CC"); string ids = RequestData.Get <string>("ids"); switch (RequestActionString) { case "delete": if (!string.IsNullOrEmpty(ids)) { string[] idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < idArray.Length; i++) { oiEnt = OrderInvoice.Find(idArray[i]); IList <OrderInvoiceDetail> oidEnts = OrderInvoiceDetail.FindAllByProperty("OrderInvoiceId", oiEnt.Id); foreach (OrderInvoiceDetail oidEnt in oidEnts) { OrdersPart opEnt = OrdersPart.Find(oidEnt.OrderDetailId); opEnt.BillingCount = opEnt.BillingCount - oidEnt.InvoiceCount; opEnt.DoUpdate(); oidEnt.DoDelete(); } //删除发票的时候 回滚销售订单的发票状态 soEnt.InvoiceState = ""; string[] oidArray = oiEnt.OId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); foreach (string oid in oidArray) { SaleOrder soEnt = SaleOrder.Find(oid); sql = "select count(Id) from SHHG_AimExamine..OrdersPart where BillingCount>0 and OId='" + oid + "'"; if (DataHelper.QueryValue <int>(sql) == 0) { soEnt.InvoiceState = ""; } else { soEnt.InvoiceState = "已部分开发票"; } soEnt.DoUpdate(); } oiEnt.DoDelete(); } } break; case "RollBack": if (!string.IsNullOrEmpty(ids)) { string[] idArray = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < idArray.Length; i++) { oiEnt = OrderInvoice.Find(idArray[i]); oiEnt.PayState = null; oiEnt.PayAmount = null; oiEnt.DoUpdate(); } } break; case "updateorderinvoicedetail": IList <OrderInvoice> oiEnts = OrderInvoice.FindAll(); foreach (OrderInvoice oiEnt in oiEnts) { IList <OrderInvoiceDetail> oidEnts = OrderInvoiceDetail.FindAllByProperty(OrderInvoiceDetail.Prop_OrderInvoiceId, oiEnt.Id); if (oidEnts.Count == 0) { JArray ja = JsonHelper.GetObject <JArray>(oiEnt.Child); foreach (JObject jo in ja) { OrderInvoiceDetail oidEnt = new OrderInvoiceDetail(); oidEnt.OrderDetailId = jo.Value <string>("Id"); oidEnt.OrderInvoiceId = oiEnt.Id; oidEnt.SaleOrderId = jo.Value <string>("OId"); oidEnt.ProductId = jo.Value <string>("ProductId"); oidEnt.ProductCode = jo.Value <string>("ProductCode"); oidEnt.ProductName = jo.Value <string>("ProductName"); oidEnt.SalePrice = jo.Value <decimal>("SalePrice"); oidEnt.Unit = jo.Value <string>("Unit"); oidEnt.Amount = jo.Value <decimal>("Amount"); oidEnt.Count = jo.Value <Int32>("Count"); oidEnt.InvoiceCount = jo.Value <Int32>("Count"); oidEnt.DoCreate(); } } } break; default: DoSelect(); break; } }