/// <summary> /// 增加一条数据 /// </summary> public void Add(DTcms.Model.AllotGoods model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AllotGoods("); strSql.Append("AllotOrderId,Id,StoreInOrderId,GoodsId,StoreInGoodsStoreInOrderId,StoreInGoodsId,Remark,Count,Status"); strSql.Append(") values ("); strSql.Append("@AllotOrderId,@Id,@StoreInOrderId,@GoodsId,@StoreInGoodsStoreInOrderId,@StoreInGoodsId,@Remark,@Count,@Status"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@AllotOrderId", SqlDbType.Int, 4), new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@StoreInOrderId", SqlDbType.Int, 4), new SqlParameter("@GoodsId", SqlDbType.Int, 4), new SqlParameter("@StoreInGoodsStoreInOrderId", 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) }; parameters[0].Value = model.AllotOrderId; parameters[1].Value = model.Id; parameters[2].Value = model.StoreInOrderId; parameters[3].Value = model.GoodsId; parameters[4].Value = model.StoreInGoodsStoreInOrderId; parameters[5].Value = model.StoreInGoodsId; parameters[6].Value = model.Remark; parameters[7].Value = model.Count; parameters[8].Value = model.Status; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
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)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.AllotGoods GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, AllotOrderId, StoreInOrderId, StoreInGoodsStoreInOrderId, StoreInGoodsId, Remark, Count, Status "); strSql.Append(" from AllotGoods "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; DTcms.Model.AllotGoods model = new DTcms.Model.AllotGoods(); 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]["AllotOrderId"].ToString() != "") { model.AllotOrderId = int.Parse(ds.Tables[0].Rows[0]["AllotOrderId"].ToString()); } if (ds.Tables[0].Rows[0]["StoreInOrderId"].ToString() != "") { model.StoreInOrderId = int.Parse(ds.Tables[0].Rows[0]["StoreInOrderId"].ToString()); } if (ds.Tables[0].Rows[0]["StoreInGoodsId"].ToString() != "") { model.StoreInGoodsId = int.Parse(ds.Tables[0].Rows[0]["StoreInGoodsId"].ToString()); } model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); if (ds.Tables[0].Rows[0]["Count"].ToString() != "") { model.Count = decimal.Parse(ds.Tables[0].Rows[0]["Count"].ToString()); } if (ds.Tables[0].Rows[0]["Status"].ToString() != "") { model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DTcms.Model.AllotGoods model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update AllotGoods set "); strSql.Append(" AllotOrderId = @AllotOrderId , "); strSql.Append(" Id = @Id , "); strSql.Append(" StoreInOrderId = @StoreInOrderId , "); strSql.Append(" GoodsId = @GoodsId , "); strSql.Append(" StoreInGoodsStoreInOrderId = @StoreInGoodsStoreInOrderId , "); strSql.Append(" StoreInGoodsId = @StoreInGoodsId , "); strSql.Append(" Remark = @Remark , "); strSql.Append(" Count = @Count , "); strSql.Append(" Status = @Status "); strSql.Append(" where AllotOrderId=@AllotOrderId and Id=@Id and StoreInOrderId=@StoreInOrderId and GoodsId=@GoodsId and StoreInGoodsStoreInOrderId=@StoreInGoodsStoreInOrderId and StoreInGoodsId=@StoreInGoodsId "); SqlParameter[] parameters = { new SqlParameter("@AllotOrderId", SqlDbType.Int, 4), new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@StoreInOrderId", SqlDbType.Int, 4), new SqlParameter("@GoodsId", SqlDbType.Int, 4), new SqlParameter("@StoreInGoodsStoreInOrderId", 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) }; parameters[0].Value = model.AllotOrderId; parameters[1].Value = model.Id; parameters[2].Value = model.StoreInOrderId; parameters[3].Value = model.GoodsId; parameters[4].Value = model.StoreInGoodsStoreInOrderId; parameters[5].Value = model.StoreInGoodsId; parameters[6].Value = model.Remark; parameters[7].Value = model.Count; parameters[8].Value = model.Status; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(DTcms.Model.AllotGoods model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AllotGoods("); strSql.Append("AllotOrderId,StoreInOrderId,StoreInGoodsId,Remark,Count,Status"); strSql.Append(") values ("); strSql.Append("@AllotOrderId,@StoreInOrderId,@StoreInGoodsId,@Remark,@Count,@Status"); 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) }; 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; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DTcms.Model.AllotGoods GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, AllotOrderId, StoreInOrderId, StoreInGoodsStoreInOrderId, StoreInGoodsId, Remark, Count, Status "); strSql.Append(" from AllotGoods "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) }; parameters[0].Value = Id; DTcms.Model.AllotGoods model = new DTcms.Model.AllotGoods(); 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]["AllotOrderId"].ToString() != "") { model.AllotOrderId = int.Parse(ds.Tables[0].Rows[0]["AllotOrderId"].ToString()); } if (ds.Tables[0].Rows[0]["StoreInOrderId"].ToString() != "") { model.StoreInOrderId = int.Parse(ds.Tables[0].Rows[0]["StoreInOrderId"].ToString()); } if (ds.Tables[0].Rows[0]["StoreInGoodsId"].ToString() != "") { model.StoreInGoodsId = int.Parse(ds.Tables[0].Rows[0]["StoreInGoodsId"].ToString()); } model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); if (ds.Tables[0].Rows[0]["Count"].ToString() != "") { model.Count = decimal.Parse(ds.Tables[0].Rows[0]["Count"].ToString()); } if (ds.Tables[0].Rows[0]["Status"].ToString() != "") { model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString()); } return model; } else { return null; } }