Пример #1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsDateTime(txtErrorTime.Text))
            {
                strErr+="ErrorTime格式错误!\\n";
            }
            if(this.txtErrorMessage.Text.Trim().Length==0)
            {
                strErr+="ErrorMessage不能为空!\\n";
            }

            if(strErr!="")
            {
                MessageBox.Show(this,strErr);
                return;
            }
            int ID=int.Parse(this.lblID.Text);
            DateTime ErrorTime=DateTime.Parse(this.txtErrorTime.Text);
            string ErrorMessage=this.txtErrorMessage.Text;

            JiaJiao.Model.ErrorLog model=new JiaJiao.Model.ErrorLog();
            model.ID=ID;
            model.ErrorTime=ErrorTime;
            model.ErrorMessage=ErrorMessage;

            JiaJiao.BLL.ErrorLog bll=new JiaJiao.BLL.ErrorLog();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx");
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public JiaJiao.Model.ErrorLog DataRowToModel(DataRow row)
 {
     JiaJiao.Model.ErrorLog model=new JiaJiao.Model.ErrorLog();
     if (row != null)
     {
         if(row["ID"]!=null && row["ID"].ToString()!="")
         {
             model.ID=int.Parse(row["ID"].ToString());
         }
         if(row["ErrorTime"]!=null && row["ErrorTime"].ToString()!="")
         {
             model.ErrorTime=DateTime.Parse(row["ErrorTime"].ToString());
         }
         if(row["ErrorMessage"]!=null)
         {
             model.ErrorMessage=row["ErrorMessage"].ToString();
         }
     }
     return model;
 }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JiaJiao.Model.ErrorLog GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,ErrorTime,ErrorMessage from ErrorLog ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)
            };
            parameters[0].Value = ID;

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