public int Insert(POBasketInfo oParam) { string sql = @"INSERT INTO PO_Basket ( CreateUserSysNo, ProductSysNo, Quantity, OrderPrice ) VALUES ( @CreateUserSysNo, @ProductSysNo, @Quantity, @OrderPrice );set @SysNo = SCOPE_IDENTITY();"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4); SqlParameter paramCreateUserSysNo = new SqlParameter("@CreateUserSysNo", SqlDbType.Int,4); SqlParameter paramProductSysNo = new SqlParameter("@ProductSysNo", SqlDbType.Int,4); SqlParameter paramQuantity = new SqlParameter("@Quantity", SqlDbType.Int,4); SqlParameter paramOrderPrice = new SqlParameter("@OrderPrice", SqlDbType.Decimal,9); paramSysNo.Direction = ParameterDirection.Output; if ( oParam.CreateUserSysNo != AppConst.IntNull) paramCreateUserSysNo.Value = oParam.CreateUserSysNo; else paramCreateUserSysNo.Value = System.DBNull.Value; if ( oParam.ProductSysNo != AppConst.IntNull) paramProductSysNo.Value = oParam.ProductSysNo; else paramProductSysNo.Value = System.DBNull.Value; if ( oParam.Quantity != AppConst.IntNull) paramQuantity.Value = oParam.Quantity; else paramQuantity.Value = System.DBNull.Value; if ( oParam.OrderPrice != AppConst.DecimalNull) paramOrderPrice.Value = oParam.OrderPrice; else paramOrderPrice.Value = System.DBNull.Value; cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramCreateUserSysNo); cmd.Parameters.Add(paramProductSysNo); cmd.Parameters.Add(paramQuantity); cmd.Parameters.Add(paramOrderPrice); return SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo); }
public Hashtable GetPOBasketHash(int userSysNo) { if ( userSysNo == AppConst.IntNull ) return null; string sql = @"select * from po_basket where createusersysno = " + userSysNo; DataSet ds = SqlHelper.ExecuteDataSet(sql); if (!Util.HasMoreRow(ds)) return null; Hashtable ht = new Hashtable(5); foreach(DataRow dr in ds.Tables[0].Rows) { POBasketInfo item = new POBasketInfo(); map(item, dr); ht.Add(item.SysNo, item); } return ht; }
private void map(POBasketInfo oParam, DataRow tempdr) { oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]); oParam.CreateUserSysNo = Util.TrimIntNull(tempdr["CreateUserSysNo"]); oParam.ProductSysNo = Util.TrimIntNull(tempdr["ProductSysNo"]); oParam.Quantity = Util.TrimIntNull(tempdr["Quantity"]); oParam.OrderPrice = Util.TrimDecimalNull(tempdr["OrderPrice"]); }
public void UpdatePOBasket(POBasketInfo oParam) { //ֻ�ܸ������� new POBasketDac().Update(oParam); }
public POBasketInfo LoadBasket(int productSysNo, int userSysNo) { string sql = "select * from po_basket where productsysno =" + productSysNo + " and createusersysno =" + userSysNo; DataSet ds = SqlHelper.ExecuteDataSet(sql); if ( !Util.HasMoreRow(ds)) return null; POBasketInfo oInfo = new POBasketInfo(); map(oInfo, ds.Tables[0].Rows[0]); return oInfo; }
public void InsertPOBasket(POBasketInfo oParam) { string sql = "select * from po_basket where productsysno=" +oParam.ProductSysNo; DataSet ds = SqlHelper.ExecuteDataSet(sql); if ( Util.HasMoreRow(ds)) throw new BizException("the same product exists in yours or others' basket"); new POBasketDac().Insert(oParam); }
public int Update(POBasketInfo oParam) { string sql = @"UPDATE PO_Basket SET Quantity=@Quantity, OrderPrice = @OrderPrice WHERE SysNo=@SysNo"; SqlCommand cmd = new SqlCommand(sql); SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4); SqlParameter paramQuantity = new SqlParameter("@Quantity", SqlDbType.Int,4); SqlParameter paramOrderPrice = new SqlParameter("@OrderPrice", SqlDbType.Decimal,9); if ( oParam.SysNo != AppConst.IntNull) paramSysNo.Value = oParam.SysNo; else paramSysNo.Value = System.DBNull.Value; if ( oParam.Quantity != AppConst.IntNull) paramQuantity.Value = oParam.Quantity; else paramQuantity.Value = System.DBNull.Value; if ( oParam.OrderPrice != AppConst.DecimalNull) paramOrderPrice.Value = oParam.OrderPrice; else paramOrderPrice.Value = System.DBNull.Value; cmd.Parameters.Add(paramSysNo); cmd.Parameters.Add(paramQuantity); cmd.Parameters.Add(paramOrderPrice); return SqlHelper.ExecuteNonQuery(cmd); }