public static void ThemTheDocGia(En_LapThe tdg) { SqlConnection conn = sqlConnectionData.KetNoi(); SqlCommand cmd = new SqlCommand("THEDOCGIA_Insert", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MaThe", SqlDbType.Char, 5); cmd.Parameters.Add("@HoTen", SqlDbType.NVarChar, 100); cmd.Parameters.Add("@LoaiDocGia", SqlDbType.NVarChar, 1); cmd.Parameters.Add("@NgaySinh", SqlDbType.SmallDateTime); cmd.Parameters.Add("@DiaChi", SqlDbType.NVarChar, 200); cmd.Parameters.Add("@Email", SqlDbType.NVarChar, 20); cmd.Parameters.Add("@NgayLapThe", SqlDbType.SmallDateTime); cmd.Parameters.Add("@TaiKhoanNo", SqlDbType.Int); cmd.Parameters["@MaThe"].Value = tdg.MaThe; cmd.Parameters["@HoTen"].Value = tdg.HoTen; cmd.Parameters["@LoaiDocGia"].Value = tdg.LoaiDocGia; cmd.Parameters["@NgaySinh"].Value = tdg.NgaySinh; cmd.Parameters["@DiaChi"].Value = tdg.DiaChi; cmd.Parameters["@Email"].Value = tdg.Email; cmd.Parameters["@NgayLapThe"].Value = tdg.NgayLapThe; cmd.Parameters["@TaiKhoanNo"].Value = tdg.TaiKhoanNo; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); }
private void btnCapNhat_Click(object sender, EventArgs e) { string _mathe = txtMaThe.Text; string _hoten = txtHoTen.Text; string _email = txtEmail.Text; string _diachi = txtDiaChi.Text; string _ngaylapthe = dtNgayLapThe.Text; string _ngaysinh = dtNgaySinh.Text; string _loaidg = txtLoaiDG.Text; if (_mathe == "" || _hoten == "" || _email == "" || _diachi == "" || _ngaylapthe == "" || _ngaysinh == "" || _loaidg == "") { MessageBox.Show("Vui lòng nhập đầy dủ thông tin", "Thông báo"); } else { DialogResult dialog = MessageBox.Show("Có chắc chắn cập nhật thông tin của thẻ này ?", "Thông báo", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { En_LapThe dg = new En_LapThe(_mathe, _hoten, DateTime.Parse(_ngaysinh), DateTime.Parse(_ngaylapthe), _email, _diachi, _loaidg, int.Parse(taikhoanno)); Bus_TimTV.CapNhatTV(dg); MessageBox.Show("Cập nhật thành công"); //cap nhat bang dtDachSach dataSrc = Bus_TimTV.TimTV(txtDocGia.Text); dtDanhsach.DataSource = dataSrc; dtDanhsach.Rows[0].Selected = false; dtDanhsach.Rows[hangDuocChon].Selected = true; // hien thi button btnSua.Visible = true; btnXoa.Visible = true; dtDanhsach.Enabled = true; btnCapNhat.Visible = false; btnHuy.Visible = false; setTextBoxEnabled(false); txtDocGia.Enabled = true; } else { btnHuy_Click(sender, e); } } }
private void btLapThe_Click(object sender, EventArgs e) { // kiem tra xem co de trong o nao khong if (txtDiaChi.Text == "" || txtEmail.Text == "" || txtHoTen.Text == "") { MessageBox.Show("Vui lòng điền đầy đủ thông tin", "Thông báo"); return; } // kiem tra xem co dung nhu tuoi quy dinh hay k TimeSpan _tuoiDocGia = DateTime.Today - DateTime.Parse(dtNgaySinh.Text.ToString()); int tuoiDocGia = _tuoiDocGia.Days / 365; int tuoiToiThieu = doTuoiToiThieu; int tuoiToiDa = doTuoiToiDa; if (tuoiDocGia < tuoiToiThieu || tuoiDocGia > tuoiToiDa) { MessageBox.Show("Độ tuổi hợp lệ từ " + tuoiToiThieu.ToString() + " đến " + tuoiToiDa.ToString() + " tuổi"); return; } string hoten = txtHoTen.Text; DateTime ngaysinh = DateTime.Parse(dtNgaySinh.Value.ToString()); DateTime ngaylapthe = DateTime.Parse(ngayLapthe.Text.ToString()); string email = txtEmail.Text; string diachi = txtDiaChi.Text; string loaidocgia = cbLoaiDocGia.Text; En_LapThe tdg = new En_LapThe(maThe, hoten, ngaysinh, ngaylapthe, email, diachi, loaidocgia, 0); /// ban dau lap the thi TaikhoanNo cua doc gia bang 0 Bus_LapThe.ThemTheDocGia(tdg); MessageBox.Show("Đã thêm thành công!", "Thông báo", MessageBoxButtons.OK); // them 1 row vao dgvDanhsach string[] row = new string[] { txtMathe.Text, txtHoTen.Text, cbLoaiDocGia.Text, dtNgaySinh.Text, txtDiaChi.Text, txtEmail.Text, ngayLapthe.Text, "0" }; dgvDanhSach.Rows.Add(row); // sort lai dgvDanhsach de row minh vua nhap dung o dau table dgvDanhSach.Sort(dgvDanhSach.Columns["Column1"], ListSortDirection.Descending); taoMaThe(maThe); btTaoLai_Click(sender, e); }
public static void ThemTheDocGia(En_LapThe tdg) { Sql_LapThe.ThemTheDocGia(tdg); }
public static void CapNhatTV(En_LapThe dg) { Sql_TimTV.CapNhatTV(dg); }