private void btnDelete_Click(object sender, EventArgs e)
        {
            if (ValidateMandUserFields())
            {
                if (SelectedId > 0)
                {
                    ModelBookStore.UserDetail objUserDetail = new ModelBookStore.UserDetail();
                    {
                        objUserDetail.id = SelectedId;
                    }



                    Delete(objUserDetail);
                    Reset();
                    MessageBox.Show("Deleted Successfully");
                }
                else
                {
                    MessageBox.Show("No Data in Grid or please select any row from Grid");
                }
            }
            else
            {
                lblValidationSummary.Visible = true;
            }
        }
        private void btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                string ControlFocus = string.Empty;

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

                    if (ValidaeUserFields(txtEmailId.Text, txtPhoneNo.Text, out ControlFocus))
                    {
                        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;
                            if (chkMembership.Checked == true)
                            {
                                objUserDetail.IsMembership = "Y";
                            }
                            else
                            {
                                objUserDetail.IsMembership = "N";
                            }
                            objUserDetail.id = SelectedId;

                            // objUserDetail.Login = objLogin;
                        };



                        //objLogin.UserDetails.Add(objUserDetail);
                        if (SelectedId > 0)
                        {
                            Update(objUserDetail);
                            MessageBox.Show("Customer Updated Successfully");
                            Reset();
                        }
                        else
                        {
                            Save(objUserDetail);
                            MessageBox.Show("Customer Added Successfully");
                            Reset();
                        }


                        //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 == "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);
            }
        }
 private void Delete(ModelBookStore.UserDetail objUserDetail)
 {
     objBLLogin.Delete(objUserDetail);
 }
 private void Update(ModelBookStore.UserDetail objUserDetail)
 {
     objBLLogin.Update(objUserDetail);
 }
 private void Save(ModelBookStore.UserDetail objUserDetail)
 {
     objBLLogin.Add(objUserDetail);
 }
示例#6
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);
            }
        }