/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.T_Batch_Plan model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_Batch_Plan set "); strSql.Append("batchId=@batchId,"); strSql.Append("planId=@planId,"); strSql.Append("consArea=@consArea,"); strSql.Append("agriArea=@agriArea,"); strSql.Append("arabArea=@arabArea,"); strSql.Append("issuedQuota=@issuedQuota,"); strSql.Append("createTime=@createTime,"); strSql.Append("isSubmited=@isSubmited,"); strSql.Append("isDeleted=@isDeleted"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@batchId", SqlDbType.Int, 4), new SqlParameter("@planId", SqlDbType.Int, 4), new SqlParameter("@consArea", SqlDbType.Decimal, 9), new SqlParameter("@agriArea", SqlDbType.Decimal, 9), new SqlParameter("@arabArea", SqlDbType.Decimal, 9), new SqlParameter("@issuedQuota", SqlDbType.Decimal, 9), new SqlParameter("@createTime", SqlDbType.DateTime), new SqlParameter("@isSubmited", SqlDbType.Int, 4), new SqlParameter("@isDeleted", SqlDbType.Int, 4), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.batchId; parameters[1].Value = model.planId; parameters[2].Value = model.consArea; parameters[3].Value = model.agriArea; parameters[4].Value = model.arabArea; parameters[5].Value = model.issuedQuota; parameters[6].Value = model.createTime; parameters[7].Value = model.isSubmited; parameters[8].Value = model.isDeleted; parameters[9].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.T_Batch_Plan DataRowToModel(DataRow row) { Maticsoft.Model.T_Batch_Plan model = new Maticsoft.Model.T_Batch_Plan(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["batchId"] != null && row["batchId"].ToString() != "") { model.batchId = int.Parse(row["batchId"].ToString()); } if (row["planId"] != null && row["planId"].ToString() != "") { model.planId = int.Parse(row["planId"].ToString()); } if (row["consArea"] != null && row["consArea"].ToString() != "") { model.consArea = decimal.Parse(row["consArea"].ToString()); } if (row["agriArea"] != null && row["agriArea"].ToString() != "") { model.agriArea = decimal.Parse(row["agriArea"].ToString()); } if (row["arabArea"] != null && row["arabArea"].ToString() != "") { model.arabArea = decimal.Parse(row["arabArea"].ToString()); } if (row["issuedQuota"] != null && row["issuedQuota"].ToString() != "") { model.issuedQuota = decimal.Parse(row["issuedQuota"].ToString()); } if (row["createTime"] != null && row["createTime"].ToString() != "") { model.createTime = DateTime.Parse(row["createTime"].ToString()); } if (row["isSubmited"] != null && row["isSubmited"].ToString() != "") { model.isSubmited = int.Parse(row["isSubmited"].ToString()); } if (row["isDeleted"] != null && row["isDeleted"].ToString() != "") { model.isDeleted = int.Parse(row["isDeleted"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.T_Batch_Plan DataRowToModel(DataRow row) { Maticsoft.Model.T_Batch_Plan model = new Maticsoft.Model.T_Batch_Plan(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["batchId"] != null && row["batchId"].ToString() != "") { model.batchId = int.Parse(row["batchId"].ToString()); } if (row["planId"] != null && row["planId"].ToString() != "") { model.planId = int.Parse(row["planId"].ToString()); } if (row["consArea"] != null && row["consArea"].ToString() != "") { model.consArea = decimal.Parse(row["consArea"].ToString()); } if (row["agriArea"] != null && row["agriArea"].ToString() != "") { model.agriArea = decimal.Parse(row["agriArea"].ToString()); } if (row["arabArea"] != null && row["arabArea"].ToString() != "") { model.arabArea = decimal.Parse(row["arabArea"].ToString()); } if (row["issuedQuota"] != null && row["issuedQuota"].ToString() != "") { model.issuedQuota = decimal.Parse(row["issuedQuota"].ToString()); } if (row["createTime"] != null && row["createTime"].ToString() != "") { model.createTime = DateTime.Parse(row["createTime"].ToString()); } if (row["isSubmited"] != null && row["isSubmited"].ToString() != "") { model.isSubmited = int.Parse(row["isSubmited"].ToString()); } if (row["isDeleted"] != null && row["isDeleted"].ToString() != "") { model.isDeleted = int.Parse(row["isDeleted"].ToString()); } } return model; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.T_Batch_Plan model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_Batch_Plan("); strSql.Append("batchId,planId,consArea,agriArea,arabArea,issuedQuota,createTime,isSubmited,isDeleted)"); strSql.Append(" values ("); strSql.Append("@batchId,@planId,@consArea,@agriArea,@arabArea,@issuedQuota,@createTime,@isSubmited,@isDeleted)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@batchId", SqlDbType.Int, 4), new SqlParameter("@planId", SqlDbType.Int, 4), new SqlParameter("@consArea", SqlDbType.Decimal, 9), new SqlParameter("@agriArea", SqlDbType.Decimal, 9), new SqlParameter("@arabArea", SqlDbType.Decimal, 9), new SqlParameter("@issuedQuota", SqlDbType.Decimal, 9), new SqlParameter("@createTime", SqlDbType.DateTime), new SqlParameter("@isSubmited", SqlDbType.Int, 4), new SqlParameter("@isDeleted", SqlDbType.Int, 4) }; parameters[0].Value = model.batchId; parameters[1].Value = model.planId; parameters[2].Value = model.consArea; parameters[3].Value = model.agriArea; parameters[4].Value = model.arabArea; parameters[5].Value = model.issuedQuota; parameters[6].Value = model.createTime; parameters[7].Value = model.isSubmited; parameters[8].Value = model.isDeleted; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.T_Batch_Plan GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from T_Batch_Plan "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Maticsoft.Model.T_Batch_Plan model = new Maticsoft.Model.T_Batch_Plan(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.T_Batch_Plan GetModel(int id) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 * from T_Batch_Plan "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4) }; parameters[0].Value = id; Maticsoft.Model.T_Batch_Plan model=new Maticsoft.Model.T_Batch_Plan(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }