Ejemplo n.º 1
0
        /// <summary>
        /// load when create user
        /// </summary>
        public FrmCreateUser(string userName)
        {
            COM_MESSAGE  = new CommonControls.Classes.ClsMessages();
            VALIDATION   = new CommonControls.Classes.ClsValidation();
            COMM_METHODS = new CommonControls.Classes.ClsCommonMethods();
            CREATEUSER   = new BLL.ClsUserManageData();
            MANAGEDB     = new BLL.ClsUserManageDbChanges();

            InitializeComponent();

            txt_userID.Text = MANAGEDB.getMaxUserID().ToString();
            //fill data of user role from db
            dropDown_userRole.DataSource     = MANAGEDB.getUserRoleList();
            dropDown_userRole.DisplayMember  = "userRoleName";
            dropDown_userRole.ValueMember    = "userRoleId";
            dropDown_userRole.BindingContext = this.BindingContext;
            dropDown_userRole.SelectedIndex  = -1;

            btn_create.Visible    = true;
            btn_update.Visible    = false;
            btn_delete.Visible    = false;
            btn_resetPass.Visible = false;

            USERNAME = userName;

            this.ActiveControl = txt_userName;
        }
Ejemplo n.º 2
0
        private void btn_create_Click(object sender, EventArgs e)
        {
            try
            {
                //check for do action
                if (COMM_METHODS.checkActPermission(this.Name, USERNAME))
                {
                    bool   isError   = false;
                    string userName  = txt_userName.Text;
                    string firstName = txt_firstName.Text;
                    string lastName  = txt_lastName.Text;
                    string idNumber  = txt_nic.Text;
                    string email     = txt_email.Text;
                    string userRole  = (dropDown_userRole.SelectedIndex != -1) ? dropDown_userRole.SelectedItem.ToString() : string.Empty;
                    string phoneNo   = txt_phoneNumber.Text;

                    var dataList = new List <Tuple <string, string> >();

                    dataList.Add(new Tuple <string, string>("userName", userName));
                    dataList.Add(new Tuple <string, string>("firstName", firstName));
                    dataList.Add(new Tuple <string, string>("lastName", lastName));
                    dataList.Add(new Tuple <string, string>("idNumber", idNumber));
                    dataList.Add(new Tuple <string, string>("email", email));
                    dataList.Add(new Tuple <string, string>("userRole", userRole));
                    dataList.Add(new Tuple <string, string>("phoneNo", phoneNo));

                    isError = checkInsertedUserData(dataList);

                    if (!isError)
                    {
                        //insert data to db
                        CREATEUSER._userId    = Convert.ToInt16(txt_userID.Text);
                        CREATEUSER._userName  = userName;
                        CREATEUSER._firstName = firstName;
                        CREATEUSER._lastName  = lastName;
                        CREATEUSER._dob       = Convert.ToDateTime(txt_dob.Text);
                        CREATEUSER._idNumber  = idNumber;
                        CREATEUSER._address   = txt_address.Text;
                        CREATEUSER._email     = email;
                        CREATEUSER._userRole  = userRole;
                        CREATEUSER._roleId    = Convert.ToInt16(dropDown_userRole.SelectedValue);
                        CREATEUSER._phoneNo   = phoneNo;

                        //insert to tbl_userDetail and tbl_login
                        if (MANAGEDB.InsertData_userDetail(CREATEUSER))
                        {
                            COM_MESSAGE.successfullMessage("Successfully created the user ");
                            COMM_METHODS.clearAllText(this);
                            dropDown_userRole.SelectedIndex = -1;
                            txt_userID.Text = MANAGEDB.getMaxUserID().ToString();
                        }
                    }
                }
                else
                {
                    COM_MESSAGE.permissionMessage("Sorry You dont have permission to do action !!!");
                }
            }
            catch (Exception ex)
            {
                COM_MESSAGE.exceptionMessage(ex.Message);
            }
        }