Exemplo n.º 1
0
 private void btnSVLuu_Click(object sender, EventArgs e)
 {
     if (btnSVLuu.Tag.ToString() == "Them")
     {
         string thoigian = convertToDateSQL(dtpthoigian.Value.ToString("dd/MM/yyy"));
         myhvkl = new Models.HVKL(lbhvkl.Text, thoigian, lbmahv.Text, txtkqkl.Text, txtcdg.Text
                                  , txtndg.Text, txtdkl.Text, txtht.Text,
                                  txtls.Text, txthdd.Text);
         var i = myhvkl.InsertHVKL();
         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"));
         myhvkl = new Models.HVKL(lbhvkl.Text, thoigian, lbmahv.Text, txtkqkl.Text, txtcdg.Text
                                  , txtndg.Text, txtdkl.Text, txtht.Text,
                                  txtls.Text, txthdd.Text);
         var i = myhvkl.UpdateHVKL();
         if (i == 0)
         {
             MessageBox.Show("Sửa mới thất bại !");
         }
         else
         {
             MessageBox.Show("Sửa mới thành công !");
             hienthidanhsach();
         }
     }
 }
Exemplo n.º 2
0
        private void btnluu_Click(object sender, EventArgs e)
        {
            string _Maplkl = "";

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

            string _Capdanhgia = "";

            try
            {
                _Capdanhgia = txtcdg.Text;
            }
            catch { }
            string _Nguoidanhgia = "";

            try
            {
                _Nguoidanhgia = txtndg.Text;
            }
            catch { }
            string _Diemkiluat = "";

            try
            {
                _Diemkiluat = txtdkl.Text;
            }
            catch { }
            string _Diemhoctap = "";

            try
            {
                _Diemhoctap = txtht.Text;
            }
            catch { }
            string _Diemloisong = "";

            try
            {
                _Diemloisong = txtls.Text;
            }
            catch { }
            string _Diemhoatdongdoan = "";

            try
            {
                _Diemhoatdongdoan = txthdd.Text;
            }
            catch { }
            if (txtdkl.Text != "")
            {
                if (txtht.Text != "")
                {
                    if (txtls.Text != "")
                    {
                        if (txthdd.Text != "")
                        {
                            if (txthdd.Text != "")
                            {
                                string thoigian = convertToDateSQL(dtpthoigian.Value.ToString("dd/MM/yyy"));
                                myHvkl = new Models.HVKL(lbhvkl.Text, thoigian, lbmahv.Text, txtkqkl.Text, txtcdg.Text
                                                         , txtndg.Text, txtdkl.Text, txtht.Text,
                                                         txtls.Text, txthdd.Text);
                                var i = myHvkl.UpdateHVKL();
                                if (i == 0)
                                {
                                    MessageBox.Show("Sửa mới thất bại !");
                                    this.Close();
                                }
                                else
                                {
                                    MessageBox.Show("Sửa mới thành công !");
                                    this.Close();
                                }
                            }
                        }
                    }
                }
            }
        }