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) { op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); if (!string.IsNullOrEmpty(id)) { ent = ReturnOrder.Find(id); } switch (RequestActionString) { case "update": ent = GetMergedData <ReturnOrder>(); ent.DoUpdate(); break; case "create": ent = this.GetPostedData <ReturnOrder>(); ent.Number = DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getReturnOrderNumber()") + ""; //自动生成流水号 ent.State = "已生成"; ent.DoCreate(); soent = SaleOrder.FindAllByProperty("Number", ent.OrderNumber).FirstOrDefault <SaleOrder>(); soent.ReturnAmount = (soent.ReturnAmount.HasValue ? soent.ReturnAmount.Value : 0) + ent.ReturnMoney; soent.DoUpdate(); //将退货金额反写到销售单 if (soent.InvoiceState == "已全部开发票") { ent.IsDiscount = "T"; ent.DoUpdate(); } InWarehouse inwh = new InWarehouse { PublicInterface = ent.Id, //退货单Id InWarehouseNo = DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getInWarehouseNo()").ToString(), InWarehouseType = "退货入库", WarehouseId = ent.WarehouseId, WarehouseName = ent.WarehouseName, State = "未入库" }; inwh.DoCreate(); ProcessDetail(inwh); break; case "GetSaleOrderPart": string orderNumber = RequestData.Get <string>("OrderNumber"); soent = SaleOrder.FindAllByProperty("Number", orderNumber).FirstOrDefault <SaleOrder>(); PageState.Add("Result", OrdersPart.FindAllByProperty(OrdersPart.Prop_OId, soent.Id)); break; default: DoSelect(); break; } }
/// <summary> /// 更新出库状态 /// </summary> /// <param name="childjson">出库单出库商品json</param> private void GetDeliveryState(IList <string> strList, string paids) { string db = ConfigurationManager.AppSettings["ExamineDB"]; Dictionary <string, object> dic = null; OrdersPart op = null; for (int i = 0; i < strList.Count; i++) { dic = FromJson(strList[i]) as Dictionary <string, object>; if (dic != null) { op = OrdersPart.TryFind(dic["PId"]); if (op != null) { op.OutCount = (op.OutCount == null ? 0 : Convert.ToInt32(op.OutCount)) + Convert.ToInt32(dic["OutCount"]); op.DoSave(); } else { //throw new Exception("PId未在OrdersPart的Id中"); } } } //更新销售单状态 string[] oids = paids.Split(','); SaleOrder order = null; string count = "0";//待出库数量 string state = ""; OrdersPart[] ops = null; string jsons = ""; foreach (string str in oids) { if (string.IsNullOrEmpty(str)) { continue; } count = DataHelper.QueryValue("select count(1) from " + db + "..OrdersPart where OId='" + str + "' and (OutCount is null or OutCount<>[Count])") + ""; if (count == "0") { //已出库state //state = "已出库"; state = "已全部生成出库单"; } else { //state = "部分出库"; state = "部分生成出库单"; } order = SaleOrder.TryFind(str); if (order != null) { jsons = ""; order.DeliveryState = state; //更新order的json ops = OrdersPart.FindAllByProperty("OId", str); //拼json 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 += "},"; } order.Child = "[" + jsons.Substring(0, jsons.Length - 1) + "]"; order.DoSave(); } } }
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")); }
private void DoBatchDelete() { IList <object> idList = RequestData.GetList <object>("IdList"); string db = ConfigurationManager.AppSettings["ExamineDB"]; if (idList != null && idList.Count > 0) { OrdersPart op = null; OrdersPart[] ops = null; DelieryOrderPart[] dops = null; DeliveryOrder dorder = null; SaleOrder order = null; string count = ""; //更新订单状态,同时删除DeliveryOrderPart表数据 foreach (object obj in idList) { dorder = DeliveryOrder.TryFind(obj); if (dorder == null) { DelieryOrderPart.DeleteAll("DId='" + obj + "'"); //删除DeliveryOrderPart continue; } dops = DelieryOrderPart.FindAllByProperty("DId", obj); foreach (DelieryOrderPart dop in dops) { //更新订单状态 op = OrdersPart.TryFind(dop.PId); if (op != null) { op.OutCount = (op.OutCount == null ? 0 : Convert.ToInt32(op.OutCount)) - Convert.ToInt32(dop.Count); op.DoSave(); } } //更新order的json string jsons = ""; order = SaleOrder.FindAllByProperty("Id", dorder.PId).FirstOrDefault <SaleOrder>(); if (order == null) { DelieryOrderPart.DeleteAll("DId='" + obj + "'"); //删除DeliveryOrderPart continue; } ops = OrdersPart.FindAllByProperty("OId", order.Id); //拼json 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 += "},"; } count = DataHelper.QueryValue("select count(1) from " + db + "..OrdersPart where OId='" + order.Id + "' and OutCount=[Count]") + ""; if (count == "0") { order.DeliveryState = ""; } else { order.DeliveryState = "部分生成出库单"; } order.Child = "[" + jsons.Substring(0, jsons.Length - 1) + "]"; order.DoSave(); DelieryOrderPart.DeleteAll("DId='" + obj + "'"); //删除DeliveryOrderPart } DeliveryOrder.DoBatchDelete(idList.ToArray()); } }
/// <summary> /// 获取销售单开发票状态,并修改销售详细开票数量 /// </summary> /// <param name="json">开票明细json</param> /// <param name="oid">销售单Id</param> /// <returns></returns> private string getInvoiceState(IList <string> strList, string oid, string onumber) { OrdersPart[] ops1 = OrdersPart.FindAllByProperty("OId", oid);//查出来的 Dictionary <string, object> dic = null; //dtall 所有需要开发票的 dttemp 当前订单该开票的商品 //DataTable dttemp = null; //DataRow[] rows = dtall.Select("OId='" + oid + "'"); //dttemp = dtall.Clone(); //foreach (DataRow row in rows) //{ // dttemp.Rows.Add(row.ItemArray); //} for (int i = 0; i < strList.Count; i++) { dic = FromJson(strList[i]) as Dictionary <string, object>; if (dic["Type"] + "" == "销售") { foreach (OrdersPart op1 in ops1) { if (op1.Id == dic["Id"] + "") { if (op1.BillingCount == null) { op1.BillingCount = Convert.ToInt32(dic["BcCount"]); } else { op1.BillingCount += Convert.ToInt32(dic["BcCount"]); } op1.DoUpdate(); break; } } } else if (dic["Type"] + "" == "退货") { //估计用不到 } else if (dic["Type"] + "" == "换货") { ChangeOrderPart[] chanparts = ChangeOrderPart.FindAllByProperty("OId", oid); foreach (ChangeOrderPart chanpart in chanparts) { if (chanpart.Id == dic["Id"] + "") { if (chanpart.BillingCount == null) { chanpart.BillingCount = Convert.ToInt32(dic["BcCount"]); } else { chanpart.BillingCount += Convert.ToInt32(dic["BcCount"]); } chanpart.DoUpdate(); break; } } } } //查询 以获得state return(DataHelper.QueryValue <string>("select " + db + ".dbo.fun_getWKPCount('" + oid + "')")); }
string type = String.Empty; // 对象类型 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"); oid = RequestData.Get <string>("oid"); type = RequestData.Get <string>("type"); PriceApply ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <PriceApply>(); ent.State = ""; ent.ApprovalState = ""; ent.DoUpdate(); this.SetMessage("修改成功!"); break; case RequestActionEnum.Insert: case RequestActionEnum.Create: ent = this.GetPostedData <PriceApply>(); if (oid != "") { ent.OId = oid; } //自动生成流水号 ent.Number = DataHelper.QueryValue("select " + db + ".dbo.fun_getPriceAppNumber()") + ""; ent.DoCreate(); this.SetMessage("新建成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <PriceApply>(); ent.DoDelete(); this.SetMessage("删除成功!"); return; default: if (RequestActionString == "submitfinish") { PriceApply pc = PriceApply.Find(this.RequestData.Get <string>("id")); pc.State = "End"; pc.ApprovalState = this.RequestData.Get <string>("ApprovalState"); pc.Save(); //更新销售单对应的状态 if (!string.IsNullOrEmpty(pc.OId)) { SaleOrder order = SaleOrder.TryFind(pc.OId); if (order != null) { order.PAState = pc.ApprovalState; order.Save(); } } } break; } if (RequestActionString == "getSalesman") { string cid = RequestData.Get <string>("CId"); Customer customer = Customer.TryFind(cid); if (customer != null) { PageState.Add("Code", customer.Code); } } else if (op == "c" && !string.IsNullOrEmpty(oid)) { if (!string.IsNullOrEmpty(oid)) { SaleOrder order = SaleOrder.TryFind(oid); if (order != null) { order.Id = ""; order.Reason = ""; order.Number = ""; order.ApprovalState = ""; order.Remark = ""; order.State = ""; this.SetFormData(order); } } } else if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { ent = PriceApply.Find(id); } this.SetFormData(ent); this.PageState.Add("State", ent.State); IList <OrdersPart> opEnts = OrdersPart.FindAllByProperty(OrdersPart.Prop_OId, ent.OId); PageState.Add("DataList", opEnts); } PageState.Add("FlowEnum", SysEnumeration.GetEnumDictList("WorkFlow.Simple")); }