private void init() { string action = Request.QueryString["action"].ToString(); if (action == null) { return; } else if (action.Equals("loadProductsStock")) { string str0 = Request.QueryString["ProductsID"].ToString(); string str1 = Request.QueryString["HouseDetailID"].ToString(); VProductsStock p = new VProductsStock(); p = Leyp.SQLServerDAL.Factory.getProductsStockDAL().getByProductsIDStockID(int.Parse(str0), int.Parse(str1)); if (p == null) { Response.Write("0"); Response.End(); } else { Response.Write(p.Num); Response.End(); } } }
private void checkProductsNum(int HID, int PID) { VProductsStock v = Leyp.SQLServerDAL.Factory.getProductsStockDAL().getByProductsIDStockID(PID, HID); if (v == null) { Response.Write("0"); Response.End(); } else { Response.Write(v.Num); Response.End(); } }
public List <VProductsStock> getProductsList(int HouseDetailID) { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@HouseDetailID", SqlDbType.Int) }; parameters[0].Value = HouseDetailID; List <VProductsStock> list = new List <VProductsStock>(); SqlDataReader reader = SQLHelper.RunProcedure("p_ProductsStock_getProductsList", parameters); while (reader.Read()) { VProductsStock item = new VProductsStock(); item.ID = reader.GetInt32(reader.GetOrdinal("ID")); item.HouseDetailID = reader.GetInt32(reader.GetOrdinal("HouseDetailID")); item.SubareaName = reader.GetString(reader.GetOrdinal("SubareaName")); item.HouseName = reader.GetString(reader.GetOrdinal("HouseName")); item.ProductsID = reader.GetInt32(reader.GetOrdinal("ProductsID")); item.ProductsName = reader.GetString(reader.GetOrdinal("ProductsName")); list.Add(item); } reader.Close(); return(list); }
public VProductsStock getByProductsIDStockID(int ProductsID, int HouseDetailID) { bool flag = false; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ProductsID", SqlDbType.Int), new SqlParameter("@HouseDetailID", SqlDbType.Int) }; parameters[0].Value = ProductsID; parameters[1].Value = HouseDetailID; VProductsStock stock = new VProductsStock(); SqlDataReader reader = SQLHelper.RunProcedure("p_ProductsStock_getByProductsIDStockID", parameters); while (reader.Read()) { stock.ID = reader.GetInt32(reader.GetOrdinal("ID")); stock.HouseDetailID = reader.GetInt32(reader.GetOrdinal("HouseDetailID")); stock.ProductsID = reader.GetInt32(reader.GetOrdinal("ProductsID")); stock.Num = reader.GetInt32(reader.GetOrdinal("Num")); flag = true; } reader.Close(); return(flag ? stock : null); }
/// <summary> /// 根据SalesOrderID 快速生成 /// </summary> /// <param name="SalesOrderID"></param> private void buildNode(string SalesOrderID, int DeliveryID) { bool result = true; VSalesOrder vo = Leyp.SQLServerDAL.Sales.Factory.getSalesOrderDAL().getByID(SalesOrderID); if (vo == null) { Response.Write("订单号:" + SalesOrderID + " 有误<br>"); return; } if (vo.State != 1)//订单没有审核 { Response.Write("订单号:" + SalesOrderID + " 没有审核或已经处理<br>"); return; } string SalesOutID = getSalesOutID(); // int DeliveryID = Leyp.SQLServerDAL.Factory.getDeliveryDAL().getDefaultEitity().DeliveryID;//得到默认得 SalesOut s = new SalesOut(); s.Consignee = "未知"; s.CreateDate = DateTime.Now.ToString("yyyy-MM-dd"); s.DeliveryID = DeliveryID; s.TradeDate = DateTime.Now.ToString("yyyy-MM-dd"); s.Deposits = float.Parse("0.00"); s.Description = "无"; s.UserName = getUserName(); s.State = 0; s.SalesOutID = SalesOutID; s.SalesOrderID = SalesOrderID; s.AccountsID = "无"; Leyp.SQLServerDAL.Sales.Factory.getSalesOutDAL().insertSalesDetailFrist(SalesOrderID, SalesOutID);//临时添加详细 List <VSalesOutDetail> list = Leyp.SQLServerDAL.Sales.Factory.getSalesOutDetailDAL().getBySalesOutIDinit(SalesOutID); for (int i = 0; i < list.Count; i++) { if (result == false) { break; } VSalesOutDetail v = list[i]; int ProductsID = v.ProductsID; List <VProductsStock> list0 = Leyp.SQLServerDAL.Factory.getProductsStockDAL().getStockList(ProductsID); //寻找库存 if (list0 == null || list0.Count == 0) //没有库存 { result = false; break; } VProductsStock vp = null; for (int j = 0; j < list0.Count; j++) { VProductsStock vps = list0[j]; if (vps.Num >= v.Quantity)//有库存 并且数量合理 { vp = vps; break; } } if (vp == null)//没有库存 失败! { result = false; break; } SalesOutDetail d = new SalesOutDetail(); d.SalesOutID = v.SalesOutID; d.ProductsID = v.ProductsID; d.Price = v.Price; d.Quantity = v.Quantity; d.DiscountRate = v.DiscountRate; d.Description = v.Description; d.DetailID = v.DetailID; d.StoreHouseID = vp.HouseID; d.HouseDetailID = vp.HouseDetailID; Leyp.SQLServerDAL.Sales.Factory.getSalesOutDetailDAL().updateEitity(d); } if (result == true) { if (Leyp.SQLServerDAL.Sales.Factory.getSalesOutDAL().insertNewEntity(s)) { Response.Write("单号:" + SalesOrderID + " --生成成功<br>"); } } else { Response.Write("订单号:" + SalesOrderID + " 不能生成,可能库存不足<br>"); } }