/// <summary> /// 更新一条数据 /// </summary> public bool Update(DTcms.Model.StoreOutWaitingGoods model) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update StoreOutWaitingGoods set "); strSql.Append("CreateTime=@CreateTime,"); strSql.Append("StoringOutTime=@StoringOutTime,"); strSql.Append("StoredOutTime=@StoredOutTime,"); strSql.Append("Admin=@Admin,"); strSql.Append("Status=@Status,"); strSql.Append("Remark=@Remark,"); strSql.Append("StoreInGoodsId=@StoreInGoodsId,"); strSql.Append("GoodsId=@GoodsId,"); strSql.Append("StoreInOrderId=@StoreInOrderId"); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@StoringOutTime", SqlDbType.DateTime), new SqlParameter("@StoredOutTime", SqlDbType.DateTime), new SqlParameter("@Admin", SqlDbType.NVarChar,254), new SqlParameter("@Status", SqlDbType.Int,4), new SqlParameter("@Remark", SqlDbType.NVarChar,254), new SqlParameter("@StoreInGoodsId", SqlDbType.Int,4), new SqlParameter("@GoodsId", SqlDbType.Int,4), new SqlParameter("@StoreInOrderId", SqlDbType.Int,4), new SqlParameter("@Id", SqlDbType.Int,4)}; parameters[0].Value = model.CreateTime; parameters[1].Value = model.StoringOutTime; parameters[2].Value = model.StoredOutTime; parameters[3].Value = model.Admin; parameters[4].Value = model.Status; parameters[5].Value = model.Remark; parameters[6].Value = model.StoreInGoodsId; parameters[7].Value = model.GoodsId; parameters[8].Value = model.StoreInOrderId; parameters[9].Value = model.Id; DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters); #region 车辆==================== StoreOutGoodsVehicle storeOutGoodsVehicleDAL = new StoreOutGoodsVehicle(); storeOutGoodsVehicleDAL.Delete(conn, trans, model.Id); if (model.GoodsVehicles.Count > 0) { foreach (Model.StoreOutGoodsVehicle goodsVehicle in model.GoodsVehicles) { goodsVehicle.StoreOutWaitingGoodsId = model.Id; storeOutGoodsVehicleDAL.Add(conn, trans, goodsVehicle); } } #endregion trans.Commit(); } catch { trans.Rollback(); return false; } } } return true; }
public bool Add(DTcms.Model.StoreOutWaitingGoods model) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into StoreOutWaitingGoods("); strSql.Append("CreateTime,StoringOutTime,StoredOutTime,Admin,Status,Remark,StoreInGoodsId,GoodsId,StoreInOrderId)"); strSql.Append(" values ("); strSql.Append("@CreateTime,@StoringOutTime,@StoredOutTime,@Admin,@Status,@Remark,@StoreInGoodsId,@GoodsId,@StoreInOrderId)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@StoringOutTime", SqlDbType.DateTime), new SqlParameter("@StoredOutTime", SqlDbType.DateTime), new SqlParameter("@Admin", SqlDbType.NVarChar, 254), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@Remark", SqlDbType.NVarChar, 254), new SqlParameter("@StoreInGoodsId", SqlDbType.Int, 4), new SqlParameter("@GoodsId", SqlDbType.Int, 4), new SqlParameter("@StoreInOrderId", SqlDbType.Int, 4) }; parameters[0].Value = model.CreateTime; parameters[1].Value = model.StoringOutTime; parameters[2].Value = model.StoredOutTime; parameters[3].Value = model.Admin; parameters[4].Value = model.Status; parameters[5].Value = model.Remark; parameters[6].Value = model.StoreInGoodsId; parameters[7].Value = model.GoodsId; parameters[8].Value = model.StoreInOrderId; object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务 model.Id = Convert.ToInt32(obj); #region 车辆==================== if (model.GoodsVehicles.Count > 0) { StoreOutGoodsVehicle storeOutGoodsVehicleDAL = new StoreOutGoodsVehicle(); foreach (Model.StoreOutGoodsVehicle goodsVehicle in model.GoodsVehicles) { goodsVehicle.StoreOutWaitingGoodsId = model.Id; storeOutGoodsVehicleDAL.Add(conn, trans, goodsVehicle); } } #endregion trans.Commit(); } catch { trans.Rollback(); return(false); } } } return(model.Id > 0); }
public bool Add(DTcms.Model.StoreOutWaitingGoods model) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into StoreOutWaitingGoods("); strSql.Append("CreateTime,StoringOutTime,StoredOutTime,Admin,Status,Remark,StoreInGoodsId,GoodsId,StoreInOrderId)"); strSql.Append(" values ("); strSql.Append("@CreateTime,@StoringOutTime,@StoredOutTime,@Admin,@Status,@Remark,@StoreInGoodsId,@GoodsId,@StoreInOrderId)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@StoringOutTime", SqlDbType.DateTime), new SqlParameter("@StoredOutTime", SqlDbType.DateTime), new SqlParameter("@Admin", SqlDbType.NVarChar,254), new SqlParameter("@Status", SqlDbType.Int,4), new SqlParameter("@Remark", SqlDbType.NVarChar,254), new SqlParameter("@StoreInGoodsId", SqlDbType.Int,4), new SqlParameter("@GoodsId", SqlDbType.Int,4), new SqlParameter("@StoreInOrderId", SqlDbType.Int,4)}; parameters[0].Value = model.CreateTime; parameters[1].Value = model.StoringOutTime; parameters[2].Value = model.StoredOutTime; parameters[3].Value = model.Admin; parameters[4].Value = model.Status; parameters[5].Value = model.Remark; parameters[6].Value = model.StoreInGoodsId; parameters[7].Value = model.GoodsId; parameters[8].Value = model.StoreInOrderId; object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务 model.Id = Convert.ToInt32(obj); #region 车辆==================== if (model.GoodsVehicles.Count > 0) { StoreOutGoodsVehicle storeOutGoodsVehicleDAL = new StoreOutGoodsVehicle(); foreach (Model.StoreOutGoodsVehicle goodsVehicle in model.GoodsVehicles) { goodsVehicle.StoreOutWaitingGoodsId = model.Id; storeOutGoodsVehicleDAL.Add(conn, trans, goodsVehicle); } } #endregion trans.Commit(); } catch { trans.Rollback(); return false; } } } return model.Id > 0; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DTcms.Model.StoreOutWaitingGoods model) { using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update StoreOutWaitingGoods set "); strSql.Append("CreateTime=@CreateTime,"); strSql.Append("StoringOutTime=@StoringOutTime,"); strSql.Append("StoredOutTime=@StoredOutTime,"); strSql.Append("Admin=@Admin,"); strSql.Append("Status=@Status,"); strSql.Append("Remark=@Remark,"); strSql.Append("StoreInGoodsId=@StoreInGoodsId,"); strSql.Append("GoodsId=@GoodsId,"); strSql.Append("StoreInOrderId=@StoreInOrderId"); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@StoringOutTime", SqlDbType.DateTime), new SqlParameter("@StoredOutTime", SqlDbType.DateTime), new SqlParameter("@Admin", SqlDbType.NVarChar, 254), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@Remark", SqlDbType.NVarChar, 254), new SqlParameter("@StoreInGoodsId", SqlDbType.Int, 4), new SqlParameter("@GoodsId", SqlDbType.Int, 4), new SqlParameter("@StoreInOrderId", SqlDbType.Int, 4), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.CreateTime; parameters[1].Value = model.StoringOutTime; parameters[2].Value = model.StoredOutTime; parameters[3].Value = model.Admin; parameters[4].Value = model.Status; parameters[5].Value = model.Remark; parameters[6].Value = model.StoreInGoodsId; parameters[7].Value = model.GoodsId; parameters[8].Value = model.StoreInOrderId; parameters[9].Value = model.Id; DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters); #region 车辆==================== StoreOutGoodsVehicle storeOutGoodsVehicleDAL = new StoreOutGoodsVehicle(); storeOutGoodsVehicleDAL.Delete(conn, trans, model.Id); if (model.GoodsVehicles.Count > 0) { foreach (Model.StoreOutGoodsVehicle goodsVehicle in model.GoodsVehicles) { goodsVehicle.StoreOutWaitingGoodsId = model.Id; storeOutGoodsVehicleDAL.Add(conn, trans, goodsVehicle); } } #endregion trans.Commit(); } catch { trans.Rollback(); return(false); } } } return(true); }