Example #1
0
        public int Add(Rain.Model.manager_log model)
        {
            int maxId;

            using (OleDbConnection oleDbConnection = new OleDbConnection(DbHelperOleDb.connectionString))
            {
                oleDbConnection.Open();
                using (OleDbTransaction trans = oleDbConnection.BeginTransaction())
                {
                    try
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.Append("insert into " + this.databaseprefix + "manager_log(");
                        stringBuilder.Append("user_id,user_name,action_type,[remark],user_ip,add_time)");
                        stringBuilder.Append(" values (");
                        stringBuilder.Append("@user_id,@user_name,@action_type,@remark,@user_ip,@add_time)");
                        OleDbParameter[] oleDbParameterArray = new OleDbParameter[6]
                        {
                            new OleDbParameter("@user_id", OleDbType.Integer, 4),
                            new OleDbParameter("@user_name", OleDbType.VarChar, 100),
                            new OleDbParameter("@action_type", OleDbType.VarChar, 100),
                            new OleDbParameter("@remark", OleDbType.VarChar, (int)byte.MaxValue),
                            new OleDbParameter("@user_ip", OleDbType.VarChar, 30),
                            new OleDbParameter("@add_time", OleDbType.Date)
                        };
                        oleDbParameterArray[0].Value = (object)model.user_id;
                        oleDbParameterArray[1].Value = (object)model.user_name;
                        oleDbParameterArray[2].Value = (object)model.action_type;
                        oleDbParameterArray[3].Value = (object)model.remark;
                        oleDbParameterArray[4].Value = (object)model.user_ip;
                        oleDbParameterArray[5].Value = (object)model.add_time;
                        DbHelperOleDb.ExecuteSql(oleDbConnection, trans, stringBuilder.ToString(), oleDbParameterArray);
                        maxId = this.GetMaxId(oleDbConnection, trans);
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(-1);
                    }
                }
            }
            return(maxId);
        }
Example #2
0
        public Rain.Model.manager_log GetModel(int id)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("select  top 1 id,user_id,user_name,action_type,[remark],user_ip,add_time");
            stringBuilder.Append(" from " + this.databaseprefix + "manager_log ");
            stringBuilder.Append(" where id=@id");
            OleDbParameter[] oleDbParameterArray = new OleDbParameter[1]
            {
                new OleDbParameter("@id", OleDbType.Integer, 4)
            };
            oleDbParameterArray[0].Value = (object)id;
            Rain.Model.manager_log managerLog = new Rain.Model.manager_log();
            DataSet dataSet = DbHelperOleDb.Query(stringBuilder.ToString(), oleDbParameterArray);

            if (dataSet.Tables[0].Rows.Count > 0)
            {
                return(this.DataRowToModel(dataSet.Tables[0].Rows[0]));
            }
            return((Rain.Model.manager_log)null);
        }
Example #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (this.Page.IsPostBack)
     {
         return;
     }
     Rain.Model.manager adminInfo = this.GetAdminInfo();
     if (adminInfo != null)
     {
         Rain.BLL.manager_log   managerLog = new Rain.BLL.manager_log();
         Rain.Model.manager_log model1     = managerLog.GetModel(adminInfo.user_name, 1, DTEnums.ActionEnum.Login.ToString());
         if (model1 != null)
         {
             this.litIP.Text = model1.user_ip;
         }
         Rain.Model.manager_log model2 = managerLog.GetModel(adminInfo.user_name, 2, DTEnums.ActionEnum.Login.ToString());
         if (model2 != null)
         {
             this.litBackIP.Text   = model2.user_ip;
             this.litBackTime.Text = model2.add_time.ToString();
         }
     }
 }
Example #4
0
 public Rain.Model.manager_log DataRowToModel(DataRow row)
 {
     Rain.Model.manager_log managerLog = new Rain.Model.manager_log();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             managerLog.id = int.Parse(row["id"].ToString());
         }
         if (row["user_id"] != null && row["user_id"].ToString() != "")
         {
             managerLog.user_id = int.Parse(row["user_id"].ToString());
         }
         if (row["user_name"] != null)
         {
             managerLog.user_name = row["user_name"].ToString();
         }
         if (row["action_type"] != null)
         {
             managerLog.action_type = row["action_type"].ToString();
         }
         if (row["remark"] != null)
         {
             managerLog.remark = row["remark"].ToString();
         }
         if (row["user_ip"] != null)
         {
             managerLog.user_ip = row["user_ip"].ToString();
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             managerLog.add_time = DateTime.Parse(row["add_time"].ToString());
         }
     }
     return(managerLog);
 }
Example #5
0
 public int Add(Rain.Model.manager_log model)
 {
     return(this.dal.Add(model));
 }