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; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DTcms.Model.StoreInOrder model) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update StoreInOrder set "); strSql.Append(" CustomerId = @CustomerId , "); strSql.Append(" BeginChargingTime = @BeginChargingTime , "); strSql.Append(" ChargingTime = @ChargingTime , "); strSql.Append(" Admin = @Admin , "); strSql.Append(" ChargingCount = @ChargingCount , "); strSql.Append(" InspectionNumber = @InspectionNumber , "); strSql.Append(" AccountNumber = @AccountNumber , "); strSql.Append(" SuttleWeight = @SuttleWeight , "); strSql.Append(" Remark = @Remark "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) , new SqlParameter("@CustomerId", SqlDbType.Int,4) , new SqlParameter("@BeginChargingTime", SqlDbType.DateTime) , new SqlParameter("@ChargingTime", SqlDbType.DateTime) , new SqlParameter("@Admin", SqlDbType.VarChar,254) , new SqlParameter("@ChargingCount", SqlDbType.Decimal,9) , new SqlParameter("@InspectionNumber", SqlDbType.VarChar,254) , new SqlParameter("@AccountNumber", SqlDbType.VarChar,254) , new SqlParameter("@SuttleWeight", SqlDbType.Decimal,9) , new SqlParameter("@Remark", SqlDbType.VarChar,254) }; parameters[0].Value = model.Id; parameters[1].Value = model.CustomerId; parameters[2].Value = model.BeginChargingTime; parameters[3].Value = model.ChargingTime; parameters[4].Value = model.Admin; parameters[5].Value = model.ChargingCount; parameters[6].Value = model.InspectionNumber; parameters[7].Value = model.AccountNumber; parameters[8].Value = model.SuttleWeight; parameters[9].Value = model.Remark; DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters); #region 单价 StoreInUnitPrice unitPriceDAL = new StoreInUnitPrice(); unitPriceDAL.Delete(conn, trans, model.Id); if (model.UnitPrices.Count > 0) { foreach (Model.StoreInUnitPrice unitPrice in model.UnitPrices) { unitPrice.StoreInOrderId = model.Id; unitPriceDAL.Add(conn, trans, unitPrice); } } #endregion #region 费用 StoreInCost costDAL = new StoreInCost(); costDAL.Delete(conn, trans, model.Id); if (model.StoreInCosts.Count > 0) { foreach (Model.StoreInCost cost in model.StoreInCosts) { cost.StoreInOrderId = model.Id; costDAL.Add(conn, trans, cost); } } #endregion #region 入库货物==================== StoreInGoods storeInGoodsDAL = new StoreInGoods(); storeInGoodsDAL.Delete(conn, trans, model.Id); if (model.StoreInGoods.Count > 0) { StoreWaitingGoods waitingGoodsDAL = new StoreWaitingGoods(); foreach (Model.StoreInGoods storeInGoods in model.StoreInGoods) { storeInGoods.StoreInOrderId = model.Id; storeInGoodsDAL.Add(conn, trans, storeInGoods); waitingGoodsDAL.UpdateStatus(conn, trans, storeInGoods.StoreWaitingGoodsId, 1); } } #endregion trans.Commit(); } catch { trans.Rollback(); return false; } } } return true; }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DTcms.Model.StoreInOrder model) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into StoreInOrder("); strSql.Append("CustomerId,Status,CreateTime,BeginChargingTime,ChargingTime,Admin,ChargingCount,InspectionNumber,AccountNumber,SuttleWeight,Remark"); strSql.Append(") values ("); strSql.Append("@CustomerId,@Status,@CreateTime,@BeginChargingTime,@ChargingTime,@Admin,@ChargingCount,@InspectionNumber,@AccountNumber,@SuttleWeight,@Remark"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CustomerId", SqlDbType.Int,4) , new SqlParameter("@Status", SqlDbType.Int,4) , new SqlParameter("@CreateTime", SqlDbType.DateTime) , new SqlParameter("@BeginChargingTime", SqlDbType.DateTime) , new SqlParameter("@ChargingTime", SqlDbType.DateTime) , new SqlParameter("@Admin", SqlDbType.VarChar,254) , new SqlParameter("@ChargingCount", SqlDbType.Decimal,9) , new SqlParameter("@InspectionNumber", SqlDbType.VarChar,254) , new SqlParameter("@AccountNumber", SqlDbType.VarChar,254) , new SqlParameter("@SuttleWeight", SqlDbType.Decimal,9) , new SqlParameter("@Remark", SqlDbType.VarChar,254) }; parameters[0].Value = model.CustomerId; parameters[1].Value = model.Status; parameters[2].Value = model.CreateTime; parameters[3].Value = model.BeginChargingTime; parameters[4].Value = model.ChargingTime; parameters[5].Value = model.Admin; parameters[6].Value = model.ChargingCount; parameters[7].Value = model.InspectionNumber; parameters[8].Value = model.AccountNumber; parameters[9].Value = model.SuttleWeight; parameters[10].Value = model.Remark; object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务 model.Id = Convert.ToInt32(obj); #region 单价==================== if (model.UnitPrices.Count > 0) { StoreInUnitPrice unitPriceDAL = new StoreInUnitPrice(); foreach (Model.StoreInUnitPrice unitPrice in model.UnitPrices) { unitPrice.StoreInOrderId = model.Id; unitPriceDAL.Add(conn, trans, unitPrice); } } #endregion #region 费用==================== if (model.StoreInCosts.Count > 0) { StoreInCost storeInCostDAL = new StoreInCost(); foreach (Model.StoreInCost storeInCost in model.StoreInCosts) { storeInCost.StoreInOrderId = model.Id; storeInCostDAL.Add(conn, trans, storeInCost); } } #endregion #region 入库货物==================== if (model.StoreInGoods.Count > 0) { StoreInGoods storeInGoodsDAL = new StoreInGoods(); StoreWaitingGoods waitingGoodsDAL = new StoreWaitingGoods(); foreach (Model.StoreInGoods storeInGoods in model.StoreInGoods) { storeInGoods.StoreInOrderId = model.Id; storeInGoodsDAL.Add(conn, trans, storeInGoods); waitingGoodsDAL.UpdateStatus(conn, trans, storeInGoods.StoreWaitingGoodsId, 1); } } #endregion trans.Commit(); } catch { trans.Rollback(); return false; } } } return model.Id > 0; }
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; }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DTcms.Model.StoreInOrder model) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into StoreInOrder("); strSql.Append("CustomerId,Status,CreateTime,BeginChargingTime,ChargingTime,Admin,ChargingCount,InspectionNumber,AccountNumber,SuttleWeight,Remark"); strSql.Append(") values ("); strSql.Append("@CustomerId,@Status,@CreateTime,@BeginChargingTime,@ChargingTime,@Admin,@ChargingCount,@InspectionNumber,@AccountNumber,@SuttleWeight,@Remark"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CustomerId", SqlDbType.Int, 4), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@BeginChargingTime", SqlDbType.DateTime), new SqlParameter("@ChargingTime", SqlDbType.DateTime), new SqlParameter("@Admin", SqlDbType.VarChar, 254), new SqlParameter("@ChargingCount", SqlDbType.Decimal, 9), new SqlParameter("@InspectionNumber", SqlDbType.VarChar, 254), new SqlParameter("@AccountNumber", SqlDbType.VarChar, 254), new SqlParameter("@SuttleWeight", SqlDbType.Decimal, 9), new SqlParameter("@Remark", SqlDbType.VarChar, 254) }; parameters[0].Value = model.CustomerId; parameters[1].Value = model.Status; parameters[2].Value = model.CreateTime; parameters[3].Value = model.BeginChargingTime; parameters[4].Value = model.ChargingTime; parameters[5].Value = model.Admin; parameters[6].Value = model.ChargingCount; parameters[7].Value = model.InspectionNumber; parameters[8].Value = model.AccountNumber; parameters[9].Value = model.SuttleWeight; parameters[10].Value = model.Remark; object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务 model.Id = Convert.ToInt32(obj); #region 单价==================== if (model.UnitPrices.Count > 0) { StoreInUnitPrice unitPriceDAL = new StoreInUnitPrice(); foreach (Model.StoreInUnitPrice unitPrice in model.UnitPrices) { unitPrice.StoreInOrderId = model.Id; unitPriceDAL.Add(conn, trans, unitPrice); } } #endregion #region 费用==================== if (model.StoreInCosts.Count > 0) { StoreInCost storeInCostDAL = new StoreInCost(); foreach (Model.StoreInCost storeInCost in model.StoreInCosts) { storeInCost.StoreInOrderId = model.Id; storeInCostDAL.Add(conn, trans, storeInCost); } } #endregion #region 入库货物==================== if (model.StoreInGoods.Count > 0) { StoreInGoods storeInGoodsDAL = new StoreInGoods(); StoreWaitingGoods waitingGoodsDAL = new StoreWaitingGoods(); foreach (Model.StoreInGoods storeInGoods in model.StoreInGoods) { storeInGoods.StoreInOrderId = model.Id; storeInGoodsDAL.Add(conn, trans, storeInGoods); waitingGoodsDAL.UpdateStatus(conn, trans, storeInGoods.StoreWaitingGoodsId, 1); } } #endregion trans.Commit(); } catch { trans.Rollback(); return(false); } } } return(model.Id > 0); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DTcms.Model.StoreInOrder model) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update StoreInOrder set "); strSql.Append(" CustomerId = @CustomerId , "); strSql.Append(" BeginChargingTime = @BeginChargingTime , "); strSql.Append(" ChargingTime = @ChargingTime , "); strSql.Append(" Admin = @Admin , "); strSql.Append(" ChargingCount = @ChargingCount , "); strSql.Append(" InspectionNumber = @InspectionNumber , "); strSql.Append(" AccountNumber = @AccountNumber , "); strSql.Append(" SuttleWeight = @SuttleWeight , "); strSql.Append(" Remark = @Remark "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@CustomerId", SqlDbType.Int, 4), new SqlParameter("@BeginChargingTime", SqlDbType.DateTime), new SqlParameter("@ChargingTime", SqlDbType.DateTime), new SqlParameter("@Admin", SqlDbType.VarChar, 254), new SqlParameter("@ChargingCount", SqlDbType.Decimal, 9), new SqlParameter("@InspectionNumber", SqlDbType.VarChar, 254), new SqlParameter("@AccountNumber", SqlDbType.VarChar, 254), new SqlParameter("@SuttleWeight", SqlDbType.Decimal, 9), new SqlParameter("@Remark", SqlDbType.VarChar, 254) }; parameters[0].Value = model.Id; parameters[1].Value = model.CustomerId; parameters[2].Value = model.BeginChargingTime; parameters[3].Value = model.ChargingTime; parameters[4].Value = model.Admin; parameters[5].Value = model.ChargingCount; parameters[6].Value = model.InspectionNumber; parameters[7].Value = model.AccountNumber; parameters[8].Value = model.SuttleWeight; parameters[9].Value = model.Remark; DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters); #region 单价 StoreInUnitPrice unitPriceDAL = new StoreInUnitPrice(); unitPriceDAL.Delete(conn, trans, model.Id); if (model.UnitPrices.Count > 0) { foreach (Model.StoreInUnitPrice unitPrice in model.UnitPrices) { unitPrice.StoreInOrderId = model.Id; unitPriceDAL.Add(conn, trans, unitPrice); } } #endregion #region 费用 StoreInCost costDAL = new StoreInCost(); costDAL.Delete(conn, trans, model.Id); if (model.StoreInCosts.Count > 0) { foreach (Model.StoreInCost cost in model.StoreInCosts) { cost.StoreInOrderId = model.Id; costDAL.Add(conn, trans, cost); } } #endregion #region 入库货物==================== StoreInGoods storeInGoodsDAL = new StoreInGoods(); storeInGoodsDAL.Delete(conn, trans, model.Id); if (model.StoreInGoods.Count > 0) { StoreWaitingGoods waitingGoodsDAL = new StoreWaitingGoods(); foreach (Model.StoreInGoods storeInGoods in model.StoreInGoods) { storeInGoods.StoreInOrderId = model.Id; storeInGoodsDAL.Add(conn, trans, storeInGoods); waitingGoodsDAL.UpdateStatus(conn, trans, storeInGoods.StoreWaitingGoodsId, 1); } } #endregion trans.Commit(); } catch { trans.Rollback(); return(false); } } } return(true); }