private void phodiemthi_Load(object sender, EventArgs e) { dataGridView1.Hide(); dbVeMTDataContext db = new dbVeMTDataContext(); dataGridView1.Rows.Clear(); var results = from p in db.vemts group p by p.diem into g select new { diem = g.Key , soluong = g.Count() }; dataGridView1.DataSource = results; db.SubmitChanges(); //Tìm và đặt giá trị MAX cho trục Y int max = Convert.ToInt32(dataGridView1.Rows[0].Cells[0].Value); for (int i = 1; i <= dataGridView1.SelectedRows.Count; i++) if (max < Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value)) max = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value); if (chart1.ChartAreas[0].AxisY.Maximum < max) chart1.ChartAreas[0].AxisY.Maximum = max; chart1.Series.Clear(); Series s = new Series(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { s.ChartType = SeriesChartType.Line; DataPoint p = new DataPoint(); p.XValue = i; p.SetValueY(Convert.ToDouble(dataGridView1.Rows[i].Cells[1].Value)); //p.AxisLabel = "Điểm " + dataGridView1.Rows[i].Cells[0].Value.ToString() +""; p.AxisLabel = "điểm" + i.ToString(); ; s.Points.Add(p); } chart1.Series.Add(s); }
public void load_datagridview() { dbVeMTDataContext db = new dbVeMTDataContext(); dgv_thisinh.Rows.Clear(); var list = from t in db.vemts orderby t.sohs select new { t.sohs, t.hoten, Type = t.phai == true ? "Nam" : "Nữ", t.ngaysinh, t.noisinh, t.cmnd, t.ngcapcmt, t.noicap, t.hktt, t.phone, t.phonecodinh, t.email, t.namtn, Type1 = t.lephi == true ? "Đã nộp" : "Chưa nộp" }; dgv_thisinh.Columns[0].HeaderText = "Số HS"; dgv_thisinh.Columns[1].HeaderText = "Họ và tên"; dgv_thisinh.Columns[2].HeaderText = "Giới tính"; dgv_thisinh.Columns[3].HeaderText = "Ngày sinh"; dgv_thisinh.Columns[4].HeaderText = "Nơi Sinh"; dgv_thisinh.Columns[5].HeaderText = "Số CMND"; dgv_thisinh.Columns[6].HeaderText = "Ngày cấp CMND"; dgv_thisinh.Columns[7].HeaderText = "Nơi cấp CMND"; dgv_thisinh.Columns[8].HeaderText = "Hộ khẩu thường trú"; dgv_thisinh.Columns[9].HeaderText = "Số điện thoại"; dgv_thisinh.Columns[10].HeaderText = "Điện thoại cố định"; dgv_thisinh.Columns[11].HeaderText = "Email"; dgv_thisinh.Columns[12].HeaderText = "Năm tốt nghiệp"; dgv_thisinh.Columns[13].HeaderText = "Lệ phí"; for (int i = 0; i < dgv_thisinh.Rows.Count; i++) { dgv_thisinh.Rows[i].HeaderCell.Value = (i + 1).ToString(); } this.dgv_thisinh.Columns[3].DefaultCellStyle.Format = ("dd/MM/yyyy"); this.dgv_thisinh.Columns[6].DefaultCellStyle.Format = ("dd/MM/yyyy"); //dgv_thisinh.DataSource = null; dgv_thisinh.DataSource = list; dgv_thisinh.Refresh(); }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtMK1.Text)) { txtMK1.Focus(); errorcu.SetError(txtMK1, @"Chưa nhập mật khẩu cũ"); } else if (string.IsNullOrEmpty(txtMK2.Text)) { txtMK2.Focus(); errorcu.Dispose(); errormoi.SetError(txtMK2, @"Chưa nhập mật khẩu mới"); } else if (string.IsNullOrEmpty(txtMK3.Text)) { txtMK3.Focus(); errormoi.Dispose(); errornhaplai.SetError(txtMK3, @"Nhập lại mật khẩu mới"); } else if (txtMK2.Text != txtMK3.Text) { txtMK3.Focus(); errornhaplai.Dispose(); MessageBox.Show(@"Mật khẩu nhập lại không khớp", @"Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //else if (_matkhau != MaHoaMD5.Md5(txtMK1.Text)) //{ // txtMK1.Focus(); // MessageBox.Show(@"Sai Mật khẩu cũ", @"Thông báo", MessageBoxButtons.OK, // MessageBoxIcon.Warning); //} else { //UpdateData.UpdateMatKhau(_taikhoan, MaHoaMD5.Md5(txtMK3.Text)); //CheckUpdate = true; dbVeMTDataContext db = new dbVeMTDataContext(); var ts = (from p in db.nhanviens where p.username == textBox1.Text select p).Single(); if(ts.pass == txtMK1.Text.ToMD5()) { ts.pass = txtMK2.Text.ToMD5(); db.SubmitChanges(); MessageBox.Show(@"Mật khẩu đã được thay đổi", @"Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } else { txtMK1.Focus(); MessageBox.Show(@"Sai Mật khẩu cũ", @"Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } // ts.tennguoidung = textBox4.Text; // ts.username = textBox1.Text; } }
private void FrmDsThuLePhi_Load(object sender, EventArgs e) { Utils.LoadFullScreen(this); dbVeMTDataContext db = new dbVeMTDataContext(); var db_filter = db.vemts.Where(o => o.lephi == null || o.lephi == false); this.reportManager1.DataSources = new PerpetuumSoft.Reporting.Components.ObjectPointerCollection(new string[] {"VeMT"}, new object[] {((object)(db_filter))}); inlineReportSlot1.RenderDocument(); }
private void button3_Click(object sender, EventArgs e) { dbVeMTDataContext db = new dbVeMTDataContext(); var del = db.nhanviens.SingleOrDefault(d => d.username == dgv_nguoidung.CurrentRow.Cells[0].Value.ToString()); db.nhanviens.DeleteOnSubmit(del); DialogResult dia = new DialogResult(); dia = MessageBox.Show("Bạn có chắc muốn xóa người dùng này?" + "", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dia == DialogResult.Yes) db.SubmitChanges(); loadgrv(); }
public void load_datagridview() { dbVeMTDataContext db = new dbVeMTDataContext(); dgv_nguoidung.Rows.Clear(); var list = from t in db.nhanviens orderby t.username select new { t.username, t.pass, t.tennguoidung }; dgv_nguoidung.Columns[0].HeaderText = "Tài khoản"; dgv_nguoidung.Columns[1].HeaderText = "Mật khẩu"; dgv_nguoidung.Columns[2].HeaderText = "Họ và Tên người dùng"; dgv_nguoidung.Columns[0].Width = 200; dgv_nguoidung.Columns[1].Width = 200; dgv_nguoidung.Columns[2].Width = 300; // dgv_nguoidung.DataSource = null; dgv_nguoidung.DataSource = list; dgv_nguoidung.Refresh(); }
public void LoadData_lstTui() { //lấy về dữ liệu dbVeMTDataContext db = new dbVeMTDataContext(); //lấy về số túi bài thi trong CSDL var query = db.vemts.Select(o => o.tui).Distinct(); // (from x in db.vemts select x.tui).Distinct(); for (int i = 0; i < query.Count(); i++) { //get list bài thi theo túi, sort by phach. var qr = db.vemts.Where(o => o.tui == i + 1).OrderBy(o => o.phach).ToList(); //Khởi tạo đối tượng Thông tin phách ThongTinTuiPhach tt = new ThongTinTuiPhach(); tt.tuiso = i + 1; tt.tuphach = (int) qr[0].phach; tt.denphach = (int)qr[qr.Count() - 1].phach; //Add đối tượng vừa tạo vào lst_tt_tuiphach lst_TT_TuiPhach.Add(tt); } }
private void importĐiểmToolStripMenuItem_Click(object sender, EventArgs e) { //if (!CheckExitsFrom("Importdiem")) //{ // Importdiem fm = new Importdiem(); // fm.MdiParent = this; // fm.Show(); //} //else ActiveChildForm("Importdiem"); if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { dbVeMTDataContext db = new dbVeMTDataContext(); var qry1 = db.vemts.OrderBy(bn => bn.phach); List<vemt> list1 = new List<vemt>(); list1 = qry1.ToList(); string[] a = new string[20]; DataSet ds = new DataSet(); ds = GetDataExcel(openFileDialog1.FileName, "Sheet1");// Goi chuong trinh GetDataExcel phia tren luu vao Dataset ds for (int i = 0; i < ds.Tables[0].Rows.Count; i++) //Dong { for (int j = 0; j < ds.Tables[0].Columns.Count; j++)//Cot { a[j] = ds.Tables[0].Rows[i].ItemArray[j].ToString().Trim(); }; for (int ba = 0; ba < list1.Count; ba++) { if (list1[ba].phach == Convert.ToDouble(a[0])) { list1[ba].diem = Convert.ToDouble(a[1]); db.SubmitChanges(); } } //MessageBox.Show(a[1].ToString()); //Bat dau import du lieu vao // mh.Insert(a[0], a[1], byte.Parse(a[2])); } //loadData(); MessageBox.Show("Import thành công."); } catch { MessageBox.Show("Lỗi! Import thất bại. Vui lòng kiểm tra lại file Excel."); }; } ImPortDiem f = new ImPortDiem(); f.Show(); }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.Text == "anphabe Tên") { int rn = 1; //dbVeMTDataContext db = new dbVeMTDataContext(); //var b = from s in db.vemts // orderby db.layTen(s.hoten) // select (s.hoten); //List<String> list1 = new List<String>(); //list1 = b.ToList(); ////MessageBox.Show(b.ToString()); ////danh stt //foreach (String item1 in b) //{ // List<vemt> dsSbd2 = new List<vemt>(); // // List<vemt> dsSbd3 = new List<vemt>(); // dsSbd2 = (from purchase in db.vemts // where purchase.hoten == item1 // select purchase).ToList(); // // dsSbd.Count(); // //MessageBox.Show(dsSbd1.Count().ToString()); // for (int i = 0; i < dsSbd2.Count(); i++) // { // dsSbd2[i].stt = rn; // rn = rn + 1; // //MessageBox.Show(rn.ToString()); // } //} dbVeMTDataContext db = new dbVeMTDataContext(); var qry1 = db.vemts.OrderBy(a => db.layTen(a.hoten)); List<vemt> list1 = new List<vemt>(); list1 = qry1.ToList(); //danh stt int n = list1.Count; for (int i = 0; i < n; i++) { list1[i].stt = i + 1; } var qry = from s in db.vemts orderby db.layTen(s.hoten) select (s.hoten); List<String> list = new List<String>(); list = qry.ToList(); foreach (String item in list) { List<vemt> dsSbd = new List<vemt>(); List<vemt> dsSbd1 = new List<vemt>(); dsSbd = (from purchase in db.vemts where purchase.hoten == item select purchase).ToList(); dsSbd1 = (from r in db.vemts orderby r.hoten select r).ToList(); // dsSbd.Count(); //MessageBox.Show(dsSbd1.Count().ToString()); for (int i = 0; i < dsSbd.Count(); i++) { decimal? stt = dsSbd[i].stt; dsSbd[i].phongthi = Convert.ToDouble((int)((stt - 1) / numericUpDown1.Value ) + 1); // MessageBox.Show(stt.ToString()); // rn = rn + 1; } // int sl = dsSbd.Count(); } db.SubmitChanges(); // MessageBox.Show("Đã thực hiện xong"); double d = (int)(list1.Count() / numericUpDown1.Value) + 1; var qry3 = from s in db.vemts where s.phongthi == d select (s.hoten); int sl = qry3.Count(); // MessageBox.Show(sl.ToString()); if (numericUpDown2.Value.ToString()=="") { MessageBox.Show("Mời nhập vào số thí sinh cần gộp"); } else if (sl<= numericUpDown2.Value) { List<vemt> upt = new List<vemt>(); upt = (from v in db.vemts where v.phongthi == d select v).ToList(); //for (int i = 0; i < upt.Count(); i++) //{ // upt[i].phongthi = Convert.ToDouble((int)((stt - 1) / numericUpDown1.Value) + 1); // // MessageBox.Show(stt.ToString()); // // rn = rn + 1; //} foreach (vemt v in upt) { v.phongthi = d - 1; } //upt.phongthi = (d - 1.0); db.SubmitChanges(); } //a = số lượng người ở phòng d // nếu d < số người quy định* //{ // update pt=d-1 cua where pt = d //} MessageBox.Show("Chia thành công"); //MessageBox.Show(list.Count.ToString()); // loadgrv(); } }
private void button1_Click(object sender, EventArgs e) { try { //sap xep theo phong thi dbVeMTDataContext db = new dbVeMTDataContext(); var qry = db.vemts.OrderBy(a => a.phongthi); List<vemt> list = new List<vemt>(); list = qry.ToList(); //danh stt int n = list.Count; for (int i = 0; i < n; i++) { list[i].stt = i + 1; } //don tui bai thi for (int i = 0; i < n; i++) { decimal? stt = list[i].stt; list[i].tui = Convert.ToDouble((int)((stt - 1) / numericUpDown1.Value)) + 1; } // db.SubmitChanges(); //danh phach theo tung tui, cac phach trong mot tui la lien tuc //phac giua cac tui cach nhau la 1 so nguyen tu 1 den 10 //sinh ra so ngau nhien Random rd = new Random(1); int rn = rd.Next(1, 100); //lay ra danh sach cac tui var qryDstui = (from x in db.vemts orderby x.tui select x.tui).Distinct(); List<double?> dstui = new List<double?>(); dstui = qryDstui.ToList(); //duyet tung tui bai thi foreach (float item in dstui) { //MesageBox.Show(item.ToString()); progressBar1.Value = progressBar1.Value + 1; List<vemt> dsSbd = new List<vemt>(); //lay ra ca bai thi trong 1 tui dsSbd = (from x in db.vemts where x.tui == item select x).ToList(); //duyet tung bai thi va danh phach cho bai thi for (int i = 0; i < dsSbd.Count; i++) { dsSbd[i].phach = rn;//so phach la tang lien tuc rn = rn + 1; } //tui tiep theo co so phach bat dau bang so phach tui cu + 1 so ngau nhien rn = rn + new Random().Next(1,10); } db.SubmitChanges(); MessageBox.Show("Đã thực hiện xong"); } catch (Exception ex) { Utils.Show_Exception_Msg(ex); } }
//private void loadgrv() //{ // dbVeMTDataContext db = new dbVeMTDataContext(); // dgv_thisinh.Rows.Clear(); // var list = from t in db.vemts select new { t.sohs, t.hoten, Type = t.phai == true ? "Nam" : "Nữ",t.sobaodanh }; // dgv_thisinh.DataSource = list; // dgv_thisinh.Columns[0].HeaderText = "Số HS"; // dgv_thisinh.Columns[1].HeaderText = "Họ và tên"; // dgv_thisinh.Columns[2].HeaderText = "Giới tính"; // dgv_thisinh.Columns[3].HeaderText = "Số báo danh"; // //this.dgv_thisinh.Columns[3].DefaultCellStyle.Format = ("dd/MM/yyyy"); // //this.dgv_thisinh.Columns[6].DefaultCellStyle.Format = ("dd/MM/yyyy"); // // if (dgv_thisinh.CurrentRow.Cells[2].Value.ToString() == "True") // // { // // dgv_thisinh.CurrentRow.Cells[2].Value = "name"; // // } // // else { dgv_thisinh.CurrentRow.Cells[2].Value = "nữ"; } //} private void button1_Click(object sender, EventArgs e) { //Random rd = new Random(1); //int rn = rd.Next(1, 100); if (comboBox1.Text == "anphabe Tên") { int rn = 1; dbVeMTDataContext db = new dbVeMTDataContext(); //db.layTen(); //var sort = from s in db.vemts // orderby db.layTen(s.hoten) // select s.hoten; var qry1 = db.vemts.OrderBy(a => db.layTen(a.hoten)).Select(b => b.hoten); List<String> list1 = new List<String>(); list1 = qry1.ToList(); // var qry = db.vemts.OrderBy(a => db.layTen(a.phongthi)); //private ArrayList al = new ArrayList(); List<String> ds = new List<String>(); // ds = sort.ToList(); // MessageBox.Show(ds.ToString()); foreach (String item in list1) { List<vemt> dsSbd = new List<vemt>(); List<vemt> dsSbd1 = new List<vemt>(); dsSbd = (from purchase in db.vemts where purchase.hoten == item select purchase).ToList(); dsSbd1 = (from r in db.vemts orderby r.hoten select r).ToList(); // dsSbd.Count(); //MessageBox.Show(dsSbd1.Count().ToString()); if (dsSbd1.Count() < 10) { for (int i = 0; i < dsSbd.Count(); i++) { string s = rn.ToString().PadLeft(1, '0') ; dsSbd[i].sobaodanh = textBox1.Text + s;//so phach la tang lien tuc // MessageBox.Show(dsSbd[i].phach.ToString()); rn = rn + 1; } } else if (dsSbd1.Count() < 100) { for (int i = 0; i < dsSbd.Count(); i++) { //string s = i.ToString().PadLeft(2, '0') +rn.ToString(); string s = rn.ToString().PadLeft(2, '0'); dsSbd[i].sobaodanh = textBox1.Text + s;//so phach la tang lien tuc // MessageBox.Show(dsSbd[i].phach.ToString()); rn = rn + 1; } } else if (dsSbd1.Count() < 1000) { for (int i = 0; i < dsSbd.Count(); i++) { //string s = i.ToString().PadLeft(2, '0') +rn.ToString(); string s = rn.ToString().PadLeft(3, '0'); dsSbd[i].sobaodanh = textBox1.Text + s;//so phach la tang lien tuc // MessageBox.Show(dsSbd[i].sobaodanh.ToString()); rn = rn + 1; } } else { for (int i = 0; i < dsSbd.Count(); i++) { string s = rn.ToString().PadLeft(4, '0'); dsSbd[i].sobaodanh = textBox1.Text + s;//so phach la tang lien tuc // MessageBox.Show(dsSbd[i].phach.ToString()); rn = rn + 1; } } } db.SubmitChanges(); MessageBox.Show("Đã thực hiện xong"); // loadgrv(); } else { int rn = 1; dbVeMTDataContext db = new dbVeMTDataContext(); //db.layTen(); var sort = from s in db.vemts orderby s.sohs select (s.sohs); //private ArrayList al = new ArrayList(); List<String> ds = new List<String>(); ds = sort.ToList(); // MessageBox.Show(ds.ToString()); foreach (String item in sort) { List<vemt> dsSbd = new List<vemt>(); List<vemt> dsSbd1 = new List<vemt>(); dsSbd = (from purchase in db.vemts where purchase.sohs == item select purchase).ToList(); dsSbd1 = (from r in db.vemts orderby r.sohs select r).ToList(); // dsSbd.Count(); // MessageBox.Show(dsSbd1.Count().ToString()); if (dsSbd1.Count() < 10) { for (int i = 0; i < dsSbd.Count(); i++) { string a = rn.ToString().PadLeft(1, '0'); dsSbd[i].sobaodanh = textBox1.Text + a;//so phach la tang lien tuc // MessageBox.Show(dsSbd[i].phach.ToString()); rn = rn + 1; } } else if (dsSbd1.Count() < 100) { for (int i = 0; i < dsSbd.Count(); i++) { string a = rn.ToString().PadLeft(2, '0'); dsSbd[i].sobaodanh = textBox1.Text + a;//so phach la tang lien tuc // MessageBox.Show(dsSbd[i].phach.ToString()); rn = rn + 1; } } else { for (int i = 0; i < dsSbd.Count(); i++) { string a = rn.ToString().PadLeft(3, '0'); dsSbd[i].sobaodanh = textBox1.Text + a;//so phach la tang lien tuc // MessageBox.Show(dsSbd[i].phach.ToString()); rn = rn + 1; } } } db.SubmitChanges(); MessageBox.Show("Đã thực hiện xong"); // loadgrv(); } }
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(); } } }
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(); var ts = (from p in db.vemts where p.sohs == txtsohs.Text select p).Single(); ts.hoten = txthoten.Text; if (checkBox1.Checked) { ts.phai = true; } else if (chkgioitinh.Checked) { ts.phai = false; } ts.ngaysinh = DateTime.Parse(dateTimePicker1.Text.ToString()); ts.noisinh = txtnoisinh.Text; ts.cmnd = txtsocm.Text; ts.ngcapcmt = DateTime.Parse(dateTimePicker2.Text); ts.noicap = txtnoicap.Text; ts.hktt = txthokhau.Text; ts.phone = txtsodienthoai.Text; ts.phonecodinh = txtdtcd.Text; ts.email = txtemal.Text; ts.namtn = float.Parse(comboBox1.Text); if (chklephi.Checked) { ts.lephi = true; } else ts.lephi = false; DialogResult dia = new DialogResult(); dia = MessageBox.Show("Bạn có chắc chắn muốn cập nhật thí sinh này không ?" + "", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dia == DialogResult.Yes) { db.SubmitChanges(); } MessageBox.Show("Cập nhật thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception) { MessageBox.Show("Trùng số hồ sơ"); } TransferData(null); }
public static void Update_DB() { try { dbVeMTDataContext db = new dbVeMTDataContext(); foreach (CTui tui in Utils.lst_tui) { foreach (vemt rc in tui.Lst_baithi_theotui) { //cần validate dữ liệu ở đây k? //lấy về đối tượng tương ứng var rc_in_DB = db.vemts.Where(o => o.sobaodanh == rc.sobaodanh).Single(); rc_in_DB.tui = rc.tui; rc_in_DB.stttui = rc.stttui; rc_in_DB.phach = rc.phach; } } db.SubmitChanges(); MessageBox.Show(Constants.Msg_Update_Success, Constants.Msg_Caption_Success, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception ex) { Utils.Show_Exception_Msg(ex); } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Length - 1 < 5) MessageBox.Show("Tên tài khoản quá ngắn"); else if (textBox1.Text.Length - 1 > 30) MessageBox.Show("Tên tài khoản quá dài"); else if (textBox2.Text.Length - 1 < 5) MessageBox.Show("Mật khẩu quá ngắn"); else if (textBox3.Text.Length - 1 > 30) MessageBox.Show("Mật khẩu quá dài"); else if (textBox2.Text != textBox3.Text) MessageBox.Show("Password không trùng nhau"); else { try { dbVeMTDataContext db = new dbVeMTDataContext(); var ts = (from p in db.nhanviens where p.username == textBox1.Text select p).Single(); ts.tennguoidung = textBox4.Text; ts.username = textBox1.Text; ts.pass = textBox3.Text; Tennd = textBox4.Text; username = textBox1.Text; pass = textBox2.Text.ToMD5() ; db.SubmitChanges(); //UpdateData.UpdateMatKhau(textBox4.Text, MaHoaMD5.Md5(textBox2.Text)); //CheckUpdate = true; MessageBox.Show("Sửa tài khoản thành công"); } catch { MessageBox.Show("Không thể Sửa tài khoản"); } } foreach (var item in Application.OpenForms) { Form f = (Form)item; if (f.Name == "FrmQuanLyDangNhap") { FrmQuanLyDangNhap f1 = (FrmQuanLyDangNhap)f; f1.load_datagridview(); } } TransferData(null); this.Close(); }
private void btnxoa_Click(object sender, EventArgs e) { //int ExampleId; //int RowId; //if (MessageBox.Show("Bạn có chắc xoá mẫu tin này không?", // "Delete Warning", MessageBoxButtons.YesNo, // MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false) // == DialogResult.Yes) //{ // for (int i = 0; i < dgv_thisinh.SelectedRows.Count; i++) // { // RowId = dgv_thisinh.SelectedRows[i].Index; // ExampleId = Convert.ToInt32(dgv_thisinh[0, RowId].Value); // } // using (var db = new dbVeMTDataContext()) // { // if (ExampleId != 0) // { // var getData = (from example in db.vemts // where example.sohs == ExampleId // select example).Single(); // db.vemts.DeleteOnSubmit(getData); // db.SubmitChanges(); // MessageBox.Show("Đã xoá thành công!"); // loadgrv(); // } // } //} dbVeMTDataContext db = new dbVeMTDataContext(); var del = db.vemts.SingleOrDefault(d => d.sohs == dgv_thisinh.CurrentRow.Cells[0].Value.ToString()); db.vemts.DeleteOnSubmit(del); DialogResult dia = new DialogResult(); dia = MessageBox.Show("Bạn có chắc muốn xóa thí sinh này?" + "", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dia == DialogResult.Yes) db.SubmitChanges(); loadgrv(); }
private void button1_Click(object sender, EventArgs e) { dbVeMTDataContext db = new dbVeMTDataContext(); dgv_thisinh.Rows.Clear(); if (comboBox1.Text == "Số hồ sơ") { var list = from t in db.vemts where t.sohs.ToString().Contains(textBox1.Text) select new { t.sohs, t.hoten, Type = t.phai == true ? "Nam" : "Nữ", t.ngaysinh, t.noisinh, t.cmnd, t.ngcapcmt, t.noicap, t.hktt, t.phone, t.phonecodinh, t.email, t.namtn, Type1 = t.lephi == true ? "Đã nộp" : "Chưa nộp" }; dgv_thisinh.DataSource = list; } else if (comboBox1.Text == "Họ tên") { var list = from t in db.vemts where t.hoten.ToString().Contains(textBox1.Text) select new { t.sohs, t.hoten, Type = t.phai == true ? "Nam" : "Nữ", t.ngaysinh, t.noisinh, t.cmnd, t.ngcapcmt, t.noicap, t.hktt, t.phone, t.phonecodinh, t.email, t.namtn, Type1 = t.lephi == true ? "Đã nộp" : "Chưa nộp" }; dgv_thisinh.DataSource = list; } else if (comboBox1.Text == "Năm tốt nghiệp") { var list = from t in db.vemts where t.namtn.ToString().Contains(textBox1.Text) select new { t.sohs, t.hoten, Type = t.phai == true ? "Nam" : "Nữ", t.ngaysinh, t.noisinh, t.cmnd, t.ngcapcmt, t.noicap, t.hktt, t.phone, t.phonecodinh, t.email, t.namtn, Type1 = t.lephi == true ? "Đã nộp" : "Chưa nộp" }; dgv_thisinh.DataSource = list; } else if (comboBox1.Text == "Hộ khẩu thường trú") { var list = from t in db.vemts where t.hktt.ToString().Contains(textBox1.Text) select new { t.sohs, t.hoten, Type = t.phai == true ? "Nam" : "Nữ", t.ngaysinh, t.noisinh, t.cmnd, t.ngcapcmt, t.noicap, t.hktt, t.phone, t.phonecodinh, t.email, t.namtn, Type1 = t.lephi == true ? "Đã nộp" : "Chưa nộp" }; dgv_thisinh.DataSource = list; } else if (comboBox1.Text == "Nơi sinh") { var list = from t in db.vemts where t.noisinh.ToString().Contains(textBox1.Text) select new { t.sohs, t.hoten, Type = t.phai == true ? "Nam" : "Nữ", t.ngaysinh, t.noisinh, t.cmnd, t.ngcapcmt, t.noicap, t.hktt, t.phone, t.phonecodinh, t.email, t.namtn, Type1 = t.lephi == true ? "Đã nộp" : "Chưa nộp" }; dgv_thisinh.DataSource = list; } else if (comboBox1.Text == "Chứng minh nhân dân") { var list = from t in db.vemts where t.cmnd.ToString().Contains(textBox1.Text) select new { t.sohs, t.hoten, Type = t.phai == true ? "Nam" : "Nữ", t.ngaysinh, t.noisinh, t.cmnd, t.ngcapcmt, t.noicap, t.hktt, t.phone, t.phonecodinh, t.email, t.namtn, Type1 = t.lephi == true ? "Đã nộp" : "Chưa nộp" }; dgv_thisinh.DataSource = list; } else { loadgrv(); } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Length - 1 < 4) MessageBox.Show("Tên tài khoản quá ngắn"); else if (textBox1.Text.Length - 1 > 30) MessageBox.Show("Tên tài khoản quá dài"); else if (textBox2.Text.Length - 1 < 4) MessageBox.Show("Mật khẩu quá ngắn"); else if (textBox3.Text.Length - 1 > 30) MessageBox.Show("Mật khẩu quá dài"); else if (textBox2.Text != textBox3.Text) MessageBox.Show("Password không trùng nhau"); else { try { dbVeMTDataContext db = new dbVeMTDataContext(); //var p = from t in db.nhanviens //where t.username =db; nhanvien n = new nhanvien(); n.tennguoidung = textBox4.Text; n.username = textBox1.Text; n.pass = textBox2.Text.ToMD5(); db.nhanviens.InsertOnSubmit(n); db.SubmitChanges(); MessageBox.Show("Tạo tài khoản thành công"); this.Close(); } catch { MessageBox.Show("Không thể tạo tài khoản"); } } foreach (var item in Application.OpenForms) { Form f = (Form)item; if (f.Name == "FrmQuanLyDangNhap") { FrmQuanLyDangNhap f1 = (FrmQuanLyDangNhap)f; f1.load_datagridview(); } } TransferData(null); }
public static void TronTuiBaiThi() { #region chặt nhỏ dữ liệu chia ra thành các phòng thi khác nhau //reset lst_tui và lst_phongthi Utils.lst_tui = new List<CTui>(); Utils.lst_phongthi = new List<CPhongThi>(); //lấy về dữ liệu dbVeMTDataContext db = new dbVeMTDataContext(); //var db_sort = db.vemts.OrderBy(o => o.sobaodanh).OrderBy(o => o.phongthi); int sophongthi = db.vemts.Select(o => o.phongthi).Distinct().Count(); // 30; //sau này cần lấy động số phòng thi. //loop so phong thi để chuẩn bị dữ liệu theo từng phòng thi for (int i = 0; i < sophongthi; i++) { //tạo ra đối tượng phòng thi CPhongThi phongthi = new CPhongThi(); //lấy về toàn bộ số thí sinh theo phòng thi thứ i+1. var lst_thisinh = db.vemts.Where(o => o.phongthi == i + 1); if (lst_thisinh.Count() > 0) { //nếu số thí sinh trong 1 phòng thi > 0 thì chuyển toàn bộ dữ liệu của thí sinh vào trong đối tượng phòng thi foreach (var ts in lst_thisinh) { phongthi.Lst_baithi_theophong.Add(ts); } } //add phòng thi vừa có vào lst phòng thi Utils.lst_phongthi.Add(phongthi); } //đến đây đã có toàn bộ dữ liệu về từng phòng thi. #endregion #region thực hiện trộn túi bài thi //tính số bài thi để chia đoạn phòng thi int chiadoan = Utils.sobaithi_theotui * 2 / 3 + 1; //tính có bao nhiêu túi bài thi cần trộn Utils.sotuibaithi = ((int)db.vemts.Count() / Utils.sobaithi_theotui) + 1; //khởi tạo đối tượng để random phòng thi cho mỗi lần lấy bài thi vào túi Random r = new Random(); int k = r.Next(0, Utils.lst_phongthi.Count - 1); for (int i = 0; i < Utils.sotuibaithi; i++) { //khởi tạo 1 túi bài thi CTui tui = new CTui(); tui.sobaithi_con_theotui = Utils.sobaithi_theotui; while (tui.sobaithi_con_theotui > 0 && Utils.lst_phongthi.Count() > 0) { if (k > Utils.lst_phongthi.Count() - 1) { k = 0; } //MessageBox.Show(ar[index].ToString()); ////Ở đây chưa random nên lấy tuần tự //for (int k = 0; k < lst_phongthi.Count(); k++) //{ CPhongThi pt = Utils.lst_phongthi[k]; //kiểm tra xem phòng thi này còn bài thi k pt.sobaithi_con_theophong = pt.Lst_baithi_theophong.Count(); if (pt.sobaithi_con_theophong > 0) { //nếu còn bài thi trong phòng thì kiểm tra xem nó có > phandoan k? if (pt.sobaithi_con_theophong > chiadoan) { //Đ: kiểm tra số bài thi trong túi cần lấy thêm có > phandoan k? if (tui.sobaithi_con_theotui > chiadoan) { //Đ: lấy tuần tự số <phandoan> bài từ phòng thi ném vào trong túi hiện tại Move_record_from_pt_to_tui(tui, pt, chiadoan); k = k + 1; } else { //S: lấy toàn bộ số bài thi còn trong phòng ném vào trong túi. Move_record_from_pt_to_tui(tui, pt, tui.sobaithi_con_theotui); //k = k + 1; } //update số bài thi còn Update_sobaithi_con(tui, pt); } else { //S: kiểm tra số bài thi cần thêm vào túi có lớn hơn số bài thi còn trong phòng k if (tui.sobaithi_con_theotui >= pt.sobaithi_con_theophong) { //Đ: lấy hết số bài thi còn trong phòng Move_record_from_pt_to_tui(tui, pt, pt.sobaithi_con_theophong); //k = k + 1; } else { /********************************************************/ #region summary: đoạn này để chống phân mảnh bài thi. //---------------------------------------------------------------- //S: kiểm tra số phòng thi còn trong lst_phongthi >2 hay không //if (lst_phongthi.Count() > 2) //{ // //Đ: kiểm tra số lượng bài thi còn dư lại nếu lấy = số bài thi cần thêm vào túi // int sobaithi_con_saukhi_laydu_theotui = pt.sobaithi_con_theophong - tui.sobaithi_con_theotui; // if (sobaithi_con_saukhi_laydu_theotui > 3) // { // //Đ: Lấy = số bài thi cần thêm vào túi. // Move_record_from_pt_to_tui(tui, pt, tui.sobaithi_con_theotui); // } //} //else //{ //------------------------------------------------------------------------ #endregion /********************************************************/ //S: Lấy = số bài thi cần thêm vào túi. Move_record_from_pt_to_tui(tui, pt, tui.sobaithi_con_theotui); //} } //update số bài thi còn Update_sobaithi_con(tui, pt); } } else { //nếu phòng thi này k còn bài thi nào -> loại ra khỏi list_phongthi Utils.lst_phongthi.Remove(pt); } //nếu đã lấy đủ số bài thi cho túi thì break loop. if (tui.sobaithi_con_theotui == 0) { break; } } //} //sau khi chèn đủ số bài thi vào túi -> add vào list_tui Utils.lst_tui.Add(tui); } #endregion #region đánh số túi cho từng túi bài thi Danh_matui(); #endregion }