string type = String.Empty; // 对象类型 #endregion #region ASP.NET 事件 protected void Page_Load(object sender, EventArgs e) { string db = ConfigurationManager.AppSettings["ExamineDB"]; op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); paids = RequestData.Get <string>("paids"); type = RequestData.Get <string>("type"); DeliveryOrder ent = null; IList <string> strList = RequestData.GetList <string>("data"); PageState.Add("Id", ""); switch (this.RequestAction) { case RequestActionEnum.Insert: case RequestActionEnum.Create: ent = this.GetPostedData <DeliveryOrder>(); ent.PId = paids; //自动生成流水号 ent.Number = DataHelper.QueryValue("select " + db + ".dbo.fun_getDeliveryNumber()") + ""; ent.DoCreate(); //更新销售单状态(放到保存的地方) if (!string.IsNullOrEmpty(paids)) { GetDeliveryState(strList, paids); } //添加出库商品信息 InsertPart(strList, ent.Id); PageState["Id"] = ent.Id; this.SetMessage("新建成功!"); break; default: break; } if (RequestActionString == "getSalesman") { string cid = RequestData.Get <string>("CId"); Customer customer = Customer.Find(cid); if (customer != null) { PageState.Add("result", customer.MagUser); PageState.Add("MagId", customer.MagId); PageState.Add("Address", customer.Address); // PageState.Add("Tel", customer.Tel); PageState.Add("Code", customer.Code); } } else if (RequestActionString == "checkdata") { string productIds = RequestData.Get <string>("productIds"); string WarehouseId = RequestData.Get <string>("WarehouseId"); if (!string.IsNullOrEmpty(productIds)) { int count = DataHelper.QueryValue <int>("select count(1) from " + db + "..StockInfo where WarehouseId='" + WarehouseId + "' and ProductId in ('" + productIds.Replace(",", "','") + "')"); if (count != productIds.Split(',').Length) { PageState.Add("error", "所选商品在指定仓库里没有找到,请重新选择"); } } } //销售订单生成销售出库单 else if (op == "c" && !string.IsNullOrEmpty(paids)) { string[] oids = paids.Split(','); SaleOrder[] ents = SaleOrder.FindAllByPrimaryKeys(oids); if (ents.Length > 0) { ents[0].Id = ""; ents[0].Number = "自动生成"; //ents[0].Remark = ""; ents[0].State = ""; ents[0].Child = "[]"; this.SetFormData(ents[0]); } } else if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { ent = DeliveryOrder.Find(id); } this.SetFormData(ent); this.PageState.Add("State", ent.State); } PageState.Add("DeliveryMode", SysEnumeration.GetEnumDict("DeliveryMode")); }
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")); }
string type = String.Empty; // 对象类型 protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); type = RequestData.Get <string>("type"); IList <string> entStrList = RequestData.GetList <string>("data"); WarehouseExchange ent = null; switch (RequestActionString) { case "create": ent = GetPostedData <WarehouseExchange>(); ent.ExchangeState = "未结束"; ent.OutWarehouseState = "未出库"; ent.InWarehouseState = "未入库"; ent.CreateId = UserInfo.UserID; ent.CreateName = UserInfo.Name; ent.CreateTime = System.DateTime.Now; ent.DoCreate(); ProcessDetail(entStrList, ent); DeliveryOrder doEnt = new DeliveryOrder(); doEnt.Number = DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getDeliveryNumber()").ToString(); doEnt.DeliveryType = "调拨出库"; doEnt.PId = ent.Id; doEnt.WarehouseId = ent.FromWarehouseId; doEnt.WarehouseName = ent.FromWarehouseName; doEnt.DoCreate(); ProcessDeliveryOrderDetail(entStrList, doEnt); InWarehouse iwEnt = new InWarehouse(); iwEnt.WarehouseId = ent.ToWarehouseId; iwEnt.WarehouseName = ent.ToWarehouseName; iwEnt.InWarehouseNo = DataHelper.QueryValue <string>("select SHHG_AimExamine.dbo.fun_getInWarehouseNo()"); iwEnt.InWarehouseType = "调拨入库"; iwEnt.State = "未入库"; iwEnt.CreateId = UserInfo.UserID; iwEnt.CreateName = UserInfo.Name; iwEnt.CreateTime = System.DateTime.Now; iwEnt.PublicInterface = ent.Id; iwEnt.DoCreate(); ProcessInWarehouseDetail(entStrList, iwEnt); break; //case "update": // ent = this.GetMergedData<PurchaseOrder>(); // PurchaseOrderDetail.DeleteAll("PurchaseOrderId='" + ent.Id + "'"); // ProcessDetail(entStrList, ent); // ent.PurchaseType = "生产商采购"; // ent.DoUpdate(); // break; case "batchdelete": DoBatchDelete(); break; default: DoSelect(); break; } if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { string sql = @"select A.*,B.SupplierName,B.MoneyType,B.Symbo from SHHG_AimExamine..PurchaseOrder as A left join SHHG_AimExamine..Supplier as B on A.SupplierId=B.Id where A.Id='" + id + "'"; IList <EasyDictionary> ents = DataHelper.QueryDictList(sql); this.SetFormData(ents[0]); } } else//添加的时候找到默认供应商 { IList <EasyDictionary> dics = DataHelper.QueryDictList("select Id as SupplierId,SupplierName,MoneyType from SHHG_AimExamine..Supplier where IsDefault='on'"); if (dics.Count > 0) { this.SetFormData(dics[0]); } //添加的时候自动生成采购单流水号 PageState.Add("ExchangeNo", DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_GetWarehouseExchangeNo()")); } }
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")); }
string type = String.Empty; // 对象类型 #endregion #region ASP.NET 事件 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"); type = RequestData.Get <string>("type"); DeliveryOrder ent = null; IList <string> strList = RequestData.GetList <string>("data"); switch (this.RequestAction) { case RequestActionEnum.Insert: case RequestActionEnum.Create: ent = this.GetPostedData <DeliveryOrder>(); ent.PId = paid; //自动生成流水号 ent.Number = DataHelper.QueryValue("select " + db + ".dbo.fun_getDeliveryNumber()") + ""; ent.DoCreate(); //添加出库商品信息 InsertPart(strList, ent.Id); break; default: break; } if (RequestActionString == "getSalesman") { string cid = RequestData.Get <string>("CId"); Customer customer = Customer.Find(cid); if (customer != null) { PageState.Add("result", customer.MagUser); PageState.Add("MagId", customer.MagId); PageState.Add("Address", customer.Address); //PageState.Add("Tel", customer.Tel); PageState.Add("Code", customer.Code); } } else if (RequestActionString == "checkdata") { string productIds = RequestData.Get <string>("productIds"); string WarehouseId = RequestData.Get <string>("WarehouseId"); if (!string.IsNullOrEmpty(productIds)) { int count = DataHelper.QueryValue <int>("select count(1) from " + db + "..StockInfo where WarehouseId='" + WarehouseId + "' and ProductId in ('" + productIds.Replace(",", "','") + "')"); if (count != productIds.Split(',').Length) { PageState.Add("error", "所选商品在指定仓库里没有找到,请重新选择"); } } } else if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { ent = DeliveryOrder.Find(id); } this.SetFormData(ent); this.PageState.Add("State", ent.State); if (!String.IsNullOrEmpty(id)) { //查询子商品 string sql = "select Id, PCode as Code, PName as Name, ProductId,Isbn, Guids, Count as OutCount, Unit, Remark from " + db + "..DelieryOrderPart where DId='" + id + "'"; PageState.Add("DetailList", DataHelper.QueryDictList(sql)); } } PageState.Add("DeliveryMode", SysEnumeration.GetEnumDict("DeliveryMode")); }