Exemplo n.º 1
0
        public bool Update(Rain.Model.user_attach_log model)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("update " + this.databaseprefix + "user_attach_log set ");
            stringBuilder.Append("user_id=@user_id,");
            stringBuilder.Append("user_name=@user_name,");
            stringBuilder.Append("attach_id=@attach_id,");
            stringBuilder.Append("file_name=@file_name,");
            stringBuilder.Append("add_time=@add_time");
            stringBuilder.Append(" where id=@id");
            OleDbParameter[] oleDbParameterArray = new OleDbParameter[6]
            {
                new OleDbParameter("@user_id", OleDbType.Integer, 4),
                new OleDbParameter("@user_name", OleDbType.VarChar, 100),
                new OleDbParameter("@attach_id", OleDbType.Integer, 4),
                new OleDbParameter("@file_name", OleDbType.VarChar, (int)byte.MaxValue),
                new OleDbParameter("@add_time", OleDbType.Date),
                new OleDbParameter("@id", OleDbType.Integer, 4)
            };
            oleDbParameterArray[0].Value = (object)model.user_id;
            oleDbParameterArray[1].Value = (object)model.user_name;
            oleDbParameterArray[2].Value = (object)model.attach_id;
            oleDbParameterArray[3].Value = (object)model.file_name;
            oleDbParameterArray[4].Value = (object)model.add_time;
            oleDbParameterArray[5].Value = (object)model.id;
            return(DbHelperOleDb.ExecuteSql(stringBuilder.ToString(), oleDbParameterArray) > 0);
        }
Exemplo n.º 2
0
 public Rain.Model.user_attach_log DataRowToModel(DataRow row)
 {
     Rain.Model.user_attach_log userAttachLog = new Rain.Model.user_attach_log();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             userAttachLog.id = int.Parse(row["id"].ToString());
         }
         if (row["user_id"] != null && row["user_id"].ToString() != "")
         {
             userAttachLog.user_id = int.Parse(row["user_id"].ToString());
         }
         if (row["user_name"] != null)
         {
             userAttachLog.user_name = row["user_name"].ToString();
         }
         if (row["attach_id"] != null && row["attach_id"].ToString() != "")
         {
             userAttachLog.attach_id = int.Parse(row["attach_id"].ToString());
         }
         if (row["file_name"] != null)
         {
             userAttachLog.file_name = row["file_name"].ToString();
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             userAttachLog.add_time = DateTime.Parse(row["add_time"].ToString());
         }
     }
     return(userAttachLog);
 }
Exemplo n.º 3
0
        public int AddLog(Rain.Model.user_attach_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 + "user_attach_log(");
                        stringBuilder.Append("user_id,user_name,attach_id,file_name,add_time)");
                        stringBuilder.Append(" values (");
                        stringBuilder.Append("@user_id,@user_name,@attach_id,@file_name,@add_time)");
                        OleDbParameter[] oleDbParameterArray = new OleDbParameter[5]
                        {
                            new OleDbParameter("@user_id", OleDbType.Integer, 4),
                            new OleDbParameter("@user_name", OleDbType.VarChar, 100),
                            new OleDbParameter("@attach_id", OleDbType.Integer, 4),
                            new OleDbParameter("@file_name", OleDbType.VarChar, (int)byte.MaxValue),
                            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.attach_id;
                        oleDbParameterArray[3].Value = (object)model.file_name;
                        oleDbParameterArray[4].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);
        }
Exemplo n.º 4
0
 public bool Update(Rain.Model.user_attach_log model)
 {
     return(this.dal.Update(model));
 }
Exemplo n.º 5
0
 public int Add(Rain.Model.user_attach_log model)
 {
     return(this.dal.Add(model));
 }