private void button1_Click(object sender, EventArgs e) { lb.username = username.Text.Trim(); lb.password = password.Text.Trim(); lb.usertype = userType.Text.Trim(); bool success = ld.loginCheck(lb); if (success == true) { try { AdminDashboard adm = new AdminDashboard(); adm.Show(); } catch (Exception ex) { MessageBox.Show("Error"); clear(); } } else { MessageBox.Show("Please enter valid login details"); clear(); } }
public void Login(Form _form) { loginProxy = new LoginProxy(); var user = loginProxy.Login(UserName, Password); if (user != null) { if (user.AccountLevel == "admin") { _form.Hide(); Form admin = new AdminDashboard(); admin.Show(); } else if (user.AccountLevel == "student") { _form.Hide(); Form student = new StudentDashboard(user.RegistrationID.ToString()); student.Show(); } else if (user.AccountLevel == "teacher") { _form.Hide(); Form teacher = new TeacherDashboard(user.RegistrationID.ToString()); teacher.Show(); } } else { MessageBox.Show("Incorrect Username or Password!"); } }
private void MbtnLogin_Click(object sender, EventArgs e) { if (this.txtLoginPassword.Text != "" && this.txtLoginId.Text != "") { UserLoginEntity user = new UserLoginEntity(); user.UserId = txtLoginId.Text.Trim(); user.UserPassword = txtLoginPassword.Text; UserLoginRepository emp = new UserLoginRepository(); if (emp.UserLoginValidation(user)) { if (user.UserId.Substring(0, 1) == "A") { MessageBox.Show("Admin"); AdminDashboard admin = new AdminDashboard(this, user.UserId); this.Hide(); admin.Show(); Clear(); } else if (user.UserId.Substring(0, 1) == "W") { MessageBox.Show("Waiter"); Waiter_Dashboard wd = new Waiter_Dashboard(this, user.UserId); this.Hide(); wd.Show(); Clear(); } else if (user.UserId.Substring(0, 1) == "M") { MessageBox.Show("Manager"); Manager_Dashboard md = new Manager_Dashboard(this, user.UserId); this.Hide(); md.Show(); Clear(); } else { MessageBox.Show("Invalid Form Of Id!"); Clear(); } } else { MessageBox.Show("Invalid Id or Password", "Login Failed"); Clear(); } } else { MessageBox.Show("Insert ID or Password", "Login Failed"); Clear(); } }
private void Login() { if (string.IsNullOrWhiteSpace(txtUserName.Text)) { MessageBox.Show("Username is required"); return; } if (string.IsNullOrWhiteSpace(txtPassword.Text)) { MessageBox.Show("password is required"); return; } var loginrequest = new LoginRequestViewModel() { UserName = txtUserName.Text, Password = txtPassword.Text }; var result = Services.UserService.Login(loginrequest); if (result.Status) { switch (result.Type) { case Common.UserType.Student: StudentDashboard student = new StudentDashboard(result); student.Show(); break; case Common.UserType.Teacher: TeacherDashboard teacher = new TeacherDashboard(result); teacher.Show(); break; case Common.UserType.Parent: break; case Common.UserType.Admin: AdminDashboard admin = new AdminDashboard(result); admin.Show(); break; default: break; } this.Hide(); } else { MessageBox.Show(result.Message); } }
private void btnLogin_Click(object sender, EventArgs e) { l.username = txtUsername.Text.Trim(); l.password = txtPassword.Text.Trim(); l.user_type = cmbUserType.Text.Trim(); //Checking the login credentials bool success = dal.loginCheck(l); if (success == true) { MessageBox.Show("Login Successfull"); loggedIn = l.username; //Need to open forms based on usertype switch (l.user_type) { case "Admin": { AdminDashboard admin = new AdminDashboard(); admin.Show(); this.Hide(); } break; case "User": { UserDashboard user = new UserDashboard(); user.Show(); this.Hide(); } break; default: { MessageBox.Show("Invalid User Type"); } break; } } else { MessageBox.Show("Login Failed.Try again"); } }
private void button1_Click(object sender, EventArgs e) { string user = empusername.Text; string pass = emppassword.Text; Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); string query = "INSERT INTO EmployeeTable VALUES " + "('" + userId + "', '" + department + "', '" + user + "', '" + pass + "');"; SqlCommand cmd = new SqlCommand(query, con); cmd.ExecuteReader(); addLoginDetails(userId, department, user, pass); this.Hide(); AdminDashboard dashboard = new AdminDashboard(); dashboard.Show(); } }
private void btnLogin_Click(object sender, EventArgs e) { l.username = txtUsername.Text.Trim(); l.password = txtPassword.Text.Trim(); l.user_type = cmbUserType.Text.Trim(); bool success = dal.loginCheck(l); if (success == true) { MessageBox.Show("Login Successfull."); loggedIn = l.username; switch (l.user_type) { case "Admin": { AdminDashboard admin = new AdminDashboard(); admin.Show(); this.Hide(); } break; case "User": { UserDashboard user = new UserDashboard(); user.Show(); this.Hide(); } break; default: { MessageBox.Show("Invalid user type!"); } break; } } else { MessageBox.Show("Login failed. Try again!!"); } }
private void button1_Click(object sender, EventArgs e) { string connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\14383\Downloads\BookBizz\BookBizz\Database1.mdf;Integrated Security=True"; string fName = firstname.Text; string lName = lastname.Text; string number = phone.Text; string mail = email.Text; Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match = regex.Match(mail); if (number.Length < 10) { error.Visible = true; errorCont.Visible = true; error.Text = "Phone number is not valid"; } else if (!match.Success) { error.Visible = true; errorCont.Visible = true; error.Text = "Email is not valid"; } else { error.Visible = false; errorCont.Visible = false; using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); string query = "INSERT INTO UserTable VALUES " + "('" + fName + "', '" + lName + "', " + number + ", '" + mail + "', 0)"; SqlCommand cmd = new SqlCommand(query, con); cmd.ExecuteReader(); this.Hide(); AdminDashboard dashboard = new AdminDashboard(); dashboard.Show(); } } }
private void btnLogin_Click(object sender, EventArgs e) { #region Throw Error Message if (txtUsername.Text == "" && txtPassword.Text == "" && cmbUserType.Text == "") { MessageBox.Show(" Please Fill All The Details..... !! "); } else if (txtPassword.Text == "" && cmbUserType.Text == "") { MessageBox.Show(" Please Enter Passsword & Select UserType ... !! "); } else if (txtUsername.Text == "") { MessageBox.Show(" Please Enter Username.... !! "); } else if (txtPassword.Text == "") { MessageBox.Show(" Please Enter Password ... !! "); } else if (cmbUserType.Text == "") { MessageBox.Show(" Please Select Usertype ... !! "); } #endregion else { l.username = txtUsername.Text.Trim(); l.password = txtPassword.Text.Trim(); l.user_type = cmbUserType.Text.Trim(); //Checking the login credentials bool success = dal.loginCheck(l); if (success == true) { MessageBox.Show("Login Successfull"); loggedIn = l.username; //Need to open forms based on usertype switch (l.user_type) { case "Admin": { AdminDashboard admin = new AdminDashboard(); admin.Show(); this.Hide(); } break; case "User": { UserDashboard user = new UserDashboard(); user.Show(); this.Hide(); } break; default: { MessageBox.Show("Invalid User Type"); } break; } } else { MessageBox.Show("Login Failed.Try again"); } } }
private void btn_login_Click(object sender, EventArgs e) { Hashtable htmastuser = new Hashtable(); DataTable dtmstuser = new DataTable(); string empCode = txt_Emp_Code.Text.ToString().ToUpper(); string password = txt_password.Text.ToString(); htmastuser.Add("@Trans", "GET_USER_BY_EMP_CODE"); htmastuser.Add("@DRN_Emp_Code", empCode); dtmstuser = Dataaccess.ExecuteSP("Sp_User", htmastuser); //empCode = txt_Emp_Code.Text.ToString(); //password = txt_password.Text.ToString(); if (dtmstuser.Rows.Count > 0) { if (string.IsNullOrEmpty(dtmstuser.Rows[0]["DRN_Emp_Code"].ToString())) { txt_Emp_Code.Text = ""; txt_Emp_Code.Focus(); MessageBox.Show("User Does Not Exist"); return; } else { Confirmusername = dtmstuser.Rows[0]["DRN_Emp_Code"].ToString().ToUpper(); } ConfirmPassword = dtmstuser.Rows[0]["Password"].ToString(); Empname = dtmstuser.Rows[0]["Employee_Name"].ToString(); userid = dtmstuser.Rows[0]["User_id"].ToString(); USerRoleid = dtmstuser.Rows[0]["User_RoleId"].ToString(); Branch_id = int.Parse(dtmstuser.Rows[0]["Branch_ID"].ToString()); Application_Login_Id = dtmstuser.Rows[0]["Application_Login_Type"].ToString(); // last_login_datetime = dtmstuser.Rows[0]["Last_login"].ToString(); } else { txt_Emp_Code.Text = ""; txt_Emp_Code.Focus(); // ScriptManager.RegisterClientScriptBlock(this, GetType(), "alert", "alert('Username Does Not Exist');", true); MessageBox.Show("Username Does Not Exist"); } if (Confirmusername == empCode && ConfirmPassword == password) { SplashScreenManager.ShowForm(this, typeof(Ordermanagement_01.Masters.WaitForm1), true, true, false); try { string userID = userid; DataTable dt_Employee_Status = new DataTable(); Hashtable ht_Employee_Status = new Hashtable(); ht_Employee_Status.Add("@Trans", "Log_In_Present"); ht_Employee_Status.Add("@Presents", "True"); ht_Employee_Status.Add("@Employee_Id", userid); dt_Employee_Status = Dataaccess.ExecuteSP("Sp_Employee_Status", ht_Employee_Status); if (Application_Login_Id == "1") { AdminDashboard mainmenu = new AdminDashboard(USerRoleid, userid, Empname, password); mainmenu.Show(); } else if (Application_Login_Id == "2") { Tax.Tax_New_Dashboard taxdashboard = new Tax.Tax_New_Dashboard(USerRoleid, userid, Empname); taxdashboard.Show(); } Ordermanagement_01.Gen_Forms.Login loginfrm = new Ordermanagement_01.Gen_Forms.Login(); loginfrm.Close(); this.Hide(); } catch (Exception ex) { //Close Wait Form SplashScreenManager.CloseForm(false); MessageBox.Show("Error Occured Please Check With Administrator"); } finally { //Close Wait Form SplashScreenManager.CloseForm(false); } } else { // ScriptManager.RegisterClientScriptBlock(this, GetType(), "alert", "alert('Wrong User Name or Password');", true); MessageBox.Show("Wrong User Name or Password"); } // Hashtable htuser = new Hashtable(); // DataTable dtuser = new DataTable(); // Username = txt_username.Text.ToString(); // password = txt_password.Text.ToString(); // htuser.Add("@Trans", "SELUSER"); // htuser.Add("@User_Name", Username); // dtuser = Dataaccess.ExecuteSP("Sp_User", htuser); // if (dtuser.Rows.Count > 0) // { // Confirmusername = dtuser.Rows[0]["User_Name"].ToString(); // userid = dtuser.Rows[0]["User_id"].ToString(); // } // else // { // txt_username.Text = ""; // txt_username.Focus(); // // ScriptManager.RegisterClientScriptBlock(this, GetType(), "alert", "alert('Username Does Not Exist');", true); // MessageBox.Show("Username Does Not Exist"); // } // Hashtable htpassword = new Hashtable(); // DataTable dtpassword = new DataTable(); // htpassword.Add("@Trans", "SELPASS"); // htpassword.Add("@User_Name", Username); // htpassword.Add("@Password", password); // htpassword.Add("@User_id", userid); // dtpassword = Dataaccess.ExecuteSP("Sp_User", htpassword); // if (dtpassword.Rows.Count > 0) // { // ConfirmPassword = dtpassword.Rows[0]["Password"].ToString(); // Userid = dtpassword.Rows[0]["User_id"].ToString(); // } // else // { // txt_password.Text = ""; // txt_password.Focus(); // // ScriptManager.RegisterClientScriptBlock(this, GetType(), "alert", "alert('Invalid Password');", true); // MessageBox.Show("Invalid Password"); // return; // } // DataTable dt = new DataTable(); // Hashtable ht = new Hashtable(); // ht.Add("@Trans", "USERWISE"); // ht.Add("@User_id", Userid); //// Session["userid"] = userid.ToString(); // dt = Dataaccess.ExecuteSP("Sp_User", ht); // if (dt.Rows.Count > 0) // { // RollName = dt.Rows[0]["Role_Name"].ToString(); // // Session["Employee_Id"] = dt.Rows[0]["Employee_Id"].ToString(); // } }
private async void Validate_User() { string _Emp_Code = textEditUsername.Text.ToString().ToUpper(); _Password = textEditPassword.Text.ToString(); _User_det.DRN_Emp_Code = _Emp_Code; _User_det.Password = _Password; using (var Client = new HttpClient()) { var serializedUser = JsonConvert.SerializeObject(_User_det); var content = new StringContent(serializedUser, Encoding.UTF8, "application/json"); var result = await Client.PostAsync(Base_Url.Url + "/Login/Validate_User", content); if (result.IsSuccessStatusCode) { var UserJsonString = await result.Content.ReadAsStringAsync(); var objResultData = JsonConvert.DeserializeObject <Result_Data>(UserJsonString); if (objResultData.Users != null && objResultData.Users.Count > 0) { List <Models.Users> _Rlist_data = objResultData.Users.ToList(); //if (_Result == 0) //{ _Application_Login_Type = _Rlist_data[0].Application_Login_Type; _User_Id = _Rlist_data[0].User_id; _User_Role_Id = _Rlist_data[0].User_RoleId; _User_Name = _Rlist_data[0].DRN_Emp_Code; _Employee_Name = _Rlist_data[0].Employee_Name; _ShiftType = _Rlist_data[0].Shift_Type_Id; _Branch_Id = _Rlist_data[0].Branch_ID; await GetToken(_User_Name, _Password); if (_Application_Login_Type == 1) { if (_User_Role_Id == 2) { Employee.Dashboard dashboard = new Employee.Dashboard(_User_Id, _User_Role_Id, _Password, _Branch_Id, _ShiftType); Invoke(new MethodInvoker(delegate { dashboard.Show(); })); } else { AdminDashboard mainmenu = new AdminDashboard(_User_Role_Id.ToString(), _User_Id.ToString(), _User_Name, _Password); mainmenu.Show(); } } else if (_Application_Login_Type == 2) { Tax.Tax_New_Dashboard taxdashboard = new Tax.Tax_New_Dashboard(_User_Role_Id.ToString(), _User_Id.ToString(), _Employee_Name); taxdashboard.Show(); } btnLogin.Enabled = true; SplashScreenManager.CloseForm(false); NewLogin _Form_New_Login = new NewLogin(); _Form_New_Login.Close(); this.Hide(); //} //else //{ // btnLogin.Enabled = true; // IsClicked = false; // SplashScreenManager.CloseForm(false); // XtraMessageBox.Show("something went wrong"); //} } else { btnLogin.Enabled = true; IsClicked = false; SplashScreenManager.CloseForm(false); XtraMessageBox.Show("Wrong User Name and Password"); } } else { btnLogin.Enabled = true; IsClicked = false; SplashScreenManager.CloseForm(false); } } }