예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == string.Empty || txtPass.Text == string.Empty || txtConfirmpass.Text == string.Empty ||
                txtEmail.Text == string.Empty || txtPass.Text == string.Empty || txtAddress.Text == string.Empty)
            {
                MessageBox.Show("Please Complete Data !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Check confirmation of the password
            if (txtPass.Text != txtConfirmpass.Text)
            {
                MessageBox.Show("Two Passowrd Not Identical", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //check User Name Correctness
            bool checkUserNameCorrectness;

            checkUserNameCorrectness = validation.IsUserName(txtUserName.Text);
            if (checkUserNameCorrectness == false)
            {
                MessageBox.Show("Please enter a correct UserName !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Check username Existence
            bool checkusername;

            checkusername = validation.IsUserName_Exist(txtUserName.Text);
            if (checkusername == true)
            {
                MessageBox.Show("Please Enter Another UserName !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserName.Focus();
                return;
            }



            //Check Email Existence
            bool checkemail;

            checkemail = validation.IsEmail_Exist(txtEmail.Text);
            if (checkemail == true)
            {
                MessageBox.Show("Please enter another Email !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.Focus();
                return;
            }

            //Check Email Correctness
            bool checkemailCorrectness;

            checkemailCorrectness = validation.IsValidEmail(txtEmail.Text);
            if (checkemailCorrectness == false)
            {
                MessageBox.Show("Enter a Correct Email !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.Focus();
                return;
            }

            //Check Mobile Existence
            bool checkMobile;

            checkMobile = validation.IsMobile_Exist(txtMobile.Text);
            if (checkMobile == true)
            {
                MessageBox.Show("Please enter another Mobile Number !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtMobile.Focus();
                return;
            }

            //Check mobile Correctness
            bool checkphoneCorrectness;

            checkphoneCorrectness = validation.IsIntNumber(txtMobile.Text);
            if (checkphoneCorrectness == false)
            {
                MessageBox.Show("Enter a Correct Mobile Number !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            //Check Address Correctness
            bool checkaddress;

            checkaddress = validation.IsAddres(txtAddress.Text);
            if (checkaddress == false)
            {
                MessageBox.Show("Enter a Correct Address !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            //variable to hold UserType
            string usertype = Convert.ToString(comboUserType.SelectedValue);

            if (usertype == "Seller")
            {
                BussinessLogicLayer.Seller seller = new BussinessLogicLayer.Seller();
                seller.Register(txtUserName.Text, txtPass.Text, txtEmail.Text, txtAddress.Text, txtMobile.Text);
                MessageBox.Show("You Are Register Successfully !", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }

            else
            {
                BussinessLogicLayer.Bidder bidder = new BussinessLogicLayer.Bidder();
                bidder.Register(txtUserName.Text, txtPass.Text, txtEmail.Text, txtAddress.Text, txtMobile.Text);
                MessageBox.Show("You Are Register Successfully !!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }
예제 #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == string.Empty || txtPassword.Text == string.Empty)
            {
                MessageBox.Show("Please Copmlete logining data ! ", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check If username exist in admin
            bool checkinAdmin;

            checkinAdmin = validation.IsUserName_ExistInAdmin(txtUserName.Text);

            // Check If username exist in admin
            bool checkinBidder;

            checkinBidder = validation.IsUserName_ExistInBidder(txtUserName.Text);

            // Check If username exist in admin
            bool checkinSeller;

            checkinSeller = validation.IsUserName_ExistInSeller(txtUserName.Text);

            //Admin
            if (checkinAdmin == true)
            {
                BussinessLogicLayer.Admin adminObj = new BussinessLogicLayer.Admin();
                DataTable Dt = adminObj.LOGIN(txtUserName.Text, txtPassword.Text, "Admin");

                if (Dt.Rows.Count > 0)
                {
                    // fetch admin data
                    int    id       = 0;
                    string username = "";
                    string password = "";
                    string email    = "";
                    string address  = "";
                    string mobile   = "";
                    string userType = "Admin";

                    foreach (DataRow row in Dt.Rows)
                    {
                        id       = Convert.ToInt32(row["ID"].ToString());
                        username = row["UserName"].ToString();
                        password = row["Password"].ToString();
                        email    = row["Email"].ToString();
                        address  = row["Address"].ToString();
                        mobile   = row["Mobile"].ToString();
                    }

                    // fill admin object
                    adminObj.setID(id);
                    adminObj.setUserName(username);
                    adminObj.setPassword(password);
                    adminObj.setEmail(email);
                    adminObj.setAddress(address);
                    adminObj.setMobile(mobile);
                    adminObj.setUserType(userType);
                    //Close login Form And Open Admin Form
                    this.Hide();
                    this.Close();
                    FORM_ADMIN form_Admin = new FORM_ADMIN(adminObj);
                    form_Admin.ShowDialog();

                    return;
                }
                else
                {
                    MessageBox.Show("InCorrect Password !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            //Bidder
            else if (checkinBidder == true)
            {
                BussinessLogicLayer.Bidder bidderObj = new BussinessLogicLayer.Bidder();
                DataTable Dt = bidderObj.LOGIN(txtUserName.Text, txtPassword.Text, "Bidder");

                if (Dt.Rows.Count > 0)
                {
                    // fetch bidder data
                    int    id       = 0;
                    string username = "";
                    string password = "";
                    string email    = "";
                    string address  = "";
                    string mobile   = "";
                    string userType = "Bidder";
                    foreach (DataRow row in Dt.Rows)
                    {
                        id       = Convert.ToInt32(row["ID"].ToString());
                        username = row["UserName"].ToString();
                        password = row["Password"].ToString();
                        email    = row["Email"].ToString();
                        address  = row["Address"].ToString();
                        mobile   = row["Mobile"].ToString();
                    }

                    // fill Bidder object
                    bidderObj.setID(id);
                    bidderObj.setUserName(username);
                    bidderObj.setPassword(password);
                    bidderObj.setEmail(email);
                    bidderObj.setAddress(address);
                    bidderObj.setMobile(mobile);
                    bidderObj.setUserType(userType);

                    //Close login Form And Open Admin Form
                    this.Hide();
                    this.Close();
                    FORM_BIDDER form_Admin = new FORM_BIDDER(bidderObj);
                    form_Admin.ShowDialog();
                }
                else
                {
                    MessageBox.Show("InCorrect Password !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            //Seller
            else if (checkinSeller == true)
            {
                BussinessLogicLayer.Seller sellerObj = new BussinessLogicLayer.Seller();
                DataTable Dt = sellerObj.LOGIN(txtUserName.Text, txtPassword.Text, "Seller");

                if (Dt.Rows.Count > 0)
                {
                    // fetch Seller data
                    int    id       = 0;
                    string username = "";
                    string password = "";
                    string email    = "";
                    string address  = "";
                    string mobile   = "";
                    string userType = "Seller";

                    foreach (DataRow row in Dt.Rows)
                    {
                        id       = Convert.ToInt32(row["ID"].ToString());
                        username = row["UserName"].ToString();
                        password = row["Password"].ToString();
                        email    = row["Email"].ToString();
                        address  = row["Address"].ToString();
                        mobile   = row["Mobile"].ToString();
                    }

                    // fill admin object
                    sellerObj.setID(id);
                    sellerObj.setUserName(username);
                    sellerObj.setPassword(password);
                    sellerObj.setEmail(email);
                    sellerObj.setAddress(address);
                    sellerObj.setMobile(mobile);
                    sellerObj.setUserType(userType);

                    //Close login Form And Open Admin Form
                    this.Hide();
                    this.Close();
                    FORM_SELLER form_Admin = new FORM_SELLER(sellerObj);
                    form_Admin.ShowDialog();
                }
                else
                {
                    MessageBox.Show("InCorrect Password !", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            else
            {
                MessageBox.Show("InCorrect UserName ! ", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }