Пример #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            RolesRepository role = new RolesRepository();

            if (role.FindBytitle(TextBox1.Text) != null)
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red);
                return;
            }

            bool successfullCreateAccount = true;

            try
            {
                Role newrole = new Role();
                newrole.RoleTitle = TextBox1.Text.Trim();

                RolesRepository rrir = new RolesRepository();
                rrir.SaveRoles(newrole);

                ClearForm();
            }
            catch (System.Exception err)
            {
                successfullCreateAccount = false;
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red);
            }
            if (successfullCreateAccount)
            {
                // ClearForm();
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green);
            }
        }
Пример #2
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            if (lblRoleid.Text.Length > 0)
            {
                try
                {
                    RolesRepository rrir = new RolesRepository();
                    if (rrir.FindBytitle(TextBox1.Text) != null)
                    {
                        PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatTitle, Color.Red);

                        return;
                    }

                    Role editRole = new Role();
                    if ((TextBox1.Text.Length > 0) && (TextBox1.Text != lbltitle.Text))
                    {
                        editRole.RoleTitle = TextBox1.Text;
                    }

                    editRole.RoleID = lblRoleid.Text.ToInt();

                    rrir.SaveRoles(editRole);



                    ClearForm();


                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green);
                }
                catch
                {
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red);
                }
            }
        }