예제 #1
0
        private void UpdateButt_Click(object sender, EventArgs e)
        {
            ThamSoDTO ts = new ThamSoDTO();

            //check Tuổi CT
            if (TuoiCTMinNumericUD.Value <= TuoiCTMaxNumericUD.Value)
            {
                ts.TuoiCTMin = (int)TuoiCTMinNumericUD.Value;
                ts.TuoiCTMax = (int)TuoiCTMaxNumericUD.Value;
            }
            else
            {
                MessageBox.Show("Qui định tuổi cầu thủ không hợp lệ !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                TuoiCTMinNumericUD.Select();
                return;
            }
            //check Số lượng CT
            if (SoLuongCTMinNumericUD.Value <= SoLuongCTMaxNumericUD.Value)
            {
                ts.SoLuongCTMin = (int)SoLuongCTMinNumericUD.Value;
                ts.SoLuongCTMax = (int)SoLuongCTMaxNumericUD.Value;
            }
            else
            {
                MessageBox.Show("Qui định số lượng cầu thủ không hợp lệ !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                SoLuongCTMinNumericUD.Select();
                return;
            }
            //check Số lượng cầu thủ ngoại tối đa
            if (SoCTNgoaiMaxNumericUD.Value <= SoLuongCTMaxNumericUD.Value)
            {
                ts.SoCTNgoaiMax = (int)SoCTNgoaiMaxNumericUD.Value;
            }
            else
            {
                MessageBox.Show("Số cầu thủ ngoại phải nhỏ hơn số cầu thủ tối đa !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                SoCTNgoaiMaxNumericUD.Select();
                return;
            }
            //check thời gian ghi bàn tối đa
            ts.TGGhiBanMax = (int)TGGhiBanMaxNumericUD.Value * 60; //covert phút sang giây
            //check điểm thắng - hòa - thua
            if (LostNumericUD.Value < DrawNumericUD.Value && DrawNumericUD.Value < WinNumericUD.Value)
            {
                ts.DiemThang = (int)WinNumericUD.Value;
                ts.DiemHoa   = (int)DrawNumericUD.Value;
                ts.DiemThua  = (int)LostNumericUD.Value;
            }
            else
            {
                MessageBox.Show("Qui định điểm không hợp lệ: Điểm Thua<Điểm Hòa<Điểm thắng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                WinNumericUD.Select();
                return;
            }
            //check Loại bàn thắng
            int iStop = ListLoaiBanThangSTO.Count;

            lbtBUS.deleteData();
            for (int i = 0; i < iStop; i++)
            {
                lbtBUS.them(ListLoaiBanThangSTO[i]);
            }

            //cập nhật TTXH
            for (int i = 0; i < dataGridViewTTXH.RowCount; i++)
            {
                int a = Int32.Parse(dataGridViewTTXH.Rows[i].Cells[0].Value.ToString());
                switch (a)
                {
                case 0:
                {
                    ts.Diem = i;
                    break;
                }

                case 1:
                {
                    ts.HieuSo = i;
                    break;
                }

                case 2:
                {
                    ts.BTSK = i;
                    break;
                }

                case 3:
                {
                    ts.KQDK = i;
                    break;
                }
                }
            }
            //thêm Mã Tham Số
            ts.MaThamSo = "1";

            //thêm vào database
            tsBUS.addData(ts);
            //load lại dữ liệu lên form
            UpdateButt_Clicked = 1;
            loadData();
        }