Пример #1
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            if (lblid.Text.Length > 0)
            {
                try
                {
                    EmailContactsRepository ecrir = new EmailContactsRepository();
                    if ((TextBox2.Text.Length > 0) && (TextBox2.Text != lblemailaddrress.Text))
                    {
                        if (ecrir.FindByEmailAddrress(TextBox2.Text) != null)
                        {
                            PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatemailTitle, Color.Red);

                            return;
                        }
                    }



                    //  EmailContactsRepository ecrir = new EmailContactsRepository();
                    EmailContact email = new EmailContact();
                    email.UserTypeID = Session["UserTypeID"].ToString().ToInt();
                    // email.UserID=ddluserid.SelectedValue.ToInt();
                    //  email.EmailTypeID = ddlemailtype.SelectedValue.ToInt();
                    email.UserID      = Session["UserID"].ToString().ToInt();
                    email.EmailTypeID = Session["newemailtype"].ToString().ToInt();

                    email.ID = lblid.Text.ToInt();
                    ecrir.SaveEmailContact(email);

                    if ((TextBox2.Text.Length > 0) && (TextBox2.Text != lblemailaddrress.Text))
                    {
                        email.EmailAddrress = TextBox2.Text.Trim();
                    }


                    clearform();


                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green);
                }
                catch
                {
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red);
                }
            }
        }
Пример #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            EmailContactsRepository email = new EmailContactsRepository();

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



            bool successfullCreateAccount = true;


            try
            {
                EmailContact newcontact = new EmailContact();
                newcontact.UserTypeID = lblusertypeid.Text.ToInt();

                newcontact.UserID        = lbluserid.Text.ToInt();
                newcontact.EmailTypeID   = ddlemailtype.SelectedValue.ToInt();
                newcontact.EmailAddrress = TextBox1.Text.Trim();

                EmailContactsRepository ecrir = new EmailContactsRepository();
                ecrir.SaveEmailContact(newcontact);



                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);
            }
        }