Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.ProductUnit model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProductUnit set ");
            strSql.Append("UnitName=@UnitName,");
            strSql.Append("Status=@Status,");
            strSql.Append("CreateUser=@CreateUser,");
            strSql.Append("CreateDate=@CreateDate,");
            strSql.Append("UpdateUser=@UpdateUser,");
            strSql.Append("UpdateDate=@UpdateDate");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UnitName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Status",     SqlDbType.Int,        4),
                new SqlParameter("@CreateUser", SqlDbType.BigInt,     8),
                new SqlParameter("@CreateDate", SqlDbType.DateTime),
                new SqlParameter("@UpdateUser", SqlDbType.BigInt,     8),
                new SqlParameter("@UpdateDate", SqlDbType.DateTime),
                new SqlParameter("@ID",         SqlDbType.BigInt, 8)
            };
            parameters[0].Value = model.UnitName;
            parameters[1].Value = model.Status;
            parameters[2].Value = model.CreateUser;
            parameters[3].Value = model.CreateDate;
            parameters[4].Value = model.UpdateUser;
            parameters[5].Value = model.UpdateDate;
            parameters[6].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.ProductUnit DataRowToModel(DataRow row)
 {
     Maticsoft.Model.ProductUnit model = new Maticsoft.Model.ProductUnit();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = long.Parse(row["ID"].ToString());
         }
         if (row["UnitName"] != null)
         {
             model.UnitName = row["UnitName"].ToString();
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = int.Parse(row["Status"].ToString());
         }
         if (row["CreateUser"] != null && row["CreateUser"].ToString() != "")
         {
             model.CreateUser = long.Parse(row["CreateUser"].ToString());
         }
         if (row["CreateDate"] != null && row["CreateDate"].ToString() != "")
         {
             model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
         }
         if (row["UpdateUser"] != null && row["UpdateUser"].ToString() != "")
         {
             model.UpdateUser = long.Parse(row["UpdateUser"].ToString());
         }
         if (row["UpdateDate"] != null && row["UpdateDate"].ToString() != "")
         {
             model.UpdateDate = DateTime.Parse(row["UpdateDate"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(Maticsoft.Model.ProductUnit model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProductUnit(");
            strSql.Append("UnitName,Status,CreateUser,CreateDate,UpdateUser,UpdateDate)");
            strSql.Append(" values (");
            strSql.Append("@UnitName,@Status,@CreateUser,@CreateDate,@UpdateUser,@UpdateDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UnitName",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Status",     SqlDbType.Int,        4),
                new SqlParameter("@CreateUser", SqlDbType.BigInt,     8),
                new SqlParameter("@CreateDate", SqlDbType.DateTime),
                new SqlParameter("@UpdateUser", SqlDbType.BigInt,     8),
                new SqlParameter("@UpdateDate", SqlDbType.DateTime)
            };
            parameters[0].Value = model.UnitName;
            parameters[1].Value = model.Status;
            parameters[2].Value = model.CreateUser;
            parameters[3].Value = model.CreateDate;
            parameters[4].Value = model.UpdateUser;
            parameters[5].Value = model.UpdateDate;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.ProductUnit GetModel(long ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,UnitName,Status,CreateUser,CreateDate,UpdateUser,UpdateDate from ProductUnit ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.BigInt)
            };
            parameters[0].Value = ID;

            Maticsoft.Model.ProductUnit model = new Maticsoft.Model.ProductUnit();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }