private void btnLuu_Click(object sender, EventArgs e) { if (this.txtTendongho.TextLength == 0) { MessageBox.Show("Tên dòng họ không được bỏ trống"); } else if (this.txtHoTen.TextLength == 0) { MessageBox.Show("Họ tên không được bỏ trống"); } else if (txtDiachi.TextLength == 0) { MessageBox.Show("Địa chỉ không được bỏ trống"); } else { try { ThemTV themtv = new ThemTV(); GhiNhanKetThuc gnkt = new GhiNhanKetThuc(); GhiNhanThanhTich gntt = new GhiNhanThanhTich(); themtv.set_tenDH(txtTendongho.Text); //Lấy giá trị text của txtTendongho gnkt.set_tenDH(txtTendongho.Text); //Lấy giá trị text của txtTendongho gntt.set_tenDH(txtTendongho.Text); //Lấy giá trị text của txtTendongho if (rdoNam.Checked == true) { gioitinh = rdoNam.Text; } if (rdoNu.Checked == true) { gioitinh = rdoNu.Text; } DateTime NgaySinh = dtpNgaySinh.Value.Date; DateTime NgayVH = dtpNgayVH.Value.Date; THANHVIEN tv = new THANHVIEN(NgaySinh, NgayVH, 1, "TV01", busqq.Get_QQ(cboQuequan.SelectedItem.ToString()), txtDiachi.Text, txtHoTen.Text, gioitinh); bustv.Insert(tv); foreach (object item in clbNghenghiep.CheckedItems) { List_TenNNghiep.Add(item.ToString()); } foreach (string s in List_TenNNghiep) { TV_NGHENGHIEP tv_nn = new TV_NGHENGHIEP(busnn.Get_NN(s), bustv.Genarate_MATV(bustv.Get_CountRow() - 1)); bustv_nn.Insert_TV_NN(tv_nn); } } catch (Exception ex) { MessageBox.Show("Thêm dữ liệu bị lỗi." + ex.ToString()); } } QuanLyGiaPha f = new QuanLyGiaPha(); f.Show(); this.Hide(); }
private void btnDangNhap_Click(object sender, EventArgs e) { try { if (txtTK.Text == "") { MessageBox.Show("Bạn chưa nhập tài khoản !", "Hãy nhập đầy đủ", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTK.Focus(); } else { if (txtMK.Text == "") { MessageBox.Show("Bạn chưa nhập mật khẩu !", "Hãy nhập đầy đủ", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMK.Focus(); } else { SqlConnection _cn = new SqlConnection(@"Data Source=THIENAN\SQLEXPRESS;Initial Catalog=QUANLYCAYGIAPHA;Integrated Security=True"); _cn.Open(); string tk = txtTK.Text; string mk = txtMK.Text; string sql = "select * from NguoiDung where TaiKhoan='" + tk + "' and MatKhau='" + mk + "'"; SqlCommand cmd = new SqlCommand(sql, _cn); SqlDataReader dta = cmd.ExecuteReader(); if (dta.Read() == true) { if (bustv.Check_SQL() == 0) { NhapThuyTo ntt = new NhapThuyTo(); ntt.ShowDialog(); this.Hide(); } else if (bustv.Check_SQL() == 1) { QuanLyGiaPha f1 = new QuanLyGiaPha(); f1.Show(); this.Hide(); } } else { MessageBox.Show("Nhập sai tài khoản hoặc mật khẩu !", "Hãy nhập lại", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } catch { MessageBox.Show("Lỗi kết nối !"); } }