private void btnLogin_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtUsername.Text)) { MessageBox.Show("E-mail daxil edin"); return; } if (string.IsNullOrEmpty(txtPassword.Text)) { MessageBox.Show("Şifrə daxil edin"); return; } User user = _context.Users.FirstOrDefault(u => u.Username == txtUsername.Text); if (user != null && Crypto.VerifyHashedPassword(user.Password, txtPassword.Text)) { dashboardForm dashboard = new dashboardForm(); dashboard.Show(); this.Hide(); return; } MessageBox.Show("Username ve ya sifre yanlisdir"); }
private void buttonLogin_Click(object sender, EventArgs e) { MyDB db = new MyDB(); SqlDataAdapter adapter = new SqlDataAdapter(); DataTable table = new DataTable(); string query = "SELECT * FROM Login WHERE username=@User AND password=@Pass"; if (radioButtonParking.Checked == true) { query = "SELECT * FROM Tho WHERE Username=@User AND Password=@Pass AND LoaiNguoiDung = 'Parking'"; } else if (radioButtonWorker.Checked) { query = "SELECT * FROM Tho WHERE Username=@User AND Password=@Pass AND (LoaiNguoiDung = 'Worker')"; } SqlCommand cmd = new SqlCommand(query, db.getConnection); cmd.Parameters.Add("@User", SqlDbType.VarChar).Value = textBoxUser.Text; cmd.Parameters.Add("@Pass", SqlDbType.VarChar).Value = textBoxPassword.Text; adapter.SelectCommand = cmd; adapter.Fill(table); if ((table.Rows.Count > 0)) { Checkin_out check_time = new Checkin_out(); Globals.GlobalUserID = Convert.ToInt32(table.Rows[0][0].ToString()); Globals.time_in = DateTime.Now; this.Close(); if (radioButtonHumanResourse.Checked) { dashboardForm dashboard = new dashboardForm(); dashboard.ShowDialog(this); } else if (radioButtonParking.Checked) { if (check_time.insert_Checkin(Globals.GlobalUserID, Globals.time_in)) { MessageBox.Show("Check in Sucessfully!", "Check in", MessageBoxButtons.OK, MessageBoxIcon.Information); manageVehiclesForm manageVehicles = new manageVehiclesForm(); manageVehicles.ShowDialog(this); } } else { if (check_time.insert_Checkin(Globals.GlobalUserID, Globals.time_in)) { MessageBox.Show("Check in Sucessfully!", "Check in", MessageBoxButtons.OK, MessageBoxIcon.Information); wokerDashBoardForm woker = new wokerDashBoardForm(); woker.ShowDialog(this); } } } else { MessageBox.Show("Invalid Username or Password", "Login error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void salaryDetailForm_Load(object sender, EventArgs e) { dataGridViewSalaryDetail.ReadOnly = true; dataGridViewSalaryDetail.AllowUserToAddRows = false; Vehicle vehicle = new Vehicle(); dashboardForm dashboard = new dashboardForm(); string query = "select Tho.MaTho, Tho.TenTho, Tho.CMND, Tho.SDT, Tho.DiaChi, checkin_time, checkout_time, DATEDIFF(hour, checkin_time, checkout_time) as 'Working Time', MucLuong.Luong as 'MucLuong', DATEDIFF(hour, checkin_time, checkout_time) * MucLuong.Luong as 'Luong' " + "from Tho inner join Luong on Tho.MaTho = Luong.MaTho" + " inner join MucLuong on MucLuong.LoaiTho = Tho.LoaiNguoiDung " + "where Tho.MaTho = " + Convert.ToInt32(id); dataGridViewSalaryDetail.DataSource = vehicle.getVehicle(new System.Data.SqlClient.SqlCommand(query)); }