private void btnSave_Click(object sender, EventArgs e) { if (Them) { try { if (dbNV.ThemNhanVien(this.txtMaNV.Text.Trim(), this.txtHovalotNV.Text.Trim(), this.txtTenNV.Text.Trim(), cbbMaCV.Text, int.Parse(nmrSoGioLam.Value.ToString()), NQL, cbChiNhanh.SelectedValue.ToString(), ref err)) { MessageBox.Show("Đã thêm xong!"); dbDangNhap.TaoTaiKhoan(txtMaNV.Text.Trim(), "1", ref err); dbDangNhap.Encrypt(txtMaNV.Text.Trim()); } LoadData(); } catch (SqlException) { MessageBox.Show("Không thêm được. Lỗi rồi!"); } } else { dbNV.CapNhatNhanVien(this.txtHovalotNV.Text.Trim(), this.txtTenNV.Text.Trim(), this.cbbMaCV.Text, this.txtMaNV.Text, int.Parse(nmrSoGioLam.Value.ToString()), NQL, cbChiNhanh.SelectedValue.ToString(), ref err); LoadData(); MessageBox.Show("Đã sửa xong!"); } }
private void button_LOGIN_Click(object sender, EventArgs e) { if (txtUsername.Text.Equals("") || txtPassword.Text.Equals("")) { return; } else { dbDangNhap.Decrypt(txtUsername.Text.Trim()); DataSet ds = dbDangNhap.FindUser(txtUsername.Text, txtPassword.Text); dbDangNhap.Encrypt(txtUsername.Text.Trim()); if (ds.Tables[0].Rows.Count > 0) { DataSet ds1 = dbNhanVien.LayChucVuNV(txtUsername.Text); if (ds1.Tables[0].Rows.Count > 0) { Program.ChucVuUser = ds1.Tables[0].Rows[0].ItemArray[0].ToString(); Program.UserName = txtUsername.Text; this.Hide(); User us = new User(); us.MaNV = txtUsername.Text.Trim(); Form1 mainform = new Form1(us.MaNV); mainform.ShowDialog(); this.Close(); //this.ShowInTaskbar = false; } else { MessageBox.Show("Đăng nhập thât bại", "Thông báo!!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } }