예제 #1
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                string ControlFocus = string.Empty;

                if (ValidateMandUserFields())
                {
                    lblUserIdExpression.Visible       = false;
                    lblPasswordExpression.Visible     = false;
                    lblConfPasswordExpression.Visible = false;
                    lblEmailExpression.Visible        = false;
                    lblPhoneNoExpression.Visible      = false;

                    if (ValidaeUserFields(txtUserId.Text, txtPassword.Text, txtConfirmPassword.Text, txtEmailId.Text, txtPhoneNo.Text, out ControlFocus))
                    {
                        ModelBookStore.Login objLogin = new ModelBookStore.Login();
                        {
                            objLogin.UserId   = txtUserId.Text;
                            objLogin.Password = txtPassword.Text;

                            ModelBookStore.UserDetail objUserDetail = new ModelBookStore.UserDetail();
                            {
                                // objUserDetail.UserId = objLogin.id;
                                objUserDetail.FirstName = txtFirstName.Text;
                                objUserDetail.LastName  = txtLastName.Text;

                                objUserDetail.PhoneNumber = txtPhoneNo.Text;
                                objUserDetail.EmailId     = txtEmailId.Text;
                                objUserDetail.DOB         = dtpDOB.Value;
                                objUserDetail.Address     = txtAddress.Text;
                                objUserDetail.state       = cmbState.Text;
                                objUserDetail.city        = cmbCity.Text;

                                // objUserDetail.Login = objLogin;
                            };

                            List <ModelBookStore.UserDetail> userDetails = new List <ModelBookStore.UserDetail>();
                            userDetails.Add(objUserDetail);
                            objLogin.UserDetails = userDetails;
                        };

                        //objLogin.UserDetails.Add(objUserDetail);

                        Save(objLogin);

                        DialogResult dialogResult = MessageBox.Show("You have added successfully and Would you like to add new customer , please click yes else no to login", "", MessageBoxButtons.YesNo);

                        if (dialogResult == DialogResult.No)
                        {
                            FrmLogin objLoginfrm = new FrmLogin();
                            objLoginfrm.Show();
                            this.Hide();
                        }
                        if (dialogResult == DialogResult.Yes)
                        {
                            Reset();
                        }
                    }
                    else
                    {
                        if (ControlFocus == "UserId")
                        {
                            txtUserId.Focus();
                            //  txtPassword.Focus();
                            lblUserIdExpression.Visible = true;
                        }
                        else if (ControlFocus.StartsWith("Password"))
                        {
                            txtPassword.Focus();
                            //  txtPassword.Focus();
                            lblPasswordExpression.Text    = ControlFocus;
                            lblPasswordExpression.Visible = true;
                        }
                        else if (ControlFocus.Contains("ConfPassword"))
                        {
                            txtConfirmPassword.Focus();
                            lblConfPasswordExpression.Visible = true;
                        }
                        else if (ControlFocus == "Email")
                        {
                            txtEmailId.Focus();
                            lblEmailExpression.Visible = true;
                        }
                        else if (ControlFocus == "PhoneNo")
                        {
                            txtPhoneNo.Focus();
                            lblPhoneNoExpression.Visible = true;
                        }
                    }
                }
                else
                {
                    lblValidationSummary.Visible = true;
                }
            }
            catch (Exception ex)
            {
                // throw new Exception(ex.Message);
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
 private void Save(ModelBookStore.Login objLogin)
 {
     //var login = objcontainer.Resolve<BLLogin>();
     // login.Register(objLogin);
     objBLLogin.Register(objLogin);
 }