private void button1_Click(object sender, EventArgs e) { try { if (txtsohs.Text == "") { MessageBox.Show("Bạn phải nhập vào số hồ sơ"); } else if (txthoten.Text == "") { MessageBox.Show("Bạn phải nhập vào họ tên"); } else if (checkBox1.Checked == false && chkgioitinh.Checked == false) { MessageBox.Show("Mời bạn chọn giới tính cho thí sinh"); } else if (txtnoisinh.Text == "") { MessageBox.Show("Bạn phải nhập vào nơi Sinh"); } else if (txtsocm.Text == "") { MessageBox.Show("Bạn phải nhập vào số CMND"); } else if (txtnoicap.Text == "") { MessageBox.Show("Bạn phải nhập vào nơi cấp CMND"); } else if (txthokhau.Text == "") { MessageBox.Show("Bạn phải nhập vào hộ khẩu thường trú"); } else if (txtsodienthoai.Text == "") { MessageBox.Show("Bạn phải nhập vào số điện thoại"); } //else if (txtdtcd.Text == "") //{ // MessageBox.Show("Bạn phải nhập vào số điện thoại cố định"); //} else if (txtemal.Text == "") { MessageBox.Show("Bạn phải nhập vào email "); } else if (comboBox1.Text == "---Chọn Năm---" || comboBox1.Text == "") { MessageBox.Show("Mời bạn chọn năm tốt nghiệp Trung Học Phổ Thông"); } else if (IsNumber(txtsohs.Text) == false) { MessageBox.Show("Bạn cần nhập định dạng số cho Số hồ sơ"); txtsohs.Focus(); } else if (IsNumber(txtsocm.Text) == false) { MessageBox.Show("Bạn cần nhập định dạng số cho Số Chứng minh thư nhân dân"); txtsocm.Focus(); } else if (IsNumber(txtsodienthoai.Text) == false) { MessageBox.Show("Bạn cần nhập định dạng số cho Số Điện thoại"); txtsodienthoai.Focus(); } else if (isValidEmail(txtemal.Text) == false) { MessageBox.Show("Bạn cần nhập định dạng [email protected] cho email"); txtemal.Focus(); } else { dbVeMTDataContext db = new dbVeMTDataContext(); vemt ve = new vemt(); ve.sohs = txtsohs.Text; ve.hoten = txthoten.Text; if (checkBox1.Checked) { ve.phai = true; } else if (chkgioitinh.Checked) { ve.phai = false; } ve.ngaysinh = DateTime.Parse(dateTimePicker2.Text.ToString()); ve.noisinh = txtnoisinh.Text; ve.cmnd = txtsocm.Text; ve.ngcapcmt = DateTime.Parse(dateTimePicker1.Text); ve.noicap = txtnoicap.Text; ve.hktt = txthokhau.Text; ve.phone = txtsodienthoai.Text; if (txtdtcd.Text != "") { ve.phonecodinh = txtdtcd.Text; } else { ve.phonecodinh = null; } ve.email = txtemal.Text; ve.namtn = float.Parse(comboBox1.Text); if (chklephi.Checked) { ve.lephi = true; } else ve.lephi = false; db.vemts.InsertOnSubmit(ve); db.SubmitChanges(); MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); TransferData(null); this.Close(); //FrmDangKy fm = new FrmDangKy(); //fm.Show(); } } catch (Exception) { MessageBox.Show("Trùng Số hồ sơ"); } foreach (var i in Application.OpenForms) { Form f = (Form)i; if (f.Name == "FrmDangKy") { FrmDangKy f1 = (FrmDangKy)f; f1.load_datagridview(); } } }
partial void Updatevemt(vemt instance);
partial void Deletevemt(vemt instance);
partial void Insertvemt(vemt instance);