コード例 #1
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(ESMonitor.Model.Files model)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",       SqlDbType.Int,        4),
                new SqlParameter("@StatCode", SqlDbType.VarChar,   20),
                new SqlParameter("@CapTime",  SqlDbType.DateTime),
                new SqlParameter("@Type",     SqlDbType.TinyInt,    1),
                new SqlParameter("@FileName", SqlDbType.VarChar,   50),
                new SqlParameter("@Path",     SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.Id;
            parameters[1].Value = model.StatCode;
            parameters[2].Value = model.CapTime;
            parameters[3].Value = model.Type;
            parameters[4].Value = model.FileName;
            parameters[5].Value = model.Path;

            DbHelperSQL.RunProcedure("T_Files_Update", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ESMonitor.Model.Files DataRowToModel(DataRow row)
 {
     ESMonitor.Model.Files model = new ESMonitor.Model.Files();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["StatCode"] != null)
         {
             model.StatCode = row["StatCode"].ToString();
         }
         if (row["CapTime"] != null && row["CapTime"].ToString() != "")
         {
             model.CapTime = DateTime.Parse(row["CapTime"].ToString());
         }
         if (row["Type"] != null && row["Type"].ToString() != "")
         {
             model.Type = int.Parse(row["Type"].ToString());
         }
         if (row["FileName"] != null)
         {
             model.FileName = row["FileName"].ToString();
         }
         if (row["Path"] != null)
         {
             model.Path = row["Path"].ToString();
         }
     }
     return(model);
 }
コード例 #3
0
 private void ShowInfo(int Id)
 {
     ESMonitor.BLL.Files   bll   = new ESMonitor.BLL.Files();
     ESMonitor.Model.Files model = bll.GetModel(Id);
     this.lblId.Text       = model.Id.ToString();
     this.lblStatCode.Text = model.StatCode;
     this.lblCapTime.Text  = model.CapTime.ToString();
     this.lblType.Text     = model.Type.ToString();
     this.lblFileName.Text = model.FileName;
     this.lblPath.Text     = model.Path;
 }
コード例 #4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtStatCode.Text.Trim().Length == 0)
            {
                strErr += "StatCode不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtCapTime.Text))
            {
                strErr += "CapTime格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtType.Text))
            {
                strErr += "Type格式错误!\\n";
            }
            if (this.txtFileName.Text.Trim().Length == 0)
            {
                strErr += "FileName不能为空!\\n";
            }
            if (this.txtPath.Text.Trim().Length == 0)
            {
                strErr += "Path不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      Id       = int.Parse(this.lblId.Text);
            string   StatCode = this.txtStatCode.Text;
            DateTime CapTime  = DateTime.Parse(this.txtCapTime.Text);
            int      Type     = int.Parse(this.txtType.Text);
            string   FileName = this.txtFileName.Text;
            string   Path     = this.txtPath.Text;


            ESMonitor.Model.Files model = new ESMonitor.Model.Files();
            model.Id       = Id;
            model.StatCode = StatCode;
            model.CapTime  = CapTime;
            model.Type     = Type;
            model.FileName = FileName;
            model.Path     = Path;

            ESMonitor.BLL.Files bll = new ESMonitor.BLL.Files();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
コード例 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ESMonitor.Model.Files GetModel(int Id)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            ESMonitor.Model.Files model = new ESMonitor.Model.Files();
            DataSet ds = DbHelperSQL.RunProcedure("T_Files_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #6
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(ESMonitor.Model.Files model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",       SqlDbType.Int,        4),
                new SqlParameter("@StatCode", SqlDbType.VarChar,   20),
                new SqlParameter("@CapTime",  SqlDbType.DateTime),
                new SqlParameter("@Type",     SqlDbType.TinyInt,    1),
                new SqlParameter("@FileName", SqlDbType.VarChar,   50),
                new SqlParameter("@Path",     SqlDbType.VarChar, 50)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.StatCode;
            parameters[2].Value     = model.CapTime;
            parameters[3].Value     = model.Type;
            parameters[4].Value     = model.FileName;
            parameters[5].Value     = model.Path;

            DbHelperSQL.RunProcedure("T_Files_ADD", parameters, out rowsAffected);
            return((int)parameters[0].Value);
        }