Exemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Bsam.Core.Model.Models.Model.UserRole DataRowToModel(DataRow row)
 {
     Bsam.Core.Model.Models.Model.UserRole model = new Bsam.Core.Model.Models.Model.UserRole();
     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["UserId"] != null && row["UserId"].ToString() != "")
         {
             model.UserId = int.Parse(row["UserId"].ToString());
         }
         if (row["RoleId"] != null && row["RoleId"].ToString() != "")
         {
             model.RoleId = int.Parse(row["RoleId"].ToString());
         }
         if (row["CreateId"] != null && row["CreateId"].ToString() != "")
         {
             model.CreateId = int.Parse(row["CreateId"].ToString());
         }
         if (row["CreateBy"] != null)
         {
             model.CreateBy = row["CreateBy"].ToString();
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
         if (row["ModifyId"] != null && row["ModifyId"].ToString() != "")
         {
             model.ModifyId = int.Parse(row["ModifyId"].ToString());
         }
         if (row["ModifyBy"] != null)
         {
             model.ModifyBy = row["ModifyBy"].ToString();
         }
         if (row["ModifyTime"] != null && row["ModifyTime"].ToString() != "")
         {
             model.ModifyTime = DateTime.Parse(row["ModifyTime"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Bsam.Core.Model.Models.Model.UserRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UserRole set ");
            strSql.Append("IsDeleted=@IsDeleted,");
            strSql.Append("UserId=@UserId,");
            strSql.Append("RoleId=@RoleId,");
            strSql.Append("CreateId=@CreateId,");
            strSql.Append("CreateBy=@CreateBy,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("ModifyId=@ModifyId,");
            strSql.Append("ModifyBy=@ModifyBy,");
            strSql.Append("ModifyTime=@ModifyTime");
            strSql.Append(" where Id=@Id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@IsDeleted",  DbType.bit,       1),
                new SQLiteParameter("@UserId",     DbType.Int32,     8),
                new SQLiteParameter("@RoleId",     DbType.Int32,     8),
                new SQLiteParameter("@CreateId",   DbType.Int32,     8),
                new SQLiteParameter("@CreateBy",   DbType.String),
                new SQLiteParameter("@CreateTime", DbType.DateTime),
                new SQLiteParameter("@ModifyId",   DbType.Int32,     8),
                new SQLiteParameter("@ModifyBy",   DbType.String),
                new SQLiteParameter("@ModifyTime", DbType.DateTime),
                new SQLiteParameter("@Id",         DbType.Int32, 8)
            };
            parameters[0].Value = model.IsDeleted;
            parameters[1].Value = model.UserId;
            parameters[2].Value = model.RoleId;
            parameters[3].Value = model.CreateId;
            parameters[4].Value = model.CreateBy;
            parameters[5].Value = model.CreateTime;
            parameters[6].Value = model.ModifyId;
            parameters[7].Value = model.ModifyBy;
            parameters[8].Value = model.ModifyTime;
            parameters[9].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 private void ShowInfo(int Id)
 {
     Bsam.Core.Model.Models.BLL.UserRole   bll   = new Bsam.Core.Model.Models.BLL.UserRole();
     Bsam.Core.Model.Models.Model.UserRole model = bll.GetModel(Id);
     this.lblId.Text           = model.Id.ToString();
     this.chkIsDeleted.Checked = model.IsDeleted;
     this.txtUserId.Text       = model.UserId.ToString();
     this.txtRoleId.Text       = model.RoleId.ToString();
     this.txtCreateId.Text     = model.CreateId.ToString();
     this.txtCreateBy.Text     = model.CreateBy;
     this.txtCreateTime.Text   = model.CreateTime.ToString();
     this.txtModifyId.Text     = model.ModifyId.ToString();
     this.txtModifyBy.Text     = model.ModifyBy;
     this.txtModifyTime.Text   = model.ModifyTime.ToString();
 }
Exemplo n.º 4
0
 private void ShowInfo(int Id)
 {
     Bsam.Core.Model.Models.BLL.UserRole   bll   = new Bsam.Core.Model.Models.BLL.UserRole();
     Bsam.Core.Model.Models.Model.UserRole model = bll.GetModel(Id);
     this.lblId.Text         = model.Id.ToString();
     this.lblIsDeleted.Text  = model.IsDeleted?"是":"否";
     this.lblUserId.Text     = model.UserId.ToString();
     this.lblRoleId.Text     = model.RoleId.ToString();
     this.lblCreateId.Text   = model.CreateId.ToString();
     this.lblCreateBy.Text   = model.CreateBy;
     this.lblCreateTime.Text = model.CreateTime.ToString();
     this.lblModifyId.Text   = model.ModifyId.ToString();
     this.lblModifyBy.Text   = model.ModifyBy;
     this.lblModifyTime.Text = model.ModifyTime.ToString();
 }
Exemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Bsam.Core.Model.Models.Model.UserRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UserRole(");
            strSql.Append("IsDeleted,UserId,RoleId,CreateId,CreateBy,CreateTime,ModifyId,ModifyBy,ModifyTime)");
            strSql.Append(" values (");
            strSql.Append("@IsDeleted,@UserId,@RoleId,@CreateId,@CreateBy,@CreateTime,@ModifyId,@ModifyBy,@ModifyTime)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@IsDeleted",  DbType.bit,       1),
                new SQLiteParameter("@UserId",     DbType.Int32,     8),
                new SQLiteParameter("@RoleId",     DbType.Int32,     8),
                new SQLiteParameter("@CreateId",   DbType.Int32,     8),
                new SQLiteParameter("@CreateBy",   DbType.String),
                new SQLiteParameter("@CreateTime", DbType.DateTime),
                new SQLiteParameter("@ModifyId",   DbType.Int32,     8),
                new SQLiteParameter("@ModifyBy",   DbType.String),
                new SQLiteParameter("@ModifyTime", DbType.DateTime)
            };
            parameters[0].Value = model.IsDeleted;
            parameters[1].Value = model.UserId;
            parameters[2].Value = model.RoleId;
            parameters[3].Value = model.CreateId;
            parameters[4].Value = model.CreateBy;
            parameters[5].Value = model.CreateTime;
            parameters[6].Value = model.ModifyId;
            parameters[7].Value = model.ModifyBy;
            parameters[8].Value = model.ModifyTime;

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

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

            strSql.Append("select Id,IsDeleted,UserId,RoleId,CreateId,CreateBy,CreateTime,ModifyId,ModifyBy,ModifyTime from UserRole ");
            strSql.Append(" where Id=@Id");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@Id", DbType.Int32, 4)
            };
            parameters[0].Value = Id;

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

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

            if (!PageValidate.IsNumber(txtUserId.Text))
            {
                strErr += "UserId格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtRoleId.Text))
            {
                strErr += "RoleId格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtCreateId.Text))
            {
                strErr += "CreateId格式错误!\\n";
            }
            if (this.txtCreateBy.Text.Trim().Length == 0)
            {
                strErr += "CreateBy不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtCreateTime.Text))
            {
                strErr += "CreateTime格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtModifyId.Text))
            {
                strErr += "ModifyId格式错误!\\n";
            }
            if (this.txtModifyBy.Text.Trim().Length == 0)
            {
                strErr += "ModifyBy不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtModifyTime.Text))
            {
                strErr += "ModifyTime格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      Id         = int.Parse(this.lblId.Text);
            bool     IsDeleted  = this.chkIsDeleted.Checked;
            int      UserId     = int.Parse(this.txtUserId.Text);
            int      RoleId     = int.Parse(this.txtRoleId.Text);
            int      CreateId   = int.Parse(this.txtCreateId.Text);
            string   CreateBy   = this.txtCreateBy.Text;
            DateTime CreateTime = DateTime.Parse(this.txtCreateTime.Text);
            int      ModifyId   = int.Parse(this.txtModifyId.Text);
            string   ModifyBy   = this.txtModifyBy.Text;
            DateTime ModifyTime = DateTime.Parse(this.txtModifyTime.Text);


            Bsam.Core.Model.Models.Model.UserRole model = new Bsam.Core.Model.Models.Model.UserRole();
            model.Id         = Id;
            model.IsDeleted  = IsDeleted;
            model.UserId     = UserId;
            model.RoleId     = RoleId;
            model.CreateId   = CreateId;
            model.CreateBy   = CreateBy;
            model.CreateTime = CreateTime;
            model.ModifyId   = ModifyId;
            model.ModifyBy   = ModifyBy;
            model.ModifyTime = ModifyTime;

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