/// <summary> /// 增加一条数据 /// </summary> public void Add(DTcms.Model.StoreInOrder model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into StoreInOrder("); strSql.Append("Id,CustomerId,Status,CreateTime,BeginChargingTime,ChargingTime,Admin,ChargingCount,InspectionNumber,AccountNumber,SuttleWeight,FreeDays,Remark"); strSql.Append(") values ("); strSql.Append("@Id,@CustomerId,@Status,@CreateTime,@BeginChargingTime,@ChargingTime,@Admin,@ChargingCount,@InspectionNumber,@AccountNumber,@SuttleWeight,@FreeDays,@Remark"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), 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("@FreeDays", SqlDbType.Int, 4), new SqlParameter("@Remark", SqlDbType.VarChar, 254) }; parameters[0].Value = model.Id; parameters[1].Value = model.CustomerId; parameters[2].Value = model.Status; parameters[3].Value = model.CreateTime; parameters[4].Value = model.BeginChargingTime; parameters[5].Value = model.ChargingTime; parameters[6].Value = model.Admin; parameters[7].Value = model.ChargingCount; parameters[8].Value = model.InspectionNumber; parameters[9].Value = model.AccountNumber; parameters[10].Value = model.SuttleWeight; parameters[11].Value = model.FreeDays; parameters[12].Value = model.Remark; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.StoreInOrder GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, CustomerId, Status, CreateTime, BeginChargingTime, ChargingTime, Admin, ChargingCount, InspectionNumber, AccountNumber, SuttleWeight, Remark "); strSql.Append(" from StoreInOrder "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) }; parameters[0].Value = Id; DTcms.Model.StoreInOrder model = new DTcms.Model.StoreInOrder(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["CustomerId"].ToString() != "") { model.CustomerId = int.Parse(ds.Tables[0].Rows[0]["CustomerId"].ToString()); } if (ds.Tables[0].Rows[0]["Status"].ToString() != "") { model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString()); } if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString()); } if (ds.Tables[0].Rows[0]["BeginChargingTime"].ToString() != "") { model.BeginChargingTime = DateTime.Parse(ds.Tables[0].Rows[0]["BeginChargingTime"].ToString()); } if (ds.Tables[0].Rows[0]["ChargingTime"].ToString() != "") { model.ChargingTime = DateTime.Parse(ds.Tables[0].Rows[0]["ChargingTime"].ToString()); } model.Admin = ds.Tables[0].Rows[0]["Admin"].ToString(); if (ds.Tables[0].Rows[0]["ChargingCount"].ToString() != "") { model.ChargingCount = decimal.Parse(ds.Tables[0].Rows[0]["ChargingCount"].ToString()); } model.InspectionNumber = ds.Tables[0].Rows[0]["InspectionNumber"].ToString(); model.AccountNumber = ds.Tables[0].Rows[0]["AccountNumber"].ToString(); if (ds.Tables[0].Rows[0]["SuttleWeight"].ToString() != "") { model.SuttleWeight = decimal.Parse(ds.Tables[0].Rows[0]["SuttleWeight"].ToString()); } model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); return model; } else { return null; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DTcms.Model.StoreInOrder model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update StoreInOrder set "); strSql.Append(" Id = @Id , "); strSql.Append(" CustomerId = @CustomerId , "); strSql.Append(" Status = @Status , "); strSql.Append(" CreateTime = @CreateTime , "); 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(" FreeDays = @FreeDays , "); strSql.Append(" Remark = @Remark "); strSql.Append(" where Id=@Id and CustomerId=@CustomerId "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), 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("@FreeDays", SqlDbType.Int, 4), new SqlParameter("@Remark", SqlDbType.VarChar, 254) }; parameters[0].Value = model.Id; parameters[1].Value = model.CustomerId; parameters[2].Value = model.Status; parameters[3].Value = model.CreateTime; parameters[4].Value = model.BeginChargingTime; parameters[5].Value = model.ChargingTime; parameters[6].Value = model.Admin; parameters[7].Value = model.ChargingCount; parameters[8].Value = model.InspectionNumber; parameters[9].Value = model.AccountNumber; parameters[10].Value = model.SuttleWeight; parameters[11].Value = model.FreeDays; parameters[12].Value = model.Remark; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.StoreInOrder GetModel(int Id, int CustomerId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, CustomerId, Status, CreateTime, BeginChargingTime, ChargingTime, Admin, ChargingCount, InspectionNumber, AccountNumber, SuttleWeight, FreeDays, Remark "); strSql.Append(" from StoreInOrder "); strSql.Append(" where Id=@Id and CustomerId=@CustomerId "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@CustomerId", SqlDbType.Int, 4) }; parameters[0].Value = Id; parameters[1].Value = CustomerId; DTcms.Model.StoreInOrder model = new DTcms.Model.StoreInOrder(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["CustomerId"].ToString() != "") { model.CustomerId = int.Parse(ds.Tables[0].Rows[0]["CustomerId"].ToString()); } if (ds.Tables[0].Rows[0]["Status"].ToString() != "") { model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString()); } if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString()); } if (ds.Tables[0].Rows[0]["BeginChargingTime"].ToString() != "") { model.BeginChargingTime = DateTime.Parse(ds.Tables[0].Rows[0]["BeginChargingTime"].ToString()); } if (ds.Tables[0].Rows[0]["ChargingTime"].ToString() != "") { model.ChargingTime = DateTime.Parse(ds.Tables[0].Rows[0]["ChargingTime"].ToString()); } model.Admin = ds.Tables[0].Rows[0]["Admin"].ToString(); if (ds.Tables[0].Rows[0]["ChargingCount"].ToString() != "") { model.ChargingCount = decimal.Parse(ds.Tables[0].Rows[0]["ChargingCount"].ToString()); } model.InspectionNumber = ds.Tables[0].Rows[0]["InspectionNumber"].ToString(); model.AccountNumber = ds.Tables[0].Rows[0]["AccountNumber"].ToString(); if (ds.Tables[0].Rows[0]["SuttleWeight"].ToString() != "") { model.SuttleWeight = decimal.Parse(ds.Tables[0].Rows[0]["SuttleWeight"].ToString()); } if (ds.Tables[0].Rows[0]["FreeDays"].ToString() != "") { model.FreeDays = int.Parse(ds.Tables[0].Rows[0]["FreeDays"].ToString()); } model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); return(model); } else { return(null); } }
/// <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); }