예제 #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (CheckBox1.Checked)
        {
            try
            {
                MembershipCreateStatus cs = MembershipCreateStatus.Success;
                MembershipUser         mu = Membership.CreateUser(txtUname.Text, txtPass.Text, txtEmail.Text, DDLForgetQues.SelectedItem.ToString(), txtForgetAns.Text, true, out cs);
                if (mu.IsApproved)
                {
                    Roles.AddUserToRole(txtUname.Text, "User");
                }
                if (Membership.ValidateUser(txtUname.Text, txtPass.Text))
                {
                    if (Roles.IsUserInRole(txtUname.Text, "User"))
                    {
                        string uid = get_userID();
                        d = new DataClassesDataContext();
                        tbl_UserProfile up = new tbl_UserProfile();
                        up.Uid       = uid;
                        up.lastname  = txtLname.Text;
                        up.firstname = txtFname.Text;
                        d.tbl_UserProfiles.InsertOnSubmit(up);
                        d.SubmitChanges();

                        string msg = mailservice.MailRegister(txtEmail.Text, txtFname.Text + " " + txtLname.Text, txtPass.Text, txtUname.Text);


                        Response.Write("<script>alert('User Added Successfuly... " + msg + "')</script>");
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert(" + ex + ")</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('Please accept the terms & conditions then continue registering.')</script>");
        }
    }
예제 #2
0
        private void SaveNewProfile()
        {
            try
            {
                using (LinqToSQLDataContext db = new LinqToSQLDataContext(con))
                {
                    tbl_UserProfile tbl = new tbl_UserProfile
                    {
                        Userprofile    = tbUserProfile.Text,
                        Productions    = checkProductions.IsChecked.Value,
                        Maintenance    = checkMaintenance.IsChecked.Value,
                        Products       = checkProductDef.IsChecked.Value,
                        Users          = checkUsers.IsChecked.Value,
                        MachineConfig  = checkMachineConfig.IsChecked.Value,
                        Reprint        = checkReprint.IsChecked.Value,
                        Reset          = checkReset.IsChecked.Value,
                        Find           = checkFind.IsChecked.Value,
                        Desktop        = checkDesktop.IsChecked.Value,
                        Materials      = checkMaterials.IsChecked.Value,
                        ProductProfile = checkProductProfile.IsChecked.Value,
                        LabelEditor    = checkLabelEditor.IsChecked.Value,
                        BobbinMonitor  = checkBobbinMonitor.IsChecked.Value,
                        BobbinTracer   = checkBobbinTracing.IsChecked.Value
                    };

                    db.tbl_UserProfiles.InsertOnSubmit(tbl);
                    db.SubmitChanges();
                }

                ResetValues();
            }
            catch (Exception exc)
            {
                System.Windows.MessageBox.Show("Something went wrong While Adding this user");
            }
        }
예제 #3
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                bool check = ValidateEmail();
                EncryptionDecription enc;

                if (txtEmail.Text == string.Empty && txtF_name.Text == string.Empty && txtL_name.Text == string.Empty && txtUserName.Text == string.Empty && txtMobileNo.Text == string.Empty && txtNewPass.Text == string.Empty && txtConfirmPass.Text == string.Empty)
                {
                    panel3.Visible = true;
                    lblError.Text  = "Enter all details.";
                    txtEmail.Focus();
                }

                else if (!check)
                {
                    panel3.Visible = true;
                    lblError.Text  = txtEmail.Text + " is Invalid Email Address";
                    txtEmail.Focus();
                }
                else if (txtEmail.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtEmail, "Enter Email Address");
                    txtEmail.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter Email Address.";
                }
                else if (txtF_name.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtF_name, "Enter First Name");
                    txtF_name.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter First Name.";
                }
                else if (txtL_name.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtL_name, "Enter Last Name");
                    txtL_name.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter Last Name.";
                }
                else if (txtUserName.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtUserName, "Enter User Name");
                    txtMobileNo.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter User Name.";
                }

                else if (txtMobileNo.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtMobileNo, "Enter Mobile Number");
                    txtMobileNo.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter Mobile Number.";
                }

                else if (txtNewPass.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtNewPass, "Enter Password");
                    txtNewPass.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter Password.";
                }
                else if (txtConfirmPass.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtConfirmPass, "Re-enter Password");
                    txtConfirmPass.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Re-enter Password.";
                }
                else if (txtConfirmPass.Text != txtNewPass.Text)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtConfirmPass, "Re-enter Password");
                    txtConfirmPass.Clear();
                    txtConfirmPass.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Password and Confirm Password does not match.";
                }

                else
                {
                    if (btnRegister.Text == "Register")
                    {
                        _entities = new MicroAccountsEntities1();

                        tbl_UserProfile userProfile = new tbl_UserProfile();

                        userProfile.email       = txtEmail.Text.Trim().ToString();
                        userProfile.firstName   = txtF_name.Text.Trim().ToString();
                        userProfile.lastName    = txtL_name.Text.Trim().ToString();
                        userProfile.mobile      = Convert.ToInt64(txtMobileNo.Text.Trim().ToString());
                        userProfile.createdDate = DateTime.Now;
                        userProfile.updateDate  = DateTime.Now;

                        _entities.tbl_UserProfile.Add(userProfile);
                        _entities.SaveChanges();

                        _entities = new MicroAccountsEntities1();
                        tbl_UserLogiln userlogin = new tbl_UserLogiln();
                        userlogin.loginId = txtUserName.Text.Trim().ToString();

                        //encryption of password by calling method of the class called EncryptionDecryption
                        enc = new EncryptionDecription();

                        //  var encPass = enc.Encrypt(txtNewPass.Text.Trim().ToString(), "sblw-3hn8-sqoy19");

                        // var encPass = enc.Encrypt(txtNewPass.Text.Trim().ToString());

                        userlogin.password    = txtNewPass.Text.Trim().ToString();
                        userlogin.userId      = _entities.tbl_UserProfile.Where(x => x.firstName == txtF_name.Text && x.email == txtEmail.Text).FirstOrDefault().userId;
                        userlogin.createdDate = DateTime.Now;
                        userlogin.updateDate  = DateTime.Now;

                        _entities.tbl_UserLogiln.Add(userlogin);
                        _entities.SaveChanges();

                        DataGridSource();
                        MessageBox.Show("Register SuccessFull!");
                    }
                    else
                    {
                        _entities = new MicroAccountsEntities1();
                        enc       = new EncryptionDecription();

                        var uId          = Convert.ToInt32(hiddenUID.Text);
                        var dataToUpdate = _entities.tbl_UserProfile.Where(x => x.userId == uId).FirstOrDefault();

                        dataToUpdate.firstName  = txtF_name.Text.Trim().ToString();
                        dataToUpdate.lastName   = txtL_name.Text.Trim().ToString();
                        dataToUpdate.email      = txtEmail.Text.Trim().ToString();
                        dataToUpdate.mobile     = Convert.ToDecimal(txtMobileNo.Text.Trim());
                        dataToUpdate.updateDate = DateTime.Now;

                        foreach (var item in dataToUpdate.tbl_UserLogiln)
                        {
                            item.loginId = txtUserName.Text.Trim().ToString();
                            //  item.password = enc.Encrypt(txtNewPass.Text.ToString(), "sblw-3hn8-sqoy19");
                            item.password   = enc.Encrypt(txtNewPass.Text.ToString());
                            item.updateDate = DateTime.Now;

                            _entities.SaveChanges();
                        }

                        _entities.SaveChanges();
                        DataGridSource();
                        MessageBox.Show("Updated SuccessFull!");
                    }

                    ClearTextBox();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went wrong. Contact your system administrator");
            }
        }