private void dataGridViewPhongban_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { //MessageBox.Show(dataGridViewNhanVien.Rows[e.RowIndex].Cells["Mã nhân viên"].Value.ToString()); var mnv = dataGridViewPhongban.Rows[e.RowIndex].Cells["Mã phòng ban"].Value.ToString(); if (!string.IsNullOrEmpty(mnv)) { var r = new DatabaseNV().Select("SELECTPHONGBAN '" + mnv + "'"); this.textBoxMaPB.Text = mnv; this.textBoxTenPB.Text = r["TenPB"].ToString(); this.textBoxDiaChiPB.Text = r["DiaChi"].ToString(); if (!string.IsNullOrEmpty(r["MaTP"].ToString())) { this.textBoxMaTP.Text = r["MaTP"].ToString(); } else { this.textBoxMaTP.Text = ""; } if (!string.IsNullOrEmpty(r["TenTP"].ToString())) { this.textBoxTenTP.Text = r["TenTP"].ToString(); } else { this.textBoxTenTP.Text = ""; } this.buttonSua.Enabled = true; } } }
public bool CheckCMND(string S) { if (S.Length != 9 && S.Length != 12) { return(false); } else { bool Result = true; foreach (Char c in S) { if (!Char.IsDigit(c)) { Result = false; } } if (Result == true) { var r = new DatabaseNV().Select("EXEC CHECKCMND '" + S + "'"); if (r["TonTai"].ToString() == "1") { Result = false; } } return(Result); } }
private void dangNhap_btn_Click(object sender, EventArgs e) { string check; check = BUS_Login.Instance.CheckLogin((Object)tenDangNhap_txb.Text, (Object)matKhau_txb.Text); if (check == "1") { List <CustomerParameter> lst = new List <CustomerParameter>(); lst.Add(new CustomerParameter() { key = "@manhanvien", value = this.tenDangNhap_txb.Text }); var r = new DatabaseNV().SelectData("CHECKHOPDONG", lst); int n = Convert.ToInt32(r.Rows[0]["TrangThai"].ToString()); if (n == 1) { this.Hide(); string mnv = this.tenDangNhap_txb.Text; Form1 fm = new Form1(mnv); fm.ShowDialog(); this.Close(); } else { MessageBox.Show("Hợp đồng của bạn đã hết hạn!"); } } else { MessageBox.Show("Tên đăng nhập hoặc Mật khẩu không chính xác!"); } }
private void buttonChange_Click(object sender, EventArgs e) { List <CustomerParameter> lst = new List <CustomerParameter>(); lst.Add(new CustomerParameter() { key = "@manhanvien", value = this.textBoxMaNV.Text }); lst.Add(new CustomerParameter() { key = "@luongCB", value = this.textBoxLuongCB.Text }); lst.Add(new CustomerParameter() { key = "@luongthuong", value = this.textBoxLuongThuong.Text }); lst.Add(new CustomerParameter() { key = "@songaytangca", value = this.numericUpDown1.Value.ToString() }); lst.Add(new CustomerParameter() { key = "@tongluong", value = this.textBoxTongLuong.Text }); lst.Add(new CustomerParameter() { key = "@ghichu", value = this.textBoxNote.Text }); var r = new DatabaseNV().Excute("UPDATELUONG", lst, null); if (r > 0) { MessageBox.Show("Cập nhật thành công."); } }
private void buttonSua_Click(object sender, EventArgs e) { if (this.buttonSua.Text == "SỬA") { this.dataGridViewPhongban.Enabled = false; this.buttonThem.Enabled = false; this.textBoxMaTP.Enabled = false; this.textBoxTenTP.Enabled = false; this.textBoxMaPB.Enabled = false; this.textBoxTenPB.Enabled = true; this.textBoxDiaChiPB.Enabled = true; this.buttonSua.Text = "LƯU"; return; } if (this.buttonSua.Text == "LƯU") { if (this.textBoxTenPB.Text == "") { MessageBox.Show("Tên phòng ban không hợp lệ"); } else { if (this.textBoxDiaChiPB.Text == "") { MessageBox.Show("Địa chỉ phòng ban không hợp lệ"); } else { List <CustomerParameter> lst = new List <CustomerParameter>(); lst.Add(new CustomerParameter() { key = "@MaPB", value = this.textBoxMaPB.Text }); lst.Add(new CustomerParameter() { key = "@TenPB", value = this.textBoxTenPB.Text }); lst.Add(new CustomerParameter() { key = "@DiaChi", value = this.textBoxDiaChiPB.Text }); var rs = new DatabaseNV().Excute("SuaPB", lst, null); if (rs > 0) { MessageBox.Show("Cập nhật thành công."); //this.Dispose(); } this.dataGridViewPhongban.Enabled = true; this.buttonThem.Enabled = true; this.textBoxTenPB.Enabled = false; this.textBoxDiaChiPB.Enabled = false; this.buttonSua.Text = "SỬA"; LoadAgain(); return; } } } }
private void LoadAgain() { var r = new DatabaseNV(); List <CustomerParameter> lst = new List <CustomerParameter>(); DataTable dt = r.SelectData("Load", lst); this.dataGridViewPhongban.DataSource = dt; this.buttonSua.Enabled = false; }
private void FormThemNhanVien_Load(object sender, EventArgs e) { var r = new DatabaseNV().Select("MANVMAX"); int n = Int32.Parse(r["MaLonNhat"].ToString()); n = n + 1; if (n < 10) { this.textBoxMaNV.Text = String.Concat("NV", "0000000", n.ToString()); } if (n > 9 && n < 100) { this.textBoxMaNV.Text = String.Concat("NV", "000000", n.ToString()); } if (n > 99 && n < 1000) { this.textBoxMaNV.Text = String.Concat("NV", "00000", n.ToString()); } if (n > 999 && n < 10000) { this.textBoxMaNV.Text = String.Concat("NV", "0000", n.ToString()); } if (n > 9999 && n < 100000) { this.textBoxMaNV.Text = String.Concat("NV", "000", n.ToString()); } if (n > 99999 && n < 1000000) { this.textBoxMaNV.Text = String.Concat("NV", "00", n.ToString()); } if (n > 999999 && n < 10000000) { this.textBoxMaNV.Text = String.Concat("NV", "0", n.ToString()); } if (n > 9999999 && n < 100000000) { this.textBoxMaNV.Text = String.Concat("NV", n.ToString()); } DateTime now = DateTime.Now; this.maskedTextBoxNgayKy.Text = now.ToString("dd/MM/yyyy"); string conString = ConfigurationManager.ConnectionStrings["myconnection"].ConnectionString; SqlConnection sqlCon = new SqlConnection(conString); sqlCon.Open(); comboBoxPhongBan.Items.Clear(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM PHONGBAN", sqlCon); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { comboBoxPhongBan.Items.Add(dt.Rows[i]["TenPB"]); } }
private void buttonRefresh_Click(object sender, EventArgs e) { List <CustomerParameter> lst = new List <CustomerParameter>(); var rs = new DatabaseNV().Excute("REFRESH", lst, null); if (rs > 0) { MessageBox.Show("Làm mới thành công"); } }
private void comboBoxPhongban_TextChanged(object sender, EventArgs e) { string TenPB = this.comboBoxPhongban.Text; List <CustomerParameter> lst = new List <CustomerParameter>(); lst.Add(new CustomerParameter() { key = "@tenphongban", value = TenPB }); var r = new DatabaseNV(); dataGridViewLuong.DataSource = r.SelectData("BANGLUONGTHEOPHONG", lst); }
public Form1(string mnv) { this.MaNV = mnv; List <CustomerParameter> lst = new List <CustomerParameter>(); lst.Add(new CustomerParameter() { key = "@manhanvien", value = mnv }); var r = new DatabaseNV().SelectData("LEVELDANGNHAP", lst); this.Level = Convert.ToInt32(r.Rows[0]["Level"].ToString()); InitializeComponent(); hideSubMenu(); }
private void dgvKetQua_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { //MessageBox.Show(dataGridViewNhanVien.Rows[e.RowIndex].Cells["Mã nhân viên"].Value.ToString()); var mnv = dgvKetQua.Rows[e.RowIndex].Cells["Mã nhân viên"].Value.ToString(); List <CustomerParameter> lst = new List <CustomerParameter>(); lst.Add(new CustomerParameter() { key = "@manhanvien", value = mnv }); var r = new DatabaseNV().SelectData("LEVELDANGNHAP", lst); int m = Convert.ToInt32(r.Rows[0]["Level"].ToString()); new ThongTinNhanVien(mnv, this.Level, m).ShowDialog(); LoadAgain(); } }
public void ThongTinLuongNhanVien(string mnv, int Level, int Object) { var r = new DatabaseNV().Select("SELECTLUONG '" + mnv + "'"); this.textBoxMaNV.Text = r["MaNV"].ToString(); this.textBoxHoten.Text = r["HoTen"].ToString(); string[] arr = r["LuongCB"].ToString().Split('.'); this.textBoxLuongCB.Text = arr[0]; this.textBoxLuongThuong.Text = r["LuongThuong"].ToString(); this.numericUpDown1.Value = Int32.Parse(r["SoNgayTangCa"].ToString()); this.textBoxTongLuong.Text = r["TongLuong"].ToString(); this.textBoxNote.Text = r["GhiChu"].ToString(); if (Level > Object) { this.panel2.Enabled = false; } else { if (Level == Object) { if (Level > 1) { this.panel2.Enabled = false; } else { this.panel2.Enabled = false; } } else { if (Level == 2 && Object == 3) { this.panel2.Enabled = false; } else if (Level == 4 && Object == 5) { this.panel2.Enabled = false; } else { this.panel2.Enabled = true; } } } }
private void Hopdong_Load(object sender, EventArgs e) { var r = new DatabaseNV().Select("SELECTHOPDONG '" + manv + "'"); this.textBoxHoTen.Text = r["HoTen"].ToString(); this.textBoxMaNV.Text = r["MaNV"].ToString(); this.comboBoxGioitinh.Text = r["GioiTinh"].ToString(); this.maskedTextBoxNgaysinh.Text = r["NgaySinh"].ToString(); this.maskedTextBoxNgayky.Text = r["NgayKi"].ToString(); this.maskedTextBoxNgayhethan.Text = r["NgayHetHan"].ToString(); if (r["TenHD"].ToString() == "Hợp Đồng Có Thời Hạn") { this.comboBoxHopDong.Text = "Có thời hạn"; } if (r["TenHD"].ToString() == "Hợp Đồng Không Thời Hạn") { this.comboBoxHopDong.Text = "Không thời hạn"; } }
private void DanhSachLuong_Load(object sender, EventArgs e) { ThongTinLuongNhanVien(this.Manhanvien, this.Level, this.Level); if (this.Level > 5) { this.panel1.Enabled = false; this.panel2.Enabled = false; } else if (this.Level > 3 && this.Level <= 5) { this.buttonRefresh.Enabled = false; var r = new DatabaseNV().Select("TIMPHONGBANTHEONHANVIEN '" + this.Manhanvien + "'"); string tenPB = r["TenPB"].ToString(); this.comboBoxPhongban.Items.Clear(); this.comboBoxPhongban.Items.Add(tenPB); this.textBoxLuongCB.Enabled = false; } }
private void dgrChucVu_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { var r = dgrChucVu.Rows[e.RowIndex].Cells["Mã chức vụ"].Value.ToString(); this.button2.Text = "SỬA"; this.txtTenCV.ReadOnly = true; if (!string.IsNullOrEmpty(r)) { var rs = new DatabaseNV().Select("SELECT * FROM CHUCVU WHERE MaCV = '" + r + "'"); this.txtMaCV.Text = rs["MaCV"].ToString(); this.txtTenCV.Text = rs["TenCV"].ToString(); this.button2.Enabled = true; } else { this.button2.Enabled = false; } } }
private void dataGridViewLuong_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { //MessageBox.Show(dataGridViewNhanVien.Rows[e.RowIndex].Cells["Mã nhân viên"].Value.ToString()); var mnv = dataGridViewLuong.Rows[e.RowIndex].Cells["Mã nhân viên"].Value.ToString(); if (!string.IsNullOrEmpty(mnv)) { List <CustomerParameter> lst = new List <CustomerParameter>(); lst.Add(new CustomerParameter() { key = "@manhanvien", value = mnv }); var r = new DatabaseNV().SelectData("LEVELDANGNHAP", lst); int n = Convert.ToInt32(r.Rows[0]["Level"].ToString()); ThongTinLuongNhanVien(mnv, this.Level, n); } } }
public void LoadAgain() { var db = new DatabaseNV(); List <CustomerParameter> lst = new List <CustomerParameter>(); lst.Add(new CustomerParameter() { key = "@tukhoa", value = textBoxTimkiem.Text }); string sql = ""; if (this.radioButton1.Checked == true) { sql = "SelectAllNhanVien"; } if (this.radioButton2.Checked == true) { sql = "SelectAllNhanVienHetHan"; } dgvKetQua.DataSource = db.SelectData(sql, lst); }
private void button1_Click(object sender, EventArgs e) { string sql = "DELETENHANVIEN"; List <CustomerParameter> lstPara = new List <CustomerParameter>(); lstPara.Add(new CustomerParameter() { key = "@manhanvien", value = manv }); var rs = new DatabaseNV().Excute(sql, lstPara, null); if (rs > 0) { MessageBox.Show("Xóa thành công"); this.Dispose(); } else { MessageBox.Show("Xóa thất bại"); this.Dispose(); } }
private void buttonLuu_Click(object sender, EventArgs e) { string sql = "UPDATENHANVIEN"; string Name = textBoxHoTen.Text; string Gioitinh = comboBoxGioitinh.Text; DateTime ngaysinh; try { ngaysinh = DateTime.ParseExact(maskedTextBoxNgaysinh.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch (Exception) { MessageBox.Show("Ngày sinh không hợp lệ"); maskedTextBoxNgaysinh.Select(); return; } string DiaChi = textBoxDiaChi.Text; string ChucVu = comboboxChucVu.Text; string sdt = textBoxSDT.Text; string BangCap = textBoxBangCap.Text; string Phongban = comboBoxPhongBan.Text; string Vitri = comboBoxViTri.Text; List <CustomerParameter> lstPara = new List <CustomerParameter>(); lstPara.Add(new CustomerParameter() { key = "@manhanvien", value = mnv }); lstPara.Add(new CustomerParameter() { key = "@Gioitinh", value = Gioitinh }); lstPara.Add(new CustomerParameter() { key = "@Hoten", value = Name }); lstPara.Add(new CustomerParameter() { key = "@ngaysinh", value = ngaysinh.ToString("yyyy-MM-dd") }); lstPara.Add(new CustomerParameter() { key = "@diachi", value = DiaChi }); lstPara.Add(new CustomerParameter() { key = "@sodienthoai", value = sdt }); lstPara.Add(new CustomerParameter() { key = "@chucvu", value = ChucVu }); lstPara.Add(new CustomerParameter() { key = "@bangcap", value = BangCap }); lstPara.Add(new CustomerParameter() { key = "@phongban", value = Phongban }); lstPara.Add(new CustomerParameter() { key = "@vitricongviec", value = Vitri }); var rs = new DatabaseNV().Excute(sql, lstPara, null); if (rs > 0) { MessageBox.Show("Cập nhật thành công."); this.Dispose(); } }
private void buttonThem_Click(object sender, EventArgs e) { DateTime ngaysinh; DateTime ngayhethan; DateTime now = DateTime.Now; try { ngaysinh = DateTime.ParseExact(maskedTextBoxNgaysinh.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch (Exception) { MessageBox.Show("Ngày sinh không hợp lệ"); maskedTextBoxNgaysinh.Select(); return; } if (DateTime.Compare(ngaysinh, now) >= 0) { MessageBox.Show("Ngày sinh không hợp lệ"); maskedTextBoxNgaysinh.Select(); return; } if (CheckCMND(this.textBoxCMND.Text) == false) { MessageBox.Show("Số CMND không hợp lệ"); this.textBoxCMND.Select(); return; } if (this.textBoxDanToc.Text == "") { MessageBox.Show("Chưa điền dân tộc"); return; } if (this.comboBox1.Text == "Có thời hạn") { try { ngayhethan = DateTime.ParseExact(this.maskedTextBoxNgayHetHan.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch (Exception) { MessageBox.Show("Ngày hết hạn không hợp lệ"); this.maskedTextBoxNgayHetHan.Select(); return; } if (DateTime.Compare(ngayhethan, now) <= 0) { MessageBox.Show("Ngày hết hạn không hợp lệ"); this.maskedTextBoxNgayHetHan.Select(); return; } } if (this.comboBoxPhongBan.Text == "") { MessageBox.Show("Chưa có phòng ban"); return; } if (this.comboBoxViTri.Text == "") { if (this.comboboxChucVu.Text != "Lao công" && this.comboboxChucVu.Text != "Chủ tịch") { MessageBox.Show("Vị trí không hợp lệ"); return; } } if (CheckLuong(this.textBox1.Text) == false) { MessageBox.Show("Số lương không hợp lệ"); this.textBox1.Select(); return; } string sql = "THEMMOINHANVIEN"; List <CustomerParameter> lstPara = new List <CustomerParameter>(); lstPara.Add(new CustomerParameter() { key = "@manhanvien", value = this.textBoxMaNV.Text }); lstPara.Add(new CustomerParameter() { key = "@gioitinh", value = this.comboBoxGioitinh.Text }); lstPara.Add(new CustomerParameter() { key = "@hoten", value = this.textBoxHoTen.Text }); lstPara.Add(new CustomerParameter() { key = "@ngaysinh", value = ngaysinh.ToString("yyyy-MM-dd") }); lstPara.Add(new CustomerParameter() { key = "@diachi", value = this.textBoxDiaChi.Text }); lstPara.Add(new CustomerParameter() { key = "@sdt", value = this.textBoxSDT.Text }); lstPara.Add(new CustomerParameter() { key = "@cmnd", value = this.textBoxCMND.Text }); lstPara.Add(new CustomerParameter() { key = "@dantoc", value = this.textBoxDanToc.Text }); lstPara.Add(new CustomerParameter() { key = "@tongiao", value = this.textBoxTongiao.Text }); lstPara.Add(new CustomerParameter() { key = "@bangcap", value = this.textBoxBangCap.Text }); lstPara.Add(new CustomerParameter() { key = "@hopdong", value = this.comboBox1.Text }); lstPara.Add(new CustomerParameter() { key = "@ngayky", value = now.ToString("yyyy-MM-dd") }); if (this.comboBox1.Text == "Không thời hạn") { lstPara.Add(new CustomerParameter() { key = "@ngayhethan", value = ngaysinh.ToString("yyyy-MM-dd") }); } else { lstPara.Add(new CustomerParameter() { key = "@ngayhethan", value = DateTime.ParseExact(maskedTextBoxNgayHetHan.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd") }); } lstPara.Add(new CustomerParameter() { key = "@phongban", value = this.comboBoxPhongBan.Text }); lstPara.Add(new CustomerParameter() { key = "@chucvu", value = this.comboboxChucVu.Text }); lstPara.Add(new CustomerParameter() { key = "@vitri", value = this.comboBoxViTri.Text }); lstPara.Add(new CustomerParameter() { key = "@luong", value = this.textBox1.Text }); var r = new DatabaseNV().Excute(sql, lstPara, null); if (r > 0) { MessageBox.Show("Thêm thành công."); this.Dispose(); } }
private void button4_Click(object sender, EventArgs e) { if (this.button4.Text == "THÊM") { this.txtTenCV.ReadOnly = false; this.dgrChucVu.Enabled = false; var r = new DatabaseNV().Select("MACVMAX"); int n = Int32.Parse(r["MaLonNhat"].ToString()); n = n + 1; if (n < 10) { this.txtMaCV.Text = String.Concat("CV", "0000000", n.ToString()); } if (n > 9 && n < 100) { this.txtMaCV.Text = String.Concat("CV", "000000", n.ToString()); } if (n > 99 && n < 1000) { this.txtMaCV.Text = String.Concat("CV", "00000", n.ToString()); } if (n > 999 && n < 10000) { this.txtMaCV.Text = String.Concat("CV", "0000", n.ToString()); } if (n > 9999 && n < 100000) { this.txtMaCV.Text = String.Concat("CV", "000", n.ToString()); } if (n > 99999 && n < 1000000) { this.txtMaCV.Text = String.Concat("CV", "00", n.ToString()); } if (n > 999999 && n < 10000000) { this.txtMaCV.Text = String.Concat("CV", "0", n.ToString()); } if (n > 9999999 && n < 100000000) { this.txtMaCV.Text = String.Concat("CV", n.ToString()); } this.txtTenCV.Text = ""; this.button2.Enabled = false; this.button4.Text = "LƯU"; return; } else { if (txtTenCV.Text == "") { MessageBox.Show("Chưa có tên chức vụ"); this.button4.Text = "THÊM"; this.txtTenCV.ReadOnly = true; this.dgrChucVu.Enabled = true; LoadAgain(); return; } else { bool check = BUS.BUS_ChucVu.Instance.ThemChucVu(txtMaCV.Text, txtTenCV.Text); if (check) { MessageBox.Show("Thêm thành công"); this.button4.Text = "THÊM"; this.txtTenCV.ReadOnly = true; } else { MessageBox.Show("Thêm thất bại"); } this.button4.Text = "THÊM"; this.txtTenCV.ReadOnly = true; this.dgrChucVu.Enabled = true; LoadAgain(); return; } } }
private void buttonThem_Click(object sender, EventArgs e) { if (this.buttonThem.Text == "THÊM") { this.buttonSua.Enabled = false; this.textBoxDiaChiPB.Enabled = true; this.textBoxMaPB.Enabled = true; this.textBoxTenPB.Enabled = true; this.dataGridViewPhongban.Enabled = false; this.textBoxDiaChiPB.Text = ""; this.textBoxMaPB.Text = ""; this.textBoxTenPB.Text = ""; this.textBoxMaTP.Text = ""; this.textBoxTenTP.Text = ""; this.buttonThem.Text = "LƯU"; return; } if (this.buttonThem.Text == "LƯU") { if (this.textBoxMaPB.Text == "") { MessageBox.Show("Mã phòng ban không hợp lệ."); } else { string s = this.textBoxMaPB.Text; var r = new DatabaseNV().Select("SELECT CASE WHEN EXISTS(SELECT * FROM PHONGBAN WHERE MaPB = '" + s + "') THEN 1 WHEN NOT EXISTS(SELECT * FROM PHONGBAN WHERE MaPB = '" + s + "') THEN 0 END AS Flag"); if (r["Flag"].ToString() == "1") { MessageBox.Show("Mã phòng ban đã tồn tại."); } else { if (this.textBoxTenPB.Text == "") { MessageBox.Show("Tên phòng ban không hợp lệ."); } else { if (this.textBoxDiaChiPB.Text == "") { MessageBox.Show("Địa chỉ phòng ban không hợp lệ."); } else { string sql = "ThemPB"; List <CustomerParameter> lstpara = new List <CustomerParameter>(); lstpara.Add(new CustomerParameter() { key = "@MaPB", value = this.textBoxMaPB.Text }); lstpara.Add(new CustomerParameter() { key = "@TenPB", value = this.textBoxTenPB.Text }); lstpara.Add(new CustomerParameter() { key = "@DiaChi", value = this.textBoxDiaChiPB.Text }); var rs = new DatabaseNV().Excute(sql, lstpara, null); if (rs > 0) { MessageBox.Show("Thêm thành công."); //this.Dispose(); } } } } } this.buttonSua.Enabled = true; this.textBoxDiaChiPB.Enabled = false; this.textBoxMaPB.Enabled = false; this.textBoxTenPB.Enabled = false; this.dataGridViewPhongban.Enabled = true; this.buttonThem.Text = "THÊM"; LoadAgain(); return; } }
private void buttonSua_Click(object sender, EventArgs e) { if (this.buttonSua.Text == "THAY ĐỔI") { this.comboBoxHopDong.Enabled = true; this.maskedTextBoxNgayhethan.Enabled = true; this.buttonSua.Text = "LƯU"; return; } if (this.buttonSua.Text == "LƯU") { DateTime ngayhethan; DateTime now = DateTime.Now; if (this.comboBoxHopDong.Text == "Có thời hạn") { try { ngayhethan = DateTime.ParseExact(this.maskedTextBoxNgayhethan.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch (Exception) { MessageBox.Show("Ngày hết hạn không hợp lệ"); this.maskedTextBoxNgayhethan.Select(); return; } if (DateTime.Compare(ngayhethan, now) <= 0) { MessageBox.Show("Ngày hết hạn không hợp lệ"); this.maskedTextBoxNgayhethan.Select(); return; } } string sql = "UPDATEHOPDONG"; List <CustomerParameter> lst = new List <CustomerParameter>(); lst.Add(new CustomerParameter() { key = "@manhanvien", value = manv }); lst.Add(new CustomerParameter() { key = "@tenhopdong", value = this.comboBoxHopDong.Text }); if (this.comboBoxHopDong.Text == "Có thời hạn") { lst.Add(new CustomerParameter() { key = "@ngayhethan", value = DateTime.ParseExact(this.maskedTextBoxNgayhethan.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd") }); } else { lst.Add(new CustomerParameter() { key = "@ngayhethan", value = now.ToString("yyyy-MM-dd") }); } var rs = new DatabaseNV().Excute(sql, lst, null); if (rs > 0) { MessageBox.Show("Cập nhật thành công."); this.Dispose(); } else { MessageBox.Show("Cập nhật thất bại."); this.Dispose(); } } }
private void ThongTinNhanVien_Load(object sender, EventArgs e) { var r = new DatabaseNV().Select("SELECTNhanVien '" + mnv + "'"); textBoxMaNV.Text = mnv; textBoxHoTen.Text = r["HoTen"].ToString(); textBoxCMND.Text = "xxxxxxxxxxxx"; textBoxSDT.Text = r["SDT"].ToString(); textBoxDiaChi.Text = r["DiaChi"].ToString(); maskedTextBoxNgaysinh.Text = r["NgaySinh"].ToString(); //// Convert to Date có vấn đề //maskedTextBoxNgayvaolam.Text = r["NgayVaoLam"].ToString(); comboBoxGioitinh.Text = r["GioiTinh"].ToString(); textBoxBangCap.Text = r["BangCap"].ToString(); this.textBoxtongiao.Text = r["TonGiao"].ToString(); this.textBoxdantoc.Text = r["DanToc"].ToString(); this.mnv = mnv; string conString = ConfigurationManager.ConnectionStrings["myconnection"].ConnectionString; SqlConnection sqlCon = new SqlConnection(conString); sqlCon.Open(); comboboxChucVu.Items.Clear(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM CHUCVU", sqlCon); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { if (this.Level == 1) { comboboxChucVu.Items.Add(dt.Rows[i]["TenCV"]); } else if (this.Level == 2 || this.Level == 3) { if (dt.Rows[i]["TenCV"].ToString() != "Chủ tịch" && dt.Rows[i]["TenCV"].ToString() != "Giám đốc" && dt.Rows[i]["TenCV"].ToString() != "Phó giám đốc") { comboboxChucVu.Items.Add(dt.Rows[i]["TenCV"]); } } else { comboboxChucVu.Items.Add(dt.Rows[i]["TenCV"]); } } comboboxChucVu.Items.Add("Không"); //comboboxChucVu.Text = r["TenCV"].ToString(); comboBoxPhongBan.Items.Clear(); dt.Clear(); da = new SqlDataAdapter("SELECT * FROM PHONGBAN", sqlCon); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { if (this.Level == 2 || this.Level == 3) { if (dt.Rows[i]["TenPB"].ToString() != "Ban điều hành") { comboBoxPhongBan.Items.Add(dt.Rows[i]["TenPB"]); } } else { comboBoxPhongBan.Items.Add(dt.Rows[i]["TenPB"]); } } //comboBoxPhongBan.Text = r["TenPB"].ToString(); comboBoxViTri.Items.Clear(); dt.Clear(); da = new SqlDataAdapter("SELECT * FROM VITRICONGVIEC", sqlCon); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { comboBoxViTri.Items.Add(dt.Rows[i]["TenVT"]); } //comboBoxViTri.Text = r["TenVT"].ToString(); comboBoxViTri.Items.Add("Không"); comboBoxPhongBan.Text = r["TenPB"].ToString(); comboboxChucVu.Text = r["TenCV"].ToString(); comboBoxViTri.Text = r["TenVT"].ToString(); sqlCon.Close(); }