Beispiel #1
0
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="RoleObj"></param>
        /// <returns></returns>
        public bool Add(tblRole_User Role_UserObj)
        {
            Role_UserObj.ID = System.Guid.NewGuid();
            int counts = 0;
            //插入数据
            try
            {
                using (MWDatabaseEntities MWDB = new MWDatabaseEntities())
                {
                    MWDB.tblRole_User.AddObject(Role_UserObj);
                    counts = MWDB.SaveChanges();
                    if (counts > 0)
                    {
                        string userHostAddress = HttpContext.Current.Request.UserHostAddress;
                        DbLoggerBLL.SysLogger.Info("Increase user and role relationship successfully! User and role relationship ID: '"
                            + Role_UserObj.ID + "'. User host address: '" + userHostAddress + "' . ");
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                string userHostAddress = HttpContext.Current.Request.UserHostAddress;
                DbLoggerBLL.SysLogger.Error("Increase user and role relationship failed! User and role relationship ID: '"
                    + Role_UserObj.ID + "'. User host address: '" + userHostAddress + "' . Exception info:" + ex.Message);
                return false;
            }

            return false;
        }
        /// <summary>
        /// GridView 的UpdateCommand 事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridUser_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            GridEditableItem edittedItem = e.Item as GridEditableItem;
            //获取控件
            RadTextBox textUserName = edittedItem.FindControl("textUserName") as RadTextBox;
            RadTextBox textLoginName = edittedItem.FindControl("textLoginName") as RadTextBox;
            RadTextBox textUserCode = edittedItem.FindControl("textUserCode") as RadTextBox;
            RadTextBox textEmail = edittedItem.FindControl("textEmail") as RadTextBox;
            RadTextBox textDesc = edittedItem.FindControl("textDesc") as RadTextBox;
            RadComboBox ComBoxState = edittedItem.FindControl("ComBoxState") as RadComboBox;
            RadComboBox ComBoxRole = edittedItem.FindControl("ComBoxRole") as RadComboBox;

            //*************************************************给用户配置角色
            RoleUserBLL Role_UserBLLs = new RoleUserBLL();

            if (ComBoxRole.SelectedItem.Value != string.Empty)
            {
                //删除关系表
                Role_UserBLLs.Delete(this.strKeyID);
                tblRole_User tblRole_UserObj = new tblRole_User();
                System.Guid gUserID = new Guid(this.strKeyID);
                System.Guid gRoleID = new Guid(ComBoxRole.SelectedItem.Value);
                tblRole_UserObj.UserID = gUserID;
                tblRole_UserObj.RoleID = gRoleID;
                Role_UserBLLs.Add(tblRole_UserObj);

            }
            //*************************************************给用户配置角色
            //实例化Entity实体
            UserBLL UserBLLs = new UserBLL();
            tblUser UserObjs;
            UserObjs = UserBLLs.GetByID(this.strKeyID);
            UserObjs.UserName = textUserName.Text;
            UserObjs.LoginName = textLoginName.Text;

            UserObjs.UserCode = textUserCode.Text;
            if (ComBoxState.SelectedItem.Value == "True")
            {
                UserObjs.State = true;
            }
            else
            {
                UserObjs.State = false;
            }

            UserObjs.Email = textEmail.Text;
            UserObjs.Desc = textDesc.Text;

            UserBLLs.Update(UserObjs);
            this.GridViewData();
        }
Beispiel #3
0
 /// <summary>
 /// 用于向 tblRole_User EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddTotblRole_User(tblRole_User tblRole_User)
 {
     base.AddObject("tblRole_User", tblRole_User);
 }
        /// <summary>
        /// GridView的InsertCommand事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridUser_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            GridEditableItem edittedItem = e.Item.OwnerTableView.GetInsertItem();
            //获取控件
            RadTextBox textUserName = edittedItem.FindControl("textUserName") as RadTextBox;
            RadTextBox textLoginName = edittedItem.FindControl("textLoginName") as RadTextBox;
            RadTextBox textUserCode = edittedItem.FindControl("textUserCode") as RadTextBox;
            RadTextBox textEmail = edittedItem.FindControl("textEmail") as RadTextBox;
            RadTextBox textDesc = edittedItem.FindControl("textDesc") as RadTextBox;
            RadTextBox textLoginPwd = edittedItem.FindControl("textLoginPwd") as RadTextBox;

            RadComboBox ComBoxState = edittedItem.FindControl("ComBoxState") as RadComboBox;
            RadComboBox ComBoxRole = edittedItem.FindControl("ComBoxRole") as RadComboBox;
            System.Guid gTemp = System.Guid.NewGuid();
            UserBLL UserBLLs = new UserBLL();
            if (UserBLLs.ExistsLogName(textLoginName.Text))
            {
                //The user already exists
                //该用户已存在
                RadWindowManager1.RadAlert("The user already exists!", 300, 100, "Info", "");
                return;
            }
            //实例化Entity实体
            tblUser UserObj = new tblUser();
            UserObj.UserName = textUserName.Text;
            UserObj.LoginName = textLoginName.Text;
            UserObj.LoginPwd = textLoginPwd.Text;
            UserObj.UserCode = textUserCode.Text;
            UserObj.State = Convert.ToBoolean(ComBoxState.SelectedItem.Value);
            UserObj.Email = textEmail.Text;
            UserObj.Desc = textDesc.Text;
            UserObj.UserID = gTemp;

            UserBLLs.Add(UserObj);
            //创建目录文件夹
            Directory.CreateDirectory(Request.PhysicalApplicationPath + "FileUpLoad/" + gTemp);
            //*************************************************给用户配置角色
            RoleUserBLL Role_UserBLLs = new RoleUserBLL();
            if (ComBoxRole.SelectedItem.Value != string.Empty)
            {

                tblRole_User tblRole_UserObj = new tblRole_User();
                System.Guid gUserID = gTemp;
                System.Guid gRoleID = new Guid(ComBoxRole.SelectedItem.Value);
                tblRole_UserObj.UserID = gUserID;
                tblRole_UserObj.RoleID = gRoleID;
                Role_UserBLLs.Add(tblRole_UserObj);
            }
            //*************************************************给用户配置角色
            this.GridViewData();
        }
Beispiel #5
0
 /// <summary>
 /// 创建新的 tblRole_User 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 public static tblRole_User CreatetblRole_User(global::System.Guid id)
 {
     tblRole_User tblRole_User = new tblRole_User();
     tblRole_User.ID = id;
     return tblRole_User;
 }