private void dgvDSNhanVien_SelectionChanged(object sender, EventArgs e) { if (dgvDSNhanVien.Rows.Count > 0) { curNhanVien = listNhanvien[dgvDSNhanVien.CurrentCell.RowIndex]; Console.WriteLine(curNhanVien.Ten); } }
private void dgvDSKhach_SelectionChanged(object sender, EventArgs e) { if (dgvDSKhach.Rows.Count > 0) { curKhach = listKhach[dgvDSKhach.CurrentCell.RowIndex]; Console.WriteLine(curKhach.Ten); } }
private void DataGridView2Config(Nguoi nguoi) { ATINChamCongEntities context = new ATINChamCongEntities(); dataGridView2.DataSource = context.spGetViewDanhSachVangByNguoi(nguoi.MaNguoi); dataGridView2.Columns["NgayChamCong"].DefaultCellStyle.Format = "dd/MM/yyyy"; dataGridView2.Columns["MaNhanVien"].Visible = false; dataGridView2.Columns["MaChamCong"].Visible = false; }
private void btLuu_Click(object sender, EventArgs e) { if (txTen.Text == "") { MessageBox.Show("Tên không được để trống!", "Lỗi:Tên không được để trống!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txCMND.Text == "" && txSDT.Text == "" && txEmail.Text == "") { MessageBox.Show("Phải nhập vào ít nhất 1 trong 3 trường Email, SĐT, CMND!", "Lỗi:Phải nhập ít nhất 1 trong 3 trường Email, SĐT, CMND !", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txSDT.Text.Length < 11 && txSDT.Text.Length > 0) { MessageBox.Show("SĐT không đúng format!", "Lỗi:SĐT không đúng format !", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if ((txCMND.Text.Length != 12 && txCMND.Text.Length > 0)) { MessageBox.Show("CMND không đúng format!", "Lỗi:CMND không đúng format !", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { var test = new MailAddress(txEmail.Text); } catch (FormatException ex) { MessageBox.Show("Email không đúng format!", "Lỗi:Email không đúng format !", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Nguoi temp = new Nguoi() { Id = -1, Ten = txTen.Text.Trim(), CMND = txCMND.Text.Trim(), SDT = txSDT.Text.Trim(), Email = txEmail.Text.Trim() }; if (this.Text == "Thêm Người") { if (comboBox1.SelectedIndex == -1) { MessageBox.Show("Chưa chọn Phân loại", "Lỗi:Chưa chọn Phân loại !", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } temp.MaVaiTro = comboBox1.SelectedIndex + 1; } else { temp.Id = curNguoi.Id; temp.MaVaiTro = curNguoi.MaVaiTro; temp.updated = true; } temp.Save(); MessageBox.Show("Lưu thành công", "Giao điện sẽ đóng lại", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
private void DataGridView2Config(Nguoi nguoi) { ATINChamCongEntities context = new ATINChamCongEntities(); var views = context.spGetViewSuaGioChamCongByNguoiByTime(nguoi.MaNguoi, (DateTime)barEditItem4.EditValue).ToList(); dataGridView2.DataSource = views; dataGridView2.Columns["MaNhanVien"].Visible = false; dataGridView2.Columns["MaChamCongChiTiet"].Visible = false; }
public ThemNguoi(Nguoi nguoi) { InitializeComponent(); curNguoi = nguoi; if (curNguoi.MaVaiTro == 1) { this.Text = "Chinh sửa thông tin Khách hàng."; } if (curNguoi.MaVaiTro == 2) { this.Text = "Chinh sửa thông tin Nhân viên."; } }
public void DeleteNguoi(int maNguoi) { try { Nguoi nguoi = context.Nguois.Where(x => x.MaNguoi == maNguoi).Single <Nguoi>(); context.Nguois.Remove(nguoi); context.SaveChanges(); } catch (Exception e) { throw e; } }
public int AddNguoi(Nguoi nguoi) { try { context.Nguois.Add(nguoi); context.SaveChanges(); int maNguoi = nguoi.MaNguoi; return(maNguoi); } catch (Exception e) { throw e; } }
public Nguoi GetNguoi(int maNguoi) { Nguoi nguoi = new Nguoi(); try { nguoi = context.Nguois .Where(c => c.MaNguoi == maNguoi) .Single <Nguoi>(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(nguoi); }
public void UpdateNguoi(Nguoi nguoiUpdate) { try { Nguoi nguoi = context.Nguois.Where(x => x.MaNguoi == nguoiUpdate.MaNguoi).Single <Nguoi>(); nguoi.HoTen = nguoiUpdate.HoTen; nguoi.MaDinhDanh = nguoiUpdate.MaDinhDanh; nguoi.MaPhongBan = nguoiUpdate.MaPhongBan; nguoi.MaChucVu = nguoiUpdate.MaChucVu; nguoi.NgayNhanViec = nguoiUpdate.NgayNhanViec; nguoi.NgaySinh = nguoiUpdate.NgaySinh; nguoi.AnhDaiDien = nguoiUpdate.AnhDaiDien; nguoi.MaGioiTinh = nguoiUpdate.MaGioiTinh; nguoi.TinhTrangHonNhan = nguoiUpdate.TinhTrangHonNhan; nguoi.MaTrinhDo = nguoiUpdate.MaTrinhDo; nguoi.MaDanToc = nguoiUpdate.MaDanToc; nguoi.MaTonGiao = nguoiUpdate.MaTonGiao; nguoi.MaQuocTich = nguoiUpdate.MaQuocTich; nguoi.NgayCapTCC = nguoiUpdate.NgayCapTCC; nguoi.SoTheCanCuoc = nguoiUpdate.SoTheCanCuoc; nguoi.NoiCapTCC = nguoiUpdate.NoiCapTCC; nguoi.DiaChiThuongTru = nguoiUpdate.DiaChiThuongTru; nguoi.DiaChiTamTru = nguoiUpdate.DiaChiTamTru; nguoi.Email = nguoiUpdate.Email; nguoi.SoDienThoai = nguoiUpdate.SoDienThoai; nguoi.SuDungKhuonMat = nguoiUpdate.SuDungKhuonMat; nguoi.SuDungTheTu = nguoiUpdate.SuDungTheTu; nguoi.SuDungVanTay = nguoiUpdate.SuDungVanTay; nguoi.GhiChu = nguoiUpdate.GhiChu; nguoi.ThoiGianCapNhat = nguoiUpdate.ThoiGianCapNhat; nguoi.TrangThaiHoatDong = nguoiUpdate.TrangThaiHoatDong; context.SaveChanges(); } catch (Exception e) { MessageBox.Show(e.Message); } }
private void button1_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count < 1) { return; } if (comboBox1.SelectedIndex < 0 || comboBox2.SelectedIndex < 0) { return; } Cursor.Current = Cursors.WaitCursor; button1.Enabled = false; ATINChamCongEntities context = new ATINChamCongEntities(); DateTime datetmp = DateTime.MinValue; int i = 0; int y = 0; try { foreach (DataGridViewRow row in dataGridView1.Rows) { y = 0; if (row.Cells[0].Value == null) { continue; } if ((bool)row.Cells[0].Value == true) { if (true) { foreach (ListViewItem lvItem in listView1.Items) { y++; if (lvItem.Checked == true) { string s = (lvItem.Tag as int?).ToString() + "/" + (comboBox4.SelectedIndex + 1).ToString() + "/" + (2020 + comboBox5.SelectedIndex).ToString(); datetmp = Convert.ToDateTime(s, System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat); var x = context.spInsertChamCongLoaiVang(datetmp, (row.DataBoundItem as Nguoi).MaNguoi, (comboBox2.SelectedItem as CaLamViec).MaCaLamViec, (comboBox1.SelectedItem as KyHieuCacLoaiVang).MaKyHieu, textBox9.Text.Trim()); } } } } i++; } MessageBox.Show("Thêm công vắng thành công!"); } catch (Exception ex) { if (ex.Message == "An error occurred while executing the command definition. See the inner exception for details.") { Nguoi loi = (dataGridView1.Rows[i].DataBoundItem as Nguoi); MessageBox.Show("Thêm vắng bị dừng giữa chừng \nKhông thể thêm vắng cho " + loi.HoTen + "(" + loi.MaNguoi.ToString() + ")" + "\n" + (comboBox2.SelectedItem as CaLamViec).MaCaLamViec + " Ngày " + y.ToString() + "/" + (comboBox4.SelectedIndex + 1).ToString() + "/" + (2020 + comboBox5.SelectedIndex).ToString() + " Đã tồn tại!", "Cảnh báo!"); } else { MessageBox.Show(ex.Message); } } DataGridView2Config(dataGridView1.SelectedRows[0].DataBoundItem as Nguoi); Cursor.Current = Cursors.Default; button1.Enabled = true; }
public void LoadDSDiaDiemDaDi(Nguoi nguoi) { }
public void LoadDSTourDaDi(Nguoi nguoi) { }
public Form1(Nguoi nguoi) { curNguoi = nguoi; InitializeComponent(); }