Example #1
0
 private void btnThemMoi_Click(object sender, EventArgs e)
 {
     if (txtMaThon.Text != "" && txtTenThon.Text != "")
     {
         if (KiemTraMa(txtMaThon.Text) == false)
         {
             tbThonXom thon = new tbThonXom();
             thon.MaThon  = txtMaThon.Text;
             thon.TenThon = txtTenThon.Text;
             db.tbThonXoms.InsertOnSubmit(thon);
             db.SubmitChanges();
             LoadDGVThon();
             txtMaThon.Text  = "";
             txtTenThon.Text = "";
         }
         else
         {
             MessageBox.Show("Nhập mã khác!");
         }
     }
     else
     {
         MessageBox.Show("Bạn hãy điền đầy đủ thông tin!");
     }
 }
Example #2
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn sửa thông tin này!?", "AptechFinanceManage", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
            {
                hang = dgvThon.CurrentRow.Index;
                tbThonXom th = db.tbThonXoms.SingleOrDefault(t1 => t1.MaThon == txtMaThon.Text);
                th.MaThon  = txtMaThon.Text;
                th.TenThon = txtTenThon.Text;
                db.SubmitChanges();
                LoadDGVThon();
                txtMaThon.Text    = "";
                txtTenThon.Text   = "";
                txtMaThon.Enabled = true;
            }

            MessageBox.Show("Sửa thành công!");
        }
Example #3
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn Muốn xóa thông tin này?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
     {
         tbThonXom th = db.tbThonXoms.SingleOrDefault(t1 => t1.MaThon == txtMaThon.Text);
         if (th != null)
         {
             dgvThon.Rows.RemoveAt(dgvThon.CurrentRow.Index);
             db.tbThonXoms.DeleteOnSubmit(th);
             db.SubmitChanges();
             LoadDGVThon();
             txtMaThon.Text    = "";
             txtTenThon.Text   = "";
             txtMaThon.Enabled = true;
         }
     }
     MessageBox.Show("Xóa thành công");
 }
Example #4
0
        private void btnDongY_Click(object sender, EventArgs e)
        {
            try
            {
                if (cboThon.Text != "" && txtMaHo.Text != "" && txtTenChuHo.Text != "" && txtNgaySinh.Text != "")
                {
                    if (KiemTraMa(txtMaHo.Text) == false)
                    {
                        tbThonXom thon = db.tbThonXoms.SingleOrDefault(p => p.TenThon == cboThon.Text.Trim());
                        tbChuHo   hogd = new tbChuHo()
                        {
                            MaHoGiaDinh = txtMaHo.Text.Trim(),
                            TenChuHo    = txtTenChuHo.Text.Trim(),
                            NgaySinh    = DateTime.Parse(txtNgaySinh.Text.Trim()),
                            DanToc      = cboDanToc.Text.Trim(),
                            MaThon      = thon.MaThon
                        };



                        if (rdbNam.Checked == true)
                        {
                            hogd.GioiTinh = "Nam";
                        }
                        if (rdbNu.Checked == true)
                        {
                            hogd.GioiTinh = "Nữ";
                        }

                        tbThanhVien ThanhVien = new tbThanhVien();
                        ThanhVien.GioiTinh       = hogd.GioiTinh;
                        ThanhVien.TenThanhVien   = hogd.TenChuHo;
                        ThanhVien.NgaySinh       = hogd.NgaySinh;
                        ThanhVien.QuanHeVoiChuHo = "Chủ hộ";
                        ThanhVien.DanToc         = hogd.DanToc;
                        hogd.tbThanhViens.Add(ThanhVien);
                        db.tbChuHos.InsertOnSubmit(hogd);
                        db.SubmitChanges();
                        LamMoi();
                        MessageBox.Show("Thêm thành công");
                        var thanhvien = (from tv in db.tbThanhViens
                                         select

                                         new
                        {
                            tv.tbChuHo.TenChuHo,
                            tv.MaHoGiaDinh,
                            tv.TenThanhVien,
                            tv.QuanHeVoiChuHo,
                            tv.NgaySinh,
                            tv.GioiTinh,
                            tv.TinhTrang,
                            tv.GiaDinhChinhSach,
                            tv.DanToc,
                            tv.NamTotNghiep,
                            tv.NamBoHoc,
                            tv.TrinhDo1,
                            tv.TrinhDo2,
                            tv.TrinhDo3,
                            tv.TrinhDo4,
                            tv.TrinhDo5,
                            tv.NgayChuyenDen,
                            tv.NoiKhac,
                            tv.GhiChu,
                            tv.MaThanhVien
                        }).OrderBy(p => p.TenChuHo);
                        DG.DataSource = thanhvien;
                        UpdateGridView();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("hãy nhập mã khác");
                    }
                }
                else
                {
                    MessageBox.Show("Hãy điền đủ các thông tin");
                }
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }