예제 #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Bsam.Core.Model.Models.Model.OperateLog DataRowToModel(DataRow row)
 {
     Bsam.Core.Model.Models.Model.OperateLog model = new Bsam.Core.Model.Models.Model.OperateLog();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["IsDeleted"] != null && row["IsDeleted"].ToString() != "")
         {
             if ((row["IsDeleted"].ToString() == "1") || (row["IsDeleted"].ToString().ToLower() == "true"))
             {
                 model.IsDeleted = true;
             }
             else
             {
                 model.IsDeleted = false;
             }
         }
         if (row["Area"] != null)
         {
             model.Area = row["Area"].ToString();
         }
         if (row["Controller"] != null)
         {
             model.Controller = row["Controller"].ToString();
         }
         if (row["Action"] != null)
         {
             model.Action = row["Action"].ToString();
         }
         if (row["IPAddress"] != null)
         {
             model.IPAddress = row["IPAddress"].ToString();
         }
         if (row["Description"] != null)
         {
             model.Description = row["Description"].ToString();
         }
         if (row["LogTime"] != null && row["LogTime"].ToString() != "")
         {
             model.LogTime = DateTime.Parse(row["LogTime"].ToString());
         }
         if (row["LoginName"] != null)
         {
             model.LoginName = row["LoginName"].ToString();
         }
         if (row["UserId"] != null && row["UserId"].ToString() != "")
         {
             model.UserId = int.Parse(row["UserId"].ToString());
         }
     }
     return(model);
 }
예제 #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Bsam.Core.Model.Models.Model.OperateLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update OperateLog set ");
            strSql.Append("IsDeleted=@IsDeleted,");
            strSql.Append("Area=@Area,");
            strSql.Append("Controller=@Controller,");
            strSql.Append("Action=@Action,");
            strSql.Append("IPAddress=@IPAddress,");
            strSql.Append("Description=@Description,");
            strSql.Append("LogTime=@LogTime,");
            strSql.Append("LoginName=@LoginName,");
            strSql.Append("UserId=@UserId");
            strSql.Append(" where Id=@Id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@IsDeleted",   DbType.bit,       1),
                new SQLiteParameter("@Area",        DbType.String),
                new SQLiteParameter("@Controller",  DbType.String),
                new SQLiteParameter("@Action",      DbType.String),
                new SQLiteParameter("@IPAddress",   DbType.String),
                new SQLiteParameter("@Description", DbType.String),
                new SQLiteParameter("@LogTime",     DbType.DateTime),
                new SQLiteParameter("@LoginName",   DbType.String),
                new SQLiteParameter("@UserId",      DbType.Int32,     8),
                new SQLiteParameter("@Id",          DbType.Int32, 8)
            };
            parameters[0].Value = model.IsDeleted;
            parameters[1].Value = model.Area;
            parameters[2].Value = model.Controller;
            parameters[3].Value = model.Action;
            parameters[4].Value = model.IPAddress;
            parameters[5].Value = model.Description;
            parameters[6].Value = model.LogTime;
            parameters[7].Value = model.LoginName;
            parameters[8].Value = model.UserId;
            parameters[9].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
 private void ShowInfo(int Id)
 {
     Bsam.Core.Model.Models.BLL.OperateLog   bll   = new Bsam.Core.Model.Models.BLL.OperateLog();
     Bsam.Core.Model.Models.Model.OperateLog model = bll.GetModel(Id);
     this.lblId.Text           = model.Id.ToString();
     this.chkIsDeleted.Checked = model.IsDeleted;
     this.txtArea.Text         = model.Area;
     this.txtController.Text   = model.Controller;
     this.txtAction.Text       = model.Action;
     this.txtIPAddress.Text    = model.IPAddress;
     this.txtDescription.Text  = model.Description;
     this.txtLogTime.Text      = model.LogTime.ToString();
     this.txtLoginName.Text    = model.LoginName;
     this.txtUserId.Text       = model.UserId.ToString();
 }
예제 #4
0
 private void ShowInfo(int Id)
 {
     Bsam.Core.Model.Models.BLL.OperateLog   bll   = new Bsam.Core.Model.Models.BLL.OperateLog();
     Bsam.Core.Model.Models.Model.OperateLog model = bll.GetModel(Id);
     this.lblId.Text          = model.Id.ToString();
     this.lblIsDeleted.Text   = model.IsDeleted?"是":"否";
     this.lblArea.Text        = model.Area;
     this.lblController.Text  = model.Controller;
     this.lblAction.Text      = model.Action;
     this.lblIPAddress.Text   = model.IPAddress;
     this.lblDescription.Text = model.Description;
     this.lblLogTime.Text     = model.LogTime.ToString();
     this.lblLoginName.Text   = model.LoginName;
     this.lblUserId.Text      = model.UserId.ToString();
 }
예제 #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Bsam.Core.Model.Models.Model.OperateLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OperateLog(");
            strSql.Append("IsDeleted,Area,Controller,Action,IPAddress,Description,LogTime,LoginName,UserId)");
            strSql.Append(" values (");
            strSql.Append("@IsDeleted,@Area,@Controller,@Action,@IPAddress,@Description,@LogTime,@LoginName,@UserId)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@IsDeleted",   DbType.bit,       1),
                new SQLiteParameter("@Area",        DbType.String),
                new SQLiteParameter("@Controller",  DbType.String),
                new SQLiteParameter("@Action",      DbType.String),
                new SQLiteParameter("@IPAddress",   DbType.String),
                new SQLiteParameter("@Description", DbType.String),
                new SQLiteParameter("@LogTime",     DbType.DateTime),
                new SQLiteParameter("@LoginName",   DbType.String),
                new SQLiteParameter("@UserId",      DbType.Int32, 8)
            };
            parameters[0].Value = model.IsDeleted;
            parameters[1].Value = model.Area;
            parameters[2].Value = model.Controller;
            parameters[3].Value = model.Action;
            parameters[4].Value = model.IPAddress;
            parameters[5].Value = model.Description;
            parameters[6].Value = model.LogTime;
            parameters[7].Value = model.LoginName;
            parameters[8].Value = model.UserId;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Bsam.Core.Model.Models.Model.OperateLog GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id,IsDeleted,Area,Controller,Action,IPAddress,Description,LogTime,LoginName,UserId from OperateLog ");
            strSql.Append(" where Id=@Id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@Id", DbType.Int32, 4)
            };
            parameters[0].Value = Id;

            Bsam.Core.Model.Models.Model.OperateLog model = new Bsam.Core.Model.Models.Model.OperateLog();
            DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #7
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtArea.Text.Trim().Length == 0)
            {
                strErr += "Area不能为空!\\n";
            }
            if (this.txtController.Text.Trim().Length == 0)
            {
                strErr += "Controller不能为空!\\n";
            }
            if (this.txtAction.Text.Trim().Length == 0)
            {
                strErr += "Action不能为空!\\n";
            }
            if (this.txtIPAddress.Text.Trim().Length == 0)
            {
                strErr += "IPAddress不能为空!\\n";
            }
            if (this.txtDescription.Text.Trim().Length == 0)
            {
                strErr += "Description不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtLogTime.Text))
            {
                strErr += "LogTime格式错误!\\n";
            }
            if (this.txtLoginName.Text.Trim().Length == 0)
            {
                strErr += "LoginName不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtUserId.Text))
            {
                strErr += "UserId格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      Id          = int.Parse(this.lblId.Text);
            bool     IsDeleted   = this.chkIsDeleted.Checked;
            string   Area        = this.txtArea.Text;
            string   Controller  = this.txtController.Text;
            string   Action      = this.txtAction.Text;
            string   IPAddress   = this.txtIPAddress.Text;
            string   Description = this.txtDescription.Text;
            DateTime LogTime     = DateTime.Parse(this.txtLogTime.Text);
            string   LoginName   = this.txtLoginName.Text;
            int      UserId      = int.Parse(this.txtUserId.Text);


            Bsam.Core.Model.Models.Model.OperateLog model = new Bsam.Core.Model.Models.Model.OperateLog();
            model.Id          = Id;
            model.IsDeleted   = IsDeleted;
            model.Area        = Area;
            model.Controller  = Controller;
            model.Action      = Action;
            model.IPAddress   = IPAddress;
            model.Description = Description;
            model.LogTime     = LogTime;
            model.LoginName   = LoginName;
            model.UserId      = UserId;

            Bsam.Core.Model.Models.BLL.OperateLog bll = new Bsam.Core.Model.Models.BLL.OperateLog();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }