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

            strSql.Append("update tb_JH_WorkCenterLoad set ");
            strSql.Append("WorkCenterNO=@WorkCenterNO,");
            strSql.Append("AllLoad=@AllLoad,");
            strSql.Append("Date=@Date");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@WorkCenterNO", SqlDbType.NVarChar,  64),
                new SqlParameter("@AllLoad",      SqlDbType.Decimal,    9),
                new SqlParameter("@Date",         SqlDbType.DateTime),
                new SqlParameter("@ID",           SqlDbType.NVarChar, 64)
            };
            parameters[0].Value = model.WorkCenterNO;
            parameters[1].Value = model.AllLoad;
            parameters[2].Value = model.Date;
            parameters[3].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Demo.Model.tb_JH_WorkCenterLoad model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_JH_WorkCenterLoad(");
            strSql.Append("ID,WorkCenterNO,AllLoad,Date)");
            strSql.Append(" values (");
            strSql.Append("@ID,@WorkCenterNO,@AllLoad,@Date)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",           SqlDbType.NVarChar, 64),
                new SqlParameter("@WorkCenterNO", SqlDbType.NVarChar, 64),
                new SqlParameter("@AllLoad",      SqlDbType.Decimal,   9),
                new SqlParameter("@Date",         SqlDbType.DateTime)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.WorkCenterNO;
            parameters[2].Value = model.AllLoad;
            parameters[3].Value = model.Date;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Demo.Model.tb_JH_WorkCenterLoad DataRowToModel(DataRow row)
 {
     Demo.Model.tb_JH_WorkCenterLoad model = new Demo.Model.tb_JH_WorkCenterLoad();
     if (row != null)
     {
         if (row["ID"] != null)
         {
             model.ID = row["ID"].ToString();
         }
         if (row["WorkCenterNO"] != null)
         {
             model.WorkCenterNO = row["WorkCenterNO"].ToString();
         }
         if (row["AllLoad"] != null && row["AllLoad"].ToString() != "")
         {
             model.AllLoad = decimal.Parse(row["AllLoad"].ToString());
         }
         if (row["Date"] != null && row["Date"].ToString() != "")
         {
             model.Date = DateTime.Parse(row["Date"].ToString());
         }
     }
     return(model);
 }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Demo.Model.tb_JH_WorkCenterLoad GetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,WorkCenterNO,AllLoad,Date from tb_JH_WorkCenterLoad ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.NVarChar, 64)
            };
            parameters[0].Value = ID;

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

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