Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MSCD.Model.EqptMaintain model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into b_EqptMaintain(");
            strSql.Append("SmId,LayerName,Name,Department,EqptName,RecordDate,MaintainDate,NextMaintainDate,MaintainType,Maintainer,Checker,Reason,Process,Result,CheckOpinion)");
            strSql.Append(" values (");
            strSql.Append("@SmId,@LayerName,@Name,@Department,@EqptName,@RecordDate,@MaintainDate,@NextMaintainDate,@MaintainType,@Maintainer,@Checker,@Reason,@Process,@Result,@CheckOpinion)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SmId",             SqlDbType.Int,       4),
                new SqlParameter("@LayerName",        SqlDbType.VarChar,  50),
                new SqlParameter("@Name",             SqlDbType.VarChar, 200),
                new SqlParameter("@Department",       SqlDbType.VarChar, 200),
                new SqlParameter("@EqptName",         SqlDbType.VarChar, 200),
                new SqlParameter("@RecordDate",       SqlDbType.Date,      3),
                new SqlParameter("@MaintainDate",     SqlDbType.Date,      3),
                new SqlParameter("@NextMaintainDate", SqlDbType.Date,      3),
                new SqlParameter("@MaintainType",     SqlDbType.Int,       4),
                new SqlParameter("@Maintainer",       SqlDbType.VarChar, 200),
                new SqlParameter("@Checker",          SqlDbType.VarChar, 200),
                new SqlParameter("@Reason",           SqlDbType.VarChar, 500),
                new SqlParameter("@Process",          SqlDbType.VarChar, 500),
                new SqlParameter("@Result",           SqlDbType.VarChar, 500),
                new SqlParameter("@CheckOpinion",     SqlDbType.VarChar, 500)
            };
            parameters[0].Value  = model.SmId;
            parameters[1].Value  = model.LayerName;
            parameters[2].Value  = model.Name;
            parameters[3].Value  = model.Department;
            parameters[4].Value  = model.EqptName;
            parameters[5].Value  = model.RecordDate;
            parameters[6].Value  = model.MaintainDate;
            parameters[7].Value  = model.NextMaintainDate;
            parameters[8].Value  = model.MaintainType;
            parameters[9].Value  = model.Maintainer;
            parameters[10].Value = model.Checker;
            parameters[11].Value = model.Reason;
            parameters[12].Value = model.Process;
            parameters[13].Value = model.Result;
            parameters[14].Value = model.CheckOpinion;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MSCD.Model.EqptMaintain GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,SmId,LayerName,Name,Department,EqptName,RecordDate,MaintainDate,NextMaintainDate,MaintainType,Maintainer,Checker,Reason,Process,Result,CheckOpinion from b_EqptMaintain ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MSCD.Model.EqptMaintain DataRowToModel(DataRow row)
 {
     MSCD.Model.EqptMaintain model = new MSCD.Model.EqptMaintain();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["SmId"] != null && row["SmId"].ToString() != "")
         {
             model.SmId = int.Parse(row["SmId"].ToString());
         }
         if (row["LayerName"] != null)
         {
             model.LayerName = row["LayerName"].ToString();
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Department"] != null)
         {
             model.Department = row["Department"].ToString();
         }
         if (row["EqptName"] != null)
         {
             model.EqptName = row["EqptName"].ToString();
         }
         if (row["RecordDate"] != null && row["RecordDate"].ToString() != "")
         {
             model.RecordDate = DateTime.Parse(row["RecordDate"].ToString());
         }
         if (row["MaintainDate"] != null && row["MaintainDate"].ToString() != "")
         {
             model.MaintainDate = DateTime.Parse(row["MaintainDate"].ToString());
         }
         if (row["NextMaintainDate"] != null && row["NextMaintainDate"].ToString() != "")
         {
             model.NextMaintainDate = DateTime.Parse(row["NextMaintainDate"].ToString());
         }
         if (row["MaintainType"] != null && row["MaintainType"].ToString() != "")
         {
             model.MaintainType = int.Parse(row["MaintainType"].ToString());
         }
         if (row["Maintainer"] != null)
         {
             model.Maintainer = row["Maintainer"].ToString();
         }
         if (row["Checker"] != null)
         {
             model.Checker = row["Checker"].ToString();
         }
         if (row["Reason"] != null)
         {
             model.Reason = row["Reason"].ToString();
         }
         if (row["Process"] != null)
         {
             model.Process = row["Process"].ToString();
         }
         if (row["Result"] != null)
         {
             model.Result = row["Result"].ToString();
         }
         if (row["CheckOpinion"] != null)
         {
             model.CheckOpinion = row["CheckOpinion"].ToString();
         }
     }
     return model;
 }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MSCD.Model.EqptMaintain GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,SmId,LayerName,Name,Department,EqptName,RecordDate,MaintainDate,NextMaintainDate,MaintainType,Maintainer,Checker,Reason,Process,Result,CheckOpinion from b_EqptMaintain ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

            MSCD.Model.EqptMaintain model = new MSCD.Model.EqptMaintain();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Пример #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(MSCD.Model.EqptMaintain model)
 {
     return(dal.Update(model));
 }
Пример #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(MSCD.Model.EqptMaintain model)
 {
     return(dal.Add(model));
 }
Пример #7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MSCD.Model.EqptMaintain model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update b_EqptMaintain set ");
            strSql.Append("SmId=@SmId,");
            strSql.Append("LayerName=@LayerName,");
            strSql.Append("Name=@Name,");
            strSql.Append("Department=@Department,");
            strSql.Append("EqptName=@EqptName,");
            strSql.Append("RecordDate=@RecordDate,");
            strSql.Append("MaintainDate=@MaintainDate,");
            strSql.Append("NextMaintainDate=@NextMaintainDate,");
            strSql.Append("MaintainType=@MaintainType,");
            strSql.Append("Maintainer=@Maintainer,");
            strSql.Append("Checker=@Checker,");
            strSql.Append("Reason=@Reason,");
            strSql.Append("Process=@Process,");
            strSql.Append("Result=@Result,");
            strSql.Append("CheckOpinion=@CheckOpinion");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SmId",             SqlDbType.Int,       4),
                new SqlParameter("@LayerName",        SqlDbType.VarChar,  50),
                new SqlParameter("@Name",             SqlDbType.VarChar, 200),
                new SqlParameter("@Department",       SqlDbType.VarChar, 200),
                new SqlParameter("@EqptName",         SqlDbType.VarChar, 200),
                new SqlParameter("@RecordDate",       SqlDbType.Date,      3),
                new SqlParameter("@MaintainDate",     SqlDbType.Date,      3),
                new SqlParameter("@NextMaintainDate", SqlDbType.Date,      3),
                new SqlParameter("@MaintainType",     SqlDbType.Int,       4),
                new SqlParameter("@Maintainer",       SqlDbType.VarChar, 200),
                new SqlParameter("@Checker",          SqlDbType.VarChar, 200),
                new SqlParameter("@Reason",           SqlDbType.VarChar, 500),
                new SqlParameter("@Process",          SqlDbType.VarChar, 500),
                new SqlParameter("@Result",           SqlDbType.VarChar, 500),
                new SqlParameter("@CheckOpinion",     SqlDbType.VarChar, 500),
                new SqlParameter("@Id",               SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.SmId;
            parameters[1].Value  = model.LayerName;
            parameters[2].Value  = model.Name;
            parameters[3].Value  = model.Department;
            parameters[4].Value  = model.EqptName;
            parameters[5].Value  = model.RecordDate;
            parameters[6].Value  = model.MaintainDate;
            parameters[7].Value  = model.NextMaintainDate;
            parameters[8].Value  = model.MaintainType;
            parameters[9].Value  = model.Maintainer;
            parameters[10].Value = model.Checker;
            parameters[11].Value = model.Reason;
            parameters[12].Value = model.Process;
            parameters[13].Value = model.Result;
            parameters[14].Value = model.CheckOpinion;
            parameters[15].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #8
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MSCD.Model.EqptMaintain DataRowToModel(DataRow row)
 {
     MSCD.Model.EqptMaintain model = new MSCD.Model.EqptMaintain();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["SmId"] != null && row["SmId"].ToString() != "")
         {
             model.SmId = int.Parse(row["SmId"].ToString());
         }
         if (row["LayerName"] != null)
         {
             model.LayerName = row["LayerName"].ToString();
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Department"] != null)
         {
             model.Department = row["Department"].ToString();
         }
         if (row["EqptName"] != null)
         {
             model.EqptName = row["EqptName"].ToString();
         }
         if (row["RecordDate"] != null && row["RecordDate"].ToString() != "")
         {
             model.RecordDate = DateTime.Parse(row["RecordDate"].ToString());
         }
         if (row["MaintainDate"] != null && row["MaintainDate"].ToString() != "")
         {
             model.MaintainDate = DateTime.Parse(row["MaintainDate"].ToString());
         }
         if (row["NextMaintainDate"] != null && row["NextMaintainDate"].ToString() != "")
         {
             model.NextMaintainDate = DateTime.Parse(row["NextMaintainDate"].ToString());
         }
         if (row["MaintainType"] != null && row["MaintainType"].ToString() != "")
         {
             model.MaintainType = int.Parse(row["MaintainType"].ToString());
         }
         if (row["Maintainer"] != null)
         {
             model.Maintainer = row["Maintainer"].ToString();
         }
         if (row["Checker"] != null)
         {
             model.Checker = row["Checker"].ToString();
         }
         if (row["Reason"] != null)
         {
             model.Reason = row["Reason"].ToString();
         }
         if (row["Process"] != null)
         {
             model.Process = row["Process"].ToString();
         }
         if (row["Result"] != null)
         {
             model.Result = row["Result"].ToString();
         }
         if (row["CheckOpinion"] != null)
         {
             model.CheckOpinion = row["CheckOpinion"].ToString();
         }
     }
     return(model);
 }