public int Add(SqlConnection conn, SqlTransaction trans, DTcms.Model.AllotGoods model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AllotGoods("); strSql.Append("AllotOrderId,StoreInOrderId,StoreInGoodsId,Remark,Count,Status,SourceStoreId,PurposeStoreId "); strSql.Append(") values ("); strSql.Append("@AllotOrderId,@StoreInOrderId,@StoreInGoodsId,@Remark,@Count,@Status,@SourceStoreId,@PurposeStoreId"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@AllotOrderId", SqlDbType.Int, 4), new SqlParameter("@StoreInOrderId", SqlDbType.Int, 4), new SqlParameter("@StoreInGoodsId", SqlDbType.Int, 4), new SqlParameter("@Remark", SqlDbType.VarChar, 254), new SqlParameter("@Count", SqlDbType.Decimal, 9), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@SourceStoreId", SqlDbType.Int, 4), new SqlParameter("@PurposeStoreId", SqlDbType.Int, 4) }; parameters[0].Value = model.AllotOrderId; parameters[1].Value = model.StoreInOrderId; parameters[2].Value = model.StoreInGoodsId; parameters[3].Value = model.Remark; parameters[4].Value = model.Count; parameters[5].Value = model.Status; parameters[6].Value = model.SourceStoreId; parameters[7].Value = model.PurposeStoreId; object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); StoreInGoods storeInGoodsDAL = new StoreInGoods(); Model.StoreInGoods storeInGoods = storeInGoodsDAL.GetModel(model.StoreInGoodsId); if (storeInGoods != null) { storeInGoodsDAL.UpdateField(conn, trans, model.StoreInGoodsId, " Count = Count - " + model.Count + ""); Model.StoreInGoods newStoreInGoods = new Model.StoreInGoods(model.PurposeStoreId, storeInGoods.StoreWaitingGoodsId, storeInGoods.CustomerId, storeInGoods.GoodsId, model.Count, "调拨货物"); newStoreInGoods.StoreInOrderId = model.StoreInOrderId; newStoreInGoods.Status = 1; storeInGoodsDAL.Add(conn, trans, newStoreInGoods); } if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
public bool Delete(SqlConnection conn, SqlTransaction trans, int allotOrderId) { DataTable allotGoodsDT = GetList(0, "AllotOrderId = " + allotOrderId + "", "Id desc").Tables[0]; if (allotGoodsDT.Rows.Count > 0) { StoreInGoods storeInGoodsDAL = new StoreInGoods(); foreach (DataRow dr in allotGoodsDT.Rows) { int storeInOrderId = Convert.ToInt32(dr["StoreInOrderId"]); int storeInGoodsId = Convert.ToInt32(dr["StoreInGoodsId"]); int status = Convert.ToInt32(dr["Status"]); decimal count = Convert.ToInt32(dr["Count"]); storeInGoodsDAL.UpdateField(conn, trans, storeInGoodsId, "Count = Count + " + count + ""); storeInGoodsDAL.Delete(conn, trans, " StoreInOrderId = " + storeInOrderId + " and Status = 1 "); } } StringBuilder strSql = new StringBuilder(); strSql.Append("delete from AllotGoods "); strSql.Append(" where AllotOrderId=@AllotOrderId"); SqlParameter[] parameters = { new SqlParameter("@AllotOrderId", SqlDbType.Int, 4) }; parameters[0].Value = allotOrderId; int rows = DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public bool Delete(SqlConnection conn, SqlTransaction trans, int storeOutOrderId) { DataSet storeOutGoodsDS = GetList(0, " StoreOutOrderId = " + storeOutOrderId + "", " Id desc"); if (storeOutGoodsDS != null) { StoreInGoods storeInGoodsDAL = new StoreInGoods(); StoreOutWaitingGoods storeOutWaitingGoodsDAL = new StoreOutWaitingGoods(); foreach (DataRow dr in storeOutGoodsDS.Tables[0].Rows) { storeInGoodsDAL.UpdateField(conn, trans, Convert.ToInt32(dr["StoreInGoodsId"]), "Count = Count + " + Convert.ToDecimal(dr["Count"]) + ""); storeOutWaitingGoodsDAL.UpdateField(conn, trans, Convert.ToInt32(dr["StoreOutWaitingGoodsId"]), " Status = 0 "); } StringBuilder strSql = new StringBuilder(); strSql.Append("delete from StoreOutGoods "); strSql.Append(" where StoreOutOrderId=@StoreOutOrderId"); SqlParameter[] parameters = { new SqlParameter("@StoreOutOrderId", SqlDbType.Int, 4) }; parameters[0].Value = storeOutOrderId; int rows = DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } } return(false); }
public int Add(SqlConnection conn, SqlTransaction trans, DTcms.Model.AllotGoods model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AllotGoods("); strSql.Append("AllotOrderId,StoreInOrderId,StoreInGoodsId,Remark,Count,Status,SourceStoreId,PurposeStoreId "); strSql.Append(") values ("); strSql.Append("@AllotOrderId,@StoreInOrderId,@StoreInGoodsId,@Remark,@Count,@Status,@SourceStoreId,@PurposeStoreId"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@AllotOrderId", SqlDbType.Int,4) , new SqlParameter("@StoreInOrderId", SqlDbType.Int,4) , new SqlParameter("@StoreInGoodsId", SqlDbType.Int,4) , new SqlParameter("@Remark", SqlDbType.VarChar,254) , new SqlParameter("@Count", SqlDbType.Decimal,9) , new SqlParameter("@Status", SqlDbType.Int,4), new SqlParameter("@SourceStoreId", SqlDbType.Int,4) , new SqlParameter("@PurposeStoreId", SqlDbType.Int,4) }; parameters[0].Value = model.AllotOrderId; parameters[1].Value = model.StoreInOrderId; parameters[2].Value = model.StoreInGoodsId; parameters[3].Value = model.Remark; parameters[4].Value = model.Count; parameters[5].Value = model.Status; parameters[6].Value = model.SourceStoreId; parameters[7].Value = model.PurposeStoreId; object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); StoreInGoods storeInGoodsDAL = new StoreInGoods(); Model.StoreInGoods storeInGoods = storeInGoodsDAL.GetModel(model.StoreInGoodsId); if (storeInGoods != null) { storeInGoodsDAL.UpdateField(conn, trans, model.StoreInGoodsId, " Count = Count - " + model.Count + ""); Model.StoreInGoods newStoreInGoods = new Model.StoreInGoods(model.PurposeStoreId, storeInGoods.StoreWaitingGoodsId, storeInGoods.CustomerId, storeInGoods.GoodsId, model.Count, "调拨货物"); newStoreInGoods.StoreInOrderId = model.StoreInOrderId; newStoreInGoods.Status = 1; storeInGoodsDAL.Add(conn, trans, newStoreInGoods); } if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } }
public bool Delete(SqlConnection conn, SqlTransaction trans, int allotOrderId) { DataTable allotGoodsDT = GetList(0, "AllotOrderId = " + allotOrderId + "", "Id desc").Tables[0]; if (allotGoodsDT.Rows.Count > 0) { StoreInGoods storeInGoodsDAL = new StoreInGoods(); foreach (DataRow dr in allotGoodsDT.Rows) { int storeInOrderId = Convert.ToInt32(dr["StoreInOrderId"]); int storeInGoodsId = Convert.ToInt32(dr["StoreInGoodsId"]); int status = Convert.ToInt32(dr["Status"]); decimal count = Convert.ToInt32(dr["Count"]); storeInGoodsDAL.UpdateField(conn, trans, storeInGoodsId, "Count = Count + " + count + ""); storeInGoodsDAL.Delete(conn, trans, " StoreInOrderId = " + storeInOrderId + " and Status = 1 "); } } StringBuilder strSql = new StringBuilder(); strSql.Append("delete from AllotGoods "); strSql.Append(" where AllotOrderId=@AllotOrderId"); SqlParameter[] parameters = { new SqlParameter("@AllotOrderId", SqlDbType.Int,4) }; parameters[0].Value = allotOrderId; int rows = DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } }
public bool Delete(SqlConnection conn, SqlTransaction trans, int storeOutOrderId) { DataSet storeOutGoodsDS = GetList(0, " StoreOutOrderId = " + storeOutOrderId + "", " Id desc"); if (storeOutGoodsDS != null) { StoreInGoods storeInGoodsDAL = new StoreInGoods(); StoreOutWaitingGoods storeOutWaitingGoodsDAL = new StoreOutWaitingGoods(); foreach (DataRow dr in storeOutGoodsDS.Tables[0].Rows) { storeInGoodsDAL.UpdateField(conn, trans, Convert.ToInt32(dr["StoreInGoodsId"]), "Count = Count + " + Convert.ToDecimal(dr["Count"]) + ""); storeOutWaitingGoodsDAL.UpdateField(conn, trans, Convert.ToInt32(dr["StoreOutWaitingGoodsId"]), " Status = 0 "); } StringBuilder strSql = new StringBuilder(); strSql.Append("delete from StoreOutGoods "); strSql.Append(" where StoreOutOrderId=@StoreOutOrderId"); SqlParameter[] parameters = { new SqlParameter("@StoreOutOrderId", SqlDbType.Int,4) }; parameters[0].Value = storeOutOrderId; int rows = DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } return false; }