Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.T_LandBlock model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_LandBlock set ");
            strSql.Append("no=@no,");
            strSql.Append("name=@name,");
            strSql.Append("batchId=@batchId,");
            strSql.Append("area=@area,");
            strSql.Append("userId=@userId,");
            strSql.Append("createTime=@createTime,");
            strSql.Append("isSubmited=@isSubmited,");
            strSql.Append("isDeleted=@isDeleted,");
            strSql.Append("des=@des");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@no",         SqlDbType.VarChar,   50),
                new SqlParameter("@name",       SqlDbType.VarChar,   50),
                new SqlParameter("@batchId",    SqlDbType.Int,        4),
                new SqlParameter("@area",       SqlDbType.Decimal,    9),
                new SqlParameter("@userId",     SqlDbType.Int,        4),
                new SqlParameter("@createTime", SqlDbType.DateTime),
                new SqlParameter("@isSubmited", SqlDbType.Int,        4),
                new SqlParameter("@isDeleted",  SqlDbType.Int,        4),
                new SqlParameter("@des",        SqlDbType.Text),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.no;
            parameters[1].Value = model.name;
            parameters[2].Value = model.batchId;
            parameters[3].Value = model.area;
            parameters[4].Value = model.userId;
            parameters[5].Value = model.createTime;
            parameters[6].Value = model.isSubmited;
            parameters[7].Value = model.isDeleted;
            parameters[8].Value = model.des;
            parameters[9].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.T_LandBlock DataRowToModel(DataRow row)
 {
     Maticsoft.Model.T_LandBlock model = new Maticsoft.Model.T_LandBlock();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["no"] != null)
         {
             model.no = row["no"].ToString();
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["batchId"] != null && row["batchId"].ToString() != "")
         {
             model.batchId = int.Parse(row["batchId"].ToString());
         }
         if (row["area"] != null && row["area"].ToString() != "")
         {
             model.area = decimal.Parse(row["area"].ToString());
         }
         if (row["userId"] != null && row["userId"].ToString() != "")
         {
             model.userId = int.Parse(row["userId"].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());
         }
         if (row["des"] != null)
         {
             model.des = row["des"].ToString();
         }
     }
     return(model);
 }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.T_LandBlock DataRowToModel(DataRow row)
 {
     Maticsoft.Model.T_LandBlock model=new Maticsoft.Model.T_LandBlock();
     if (row != null)
     {
         if(row["id"]!=null && row["id"].ToString()!="")
         {
             model.id=int.Parse(row["id"].ToString());
         }
         if(row["no"]!=null)
         {
             model.no=row["no"].ToString();
         }
         if(row["name"]!=null)
         {
             model.name=row["name"].ToString();
         }
         if(row["batchId"]!=null && row["batchId"].ToString()!="")
         {
             model.batchId=int.Parse(row["batchId"].ToString());
         }
         if(row["area"]!=null && row["area"].ToString()!="")
         {
             model.area=decimal.Parse(row["area"].ToString());
         }
         if(row["userId"]!=null && row["userId"].ToString()!="")
         {
             model.userId=int.Parse(row["userId"].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());
         }
         if(row["des"]!=null)
         {
             model.des=row["des"].ToString();
         }
     }
     return model;
 }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.T_LandBlock model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_LandBlock(");
            strSql.Append("no,name,batchId,area,userId,createTime,isSubmited,isDeleted,des)");
            strSql.Append(" values (");
            strSql.Append("@no,@name,@batchId,@area,@userId,@createTime,@isSubmited,@isDeleted,@des)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@no",         SqlDbType.VarChar,   50),
                new SqlParameter("@name",       SqlDbType.VarChar,   50),
                new SqlParameter("@batchId",    SqlDbType.Int,        4),
                new SqlParameter("@area",       SqlDbType.Decimal,    9),
                new SqlParameter("@userId",     SqlDbType.Int,        4),
                new SqlParameter("@createTime", SqlDbType.DateTime),
                new SqlParameter("@isSubmited", SqlDbType.Int,        4),
                new SqlParameter("@isDeleted",  SqlDbType.Int,        4),
                new SqlParameter("@des",        SqlDbType.Text)
            };
            parameters[0].Value = model.no;
            parameters[1].Value = model.name;
            parameters[2].Value = model.batchId;
            parameters[3].Value = model.area;
            parameters[4].Value = model.userId;
            parameters[5].Value = model.createTime;
            parameters[6].Value = model.isSubmited;
            parameters[7].Value = model.isDeleted;
            parameters[8].Value = model.des;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.T_LandBlock GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,no,name,batchId,area,userId,createTime,isSubmited,isDeleted,des from T_LandBlock ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Maticsoft.Model.T_LandBlock model = new Maticsoft.Model.T_LandBlock();
            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_LandBlock GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,no,name,batchId,area,userId,createTime,isSubmited,isDeleted,des from T_LandBlock ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            Maticsoft.Model.T_LandBlock model=new Maticsoft.Model.T_LandBlock();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }