//AT LEAST ONE USER EXIST OR NOT CHECK private void LoginUserAllAvailableCheck() { try { objUserLogic = new UserClassBLL(); DataSet ds = new DataSet(); ds = (DataSet)objUserLogic.CurrentUser(lblUserProfile.Text); string secQue = ds.Tables["Table_User"].Rows[0].Field <string>("sec_question"); string secAns = ds.Tables["Table_User"].Rows[0].Field <string>("sec_answer"); string mobile = ds.Tables["Table_User"].Rows[0].Field <string>("mobile"); string division = ds.Tables["Table_User"].Rows[0].Field <string>("division"); lblCommenDetails.Text = division;//CURRENT USER DIVISION if (string.IsNullOrEmpty(secQue) || string.IsNullOrEmpty(secAns) || string.IsNullOrEmpty(mobile) || string.IsNullOrEmpty(division)) { frmUser frmUs = new frmUser(); frmUs.ShowDialog(); MessageBox.Show("You must filling all of details.", "User Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } //SET CURRENT USERNAME AND DIVISION //objUcSurveyor = new ucSurveyor(); //objUcSurveyor.PassValue(lblUserProfile.Text, division); } catch (Exception ex) { MessageBox.Show(ex.Message, "User Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//LOGIN USER PROFILE DETAILS public void UserProfileDetails() { try { objUserLogic = new UserClassBLL(); DataSet ds = new DataSet(); ds = (DataSet)objUserLogic.CurrentUser(loginUser); lblUsernameTop.Text = lblUsername.Text = loginUser; lblType.Text = ds.Tables["Table_User"].Rows[0].Field <string>("user_type"); lblDivision.Text = lblDivisionTop.Text = ds.Tables["Table_User"].Rows[0].Field <string>("division"); lblMobile.Text = ds.Tables["Table_User"].Rows[0].Field <string>("mobile"); lblEmail.Text = ds.Tables["Table_User"].Rows[0].Field <string>("email"); } catch (Exception ex) { MessageBox.Show(ex.Message, "USER ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnLogIn_Click(object sender, EventArgs e) { try { objUserLogic = new UserClassBLL(); DataSet ds = new DataSet(); ds = (DataSet)objUserLogic.CurrentUser(txtUsename.Text); //CHECK USER EXIST OR NOT (USING LINQ) DataTable dt = ds.Tables["Table_User"]; DataColumn[] usernameCol = dt.Columns.Cast <DataColumn>().ToArray(); bool checkUserExist = dt.AsEnumerable().Any(row => usernameCol.Any(col => row[col].ToString() == txtUsename.Text)); //CHECK USER EXIST OR NOT if (checkUserExist) { //AVAILABLE USERNAME & PASSWORD GET string username = ds.Tables["Table_User"].Rows[0].Field <string>("username"); string password = ds.Tables["Table_User"].Rows[0].Field <string>("password"); //CHECK USERNAME & PASSWORD ARE EQUAL if (username.Equals(txtUsename.Text) && password.Equals(txtPassword.Text)) { //RUNNING BACKGROUNDWORKER AND STARTING PROCESS COUNTING PRECENTAGE backgroundWorker1.RunWorkerAsync(); btnLogIn.Enabled = false; llblFogotPass.Enabled = false; } else { MessageBox.Show("Login Fail, Please check again password!", "User Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); PlaceHolderUser(); } } else { MessageBox.Show("User not exist, Please check again username!", "User Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); PlaceHolderUser(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "User Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//RECOVERY USER PASSWORD private void Recovery() { try { objUserLogic = new UserClassBLL(); DataSet ds = new DataSet(); ds = (DataSet)objUserLogic.CurrentUser(txtUsername.Text); DataTable dt = ds.Tables["Table_User"]; DataColumn[] usernameCol = dt.Columns.Cast<DataColumn>().ToArray(); bool checkUserExist = dt.AsEnumerable().Any(row => usernameCol.Any(col => row[col].ToString() == txtUsername.Text)); //CHECK USER EXIST OR NOT if (checkUserExist) { string secQue = ds.Tables["Table_User"].Rows[0].Field<string>("sec_question"); string secAns = ds.Tables["Table_User"].Rows[0].Field<string>("sec_answer"); if (secQue.Equals(cbxSecQue.Text) && secAns.Equals(txtSecAns.Text)) { string password = ds.Tables["Table_User"].Rows[0].Field<string>("password"); MessageBox.Show("Your password is \"" + password + "\"", "Fogot Password", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Wrong Answer or Security Question!", "Fogot Password", MessageBoxButtons.OK, MessageBoxIcon.Warning); Clear(); //CLEAR ALL TEXTBOX AND COMBO BOX } } else { MessageBox.Show("Wrong Username!", "Fogot Password", MessageBoxButtons.OK, MessageBoxIcon.Warning); Clear(); //CLEAR ALL TEXTBOX AND COMBO BOX } } catch (Exception ex) { MessageBox.Show(ex.Message, "Fogot Password", MessageBoxButtons.OK, MessageBoxIcon.Error); } }