private void btnSVLuu_Click(object sender, EventArgs e)
 {
     if (btnSVLuu.Tag.ToString() == "Them")
     {
         string thoigian = convertToDateSQL(dtpthoigian.Value.ToString("dd/MM/yyy"));
         myHvRl = new Models.HVRL(lbhvrl.Text, thoigian, lbmahv.Text, txtkqrl.Text, txtgs.Text
                                  , txtboi.Text, txtchaydai.Text, txtchayngan.Text,
                                  txtnhayxa.Text, txtxa.Text);
         var i = myHvRl.InsertHVRL();
         if (i == 0)
         {
             MessageBox.Show("Thêm mới thất bại !");
         }
         else
         {
             MessageBox.Show("Thêm mới thành công !");
             hienthidanhsach();
         }
     }
     if (btnSVLuu.Tag.ToString() == "Sua")
     {
         string thoigian = convertToDateSQL(dtpthoigian.Value.ToString("dd/MM/yyy"));
         myHvRl = new Models.HVRL(lbhvrl.Text, thoigian, lbmahv.Text, txtkqrl.Text, txtgs.Text
                                  , txtboi.Text, txtchaydai.Text, txtchayngan.Text,
                                  txtnhayxa.Text, txtxa.Text);
         var i = myHvRl.UpdateHVRL();
         if (i == 0)
         {
             MessageBox.Show("Sửa thất bại !");
         }
         else
         {
             MessageBox.Show("Sửa thành công !");
             hienthidanhsach();
         }
     }
 }
示例#2
0
        private void btnluu_Click(object sender, EventArgs e)
        {
            string _Maplrl = "";

            try
            {
                _Maplrl = txtkqrl.Text;
            }
            catch { }
            string _NgaySinh = convertToDateSQL(dtpthoigian.Value.ToString("dd/MM/yyy"));

            string _MaGS = "";

            try
            {
                _MaGS = txtgs.Text;
            }
            catch { }
            string _Boi = "";

            try
            {
                _Boi = txtboi.Text;
            }
            catch { }
            string _chaydai = "";

            try
            {
                _chaydai = txtchaydai.Text;
            }
            catch { }
            string _chayngan = "";

            try
            {
                _chayngan = txtchayngan.Text;
            }
            catch { }
            string _xa = "";

            try
            {
                _xa = txtxa.Text;
            }
            catch { }
            string _nhayxa = "";

            try
            {
                _nhayxa = txtnhayxa.Text;
            }
            catch { }
            if (txtboi.Text != "")
            {
                if (txtchaydai.Text != "")
                {
                    if (txtchayngan.Text != "")
                    {
                        if (txtnhayxa.Text != "")
                        {
                            if (txtxa.Text != "")
                            {
                                string thoigian = convertToDateSQL(dtpthoigian.Value.ToString("dd/MM/yyy"));
                                mygvrl = new Models.HVRL(lbhvrl.Text, thoigian, lbmahv.Text, txtkqrl.Text, txtgs.Text
                                                         , txtboi.Text, txtchaydai.Text, txtchayngan.Text,
                                                         txtnhayxa.Text, txtxa.Text);
                                var i = mygvrl.InsertHVRL();
                                if (i == 0)
                                {
                                    MessageBox.Show("Thêm mới thất bại !");
                                }
                                else
                                {
                                    MessageBox.Show("Thêm mới thành công !");
                                }
                            }
                        }
                    }
                }
            }
        }