Beispiel #1
0
 //Thêm
 public bool them_Thannhantamtru(THANNHAN_TAMTRU tb)
 {
     try
     {
         data.THANNHAN_TAMTRUs.InsertOnSubmit(tb);
         data.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #2
0
 //Xóa
 public bool xoa_Thannhan_tamtru(string matn, string pMakt)
 {
     try
     {
         THANNHAN_TAMTRU tb = data.THANNHAN_TAMTRUs.Where(t => t.MATN == matn && t.MAKT == pMakt).FirstOrDefault();
         data.THANNHAN_TAMTRUs.DeleteOnSubmit(tb);
         data.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #3
0
 //Sửa
 public bool sua_thannhan_tamtru(THANNHAN_TAMTRU ptntamtru)
 {
     try
     {
         THANNHAN_TAMTRU nv = data.THANNHAN_TAMTRUs.Where(t => t.MATN == ptntamtru.MATN && t.MAKT == ptntamtru.MAKT).FirstOrDefault();
         if (nv != null)
         {
             nv.MAKT    = ptntamtru.MAKT;
             nv.MATN    = ptntamtru.MATN;
             nv.NGAYVAO = ptntamtru.NGAYVAO;
             nv.NGAYRA  = ptntamtru.NGAYRA;
             data.SubmitChanges();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #4
0
        private void btn_luu_Click(object sender, EventArgs e)
        {
            if (txt_matn.Text == string.Empty || txt_tentn.Text == string.Empty || txt_scm.Text == string.Empty ||
                txt_ngayvao.Text == string.Empty)
            {
                txt_tentn_Validating(sender, e);
                txt_scm_Validating(sender, e);
                //txt_ngayra_Validating(sender, e);
                txt_ngayvao_Validating(sender, e);
                return;
            }
            THANNHAN tn = new THANNHAN();

            tn.MATN     = txt_matn.Text;
            tn.TENTN    = txt_tentn.Text;
            tn.SOCMNDTN = txt_scm.Text;
            if (rdo_nam.Checked == true)
            {
                tn.GIOITINH_TN = "Nam";
            }
            else
            {
                tn.GIOITINH_TN = "true";
            }

            THANNHAN_TAMTRU tntt = new THANNHAN_TAMTRU();

            tntt.MAKT    = cbo_makt.Text;
            tntt.MATN    = txt_matn.Text;
            tntt.NGAYVAO = Convert.ToDateTime(txt_ngayvao.Text);
            if (txt_ngayra.Text == string.Empty)
            {
                tntt.NGAYRA = Convert.ToDateTime(txt_ngayra.Text);
            }
            else
            {
                tntt.NGAYRA = null;
            }

            if (btn_them.Enabled == true && btn_sua.Enabled == false)
            {
                if (bll_thannhan.ktkc(tn.MATN) == true)
                {
                    MessageBox.Show("trùng khóa chính thân nhân");
                    return;
                }
                if (dal_tntamtru.ktkc_thannhan_tamtru(tntt.MATN, tntt.MAKT) == true)
                {
                    MessageBox.Show("trùng khóa chính thân nhân tạm trú");
                    return;
                }
                if (bll_thannhan.Them_ThanNhan(tn) == true && dal_tntamtru.them_Thannhantamtru(tntt) == true)
                {
                    MessageBox.Show("Thành công");
                    grv_thannhan.DataSource = dal_tntamtru.loadthannhantheoma();
                }
                else
                {
                    MessageBox.Show("Thất bại");
                }
            }
            if (btn_sua.Enabled == true && btn_luu.Enabled == true)
            {
                tntt.NGAYRA = Convert.ToDateTime(txt_ngayra.Text);
                if (bll_thannhan.sua_thanNhan(tn) == true && dal_tntamtru.sua_thannhan_tamtru(tntt) == true)
                {
                    MessageBox.Show("Thành công");
                    grv_thannhan.DataSource = dal_tntamtru.loadthannhantheoma();
                }
                else
                {
                    MessageBox.Show("Thất bại");
                }
            }
        }