private void bbiSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { gvc = new GiaoVienController(); int gt = 0; if (gvc.CheckErr(txtMaGV.Text.Trim(), txtHoTen.Text.Trim(), dtNgaySinh.Value.ToString(), gt, txtSDT.Text.Trim(), txtQueQuan.Text.Trim())) { if (ckNam.Checked) { gt = 0; } if (ckNu.Checked) { gt = 1; } string _ngaysinh = dtNgaySinh.Value.Year + "/" + dtNgaySinh.Value.Month + "/" + dtNgaySinh.Value.Day; if (_ID == null) { if (gvc.ThemGV(txtMaGV.Text.Trim(), txtHoTen.Text.Trim(), _ngaysinh, gt, txtSDT.Text.Trim(), txtQueQuan.Text.Trim())) { MessageBox.Show("Thành Công", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Lỗi", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (gvc.SuaGV(txtMaGV.Text.Trim(), txtHoTen.Text.Trim(), _ngaysinh, gt, txtSDT.Text.Trim(), txtQueQuan.Text.Trim())) { MessageBox.Show("Thành Công", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Lỗi", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void bbiSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { ComboboxItem item = new ComboboxItem(); item = (ComboboxItem)cbMon.SelectedItem; bool gt = true; if (radNam.Checked == true) { gt = true; } else { gt = false; } if (_state == 1) { if (GiaoVienController.ThemGV(txtID.Text.Trim().ToUpper(), txtHoTen.Text.Trim(), dtpNgaySinh.Value, gt, txtSDT.Text.Trim(), txtDiaChi.Text.Trim(), item.Value.ToString())) { MessageBox.Show("Thành Công", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Lỗi", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (_state == 2) { if (GiaoVienController.SuaGV(txtID.Text.Trim().ToUpper(), txtHoTen.Text.Trim(), dtpNgaySinh.Value, gt, txtSDT.Text.Trim(), txtDiaChi.Text.Trim(), item.Value.ToString())) { MessageBox.Show("Thành Công", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Lỗi", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btAdd_Click_1(object sender, EventArgs e) { errorProvider1.Clear(); if (txtName.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtName, "Nhập tên "); return; } if (txtSDT.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtSDT, "Nhập SDT"); return; } if (cbBomon.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.cbBomon, "Nhập bộ môn"); return; } if (cbSex.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.cbSex, "Nhập giới tính"); return; } if (txtEmail.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtEmail, "Nhập email"); return; } if (DateTime.Now.Year - Birthday.Value.Year < 10) { errorProvider1.SetError(Birthday, "Chọn ngày sinh phù hợp"); return; } if (txtusername.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtusername, "Nhập username"); return; } if (txtpass.Text.Trim().Length <= 0) { this.errorProvider1.SetError(this.txtpass, "Nhập password"); return; } GiaoVien gv = new GiaoVien(); gv.HoTen = txtName.Text.Trim(); gv.SDT = txtSDT.Text.Trim(); gv.NgaySinh = Birthday.Value; gv.Email = txtEmail.Text.Trim(); gv.GioiTinh = cbSex.SelectedItem.ToString(); gv.BoMon = cbBomon.SelectedItem.ToString(); gv.username = txtusername.Text.Trim(); gv.pass = txtpass.Text.Trim(); gv.ad = 0; gv.status = 1; if (GiaoVienController.ThemGV(gv) == false) { MessageBox.Show("Khong them giao vien duoc"); return; } this.txtEmail.Clear(); this.txtName.Clear(); this.txtSDT.Clear(); this.cbBomon.SelectedIndex = 0; this.cbSex.SelectedIndex = 0; this.Birthday.Value = DateTime.Now; this.currentIDGV = -1; showGV(); }