protected void Button1_Click(object sender, EventArgs e)
        {
            //try
            //{

            if (lbllecid.Text.Length > 0)
            {
                WebServiceAccountsRepository webir = new WebServiceAccountsRepository();
                if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text))
                {
                    if (webir.FindByUserName(txtusername.Text) != null)
                    {
                        PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatuserTitle, Color.Red);

                        return;
                    }
                }

                WebServiceAccountsRepository webirr  = new WebServiceAccountsRepository();
                WebServiceAccount            account = new WebServiceAccount();

                if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text))
                {
                    account.Username = txtusername.Text;
                }

                account.AccountID = lbllecid.Text.ToInt();
                account.Password  = (txtpass.Text.Length > 0 ? FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5") : account.Password);
                account.Status    = (chkActiveAccount.Checked == true ? 0 : 1);
                webirr.Saveaccount(account);
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green);
            }
            //}
            //catch
            //{
            //    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red);
            //}
        }
Esempio n. 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            WebServiceAccountsRepository parir = new WebServiceAccountsRepository();

            if (parir.FindByUserName(txtusername.Text) != null)
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red);
                return;
            }

            bool successfullCreateAccount = true;

            try
            {
                WebServiceAccount webaccount = new WebServiceAccount();
                webaccount.Username = txtusername.Text.Trim();
                webaccount.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5");
                webaccount.Status   = (chkActiveAccount.Checked == true ? 0 : 1);

                parir.Saveaccount(webaccount);


                clearform();
            }
            catch (System.Exception err)
            {
                //OnlineTools.ShowMessage(lblMessage, err.Message, Color.Red);
                successfullCreateAccount = false;
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red);
            }
            if (successfullCreateAccount)
            {
                // ClearForm();
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green);
            }
        }