コード例 #1
0
        private void capNhatButton_Click(object sender, EventArgs e)
        {
            if (isEverythingTrue())
            {
                //TODO: update things
                try
                {
                    DIEUKIEN dk = new DIEUKIEN()
                    {
                        MaMuaGiai              = GlobalState.selectedSeasonId,
                        SoCauThuToiThieu       = Int16.Parse(soLuongCauThuMin.Value.ToString()),
                        SoCauThuToiDa          = Int16.Parse(soLuongCauThuMax.Value.ToString()),
                        TuoiToiDa              = Int16.Parse(doiTuoiMax.Value.ToString()),
                        TuoiToiThieu           = Int16.Parse(doiTuoiMin.Value.ToString()),
                        SoLanThayNguoiToiDa    = Int16.Parse(soLuotThayNguoiMax.Value.ToString()),
                        SoCauThuNuocNgoaiToiDa = Int16.Parse(soLuongNuocNgoaiMax.Value.ToString()),
                        DiemSoHoa              = Int16.Parse(diemSoHoa.Value.ToString()),
                        DiemSoThang            = Int16.Parse(diemSoThang.Value.ToString()),
                        DiemSoThua             = Int16.Parse(diemSoThua.Value.ToString())
                    };
                    Database.DieuKien_DAO.updateDieuKien(dk);

                    MessageBox.Show("Cập nhật thành công", "Thông báo");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Lỗi xảy ra");
                }
            }
            else
            {
                MessageBox.Show("Sai các quy định");
            }
        }
コード例 #2
0
        public static void updateDieuKien(DIEUKIEN dk)
        {
            SqlConnection conn        = DatabaseManager.Instance.getConnection();
            string        queryString = "UPDATE DIEUKIEN SET TuoiToiThieu = @TuoiToiThieu, TuoiToiDa = @TuoiToiDa, SoCauThuToiThieu = @SoCauThuToiThieu, SoCauThuToiDa = @SoCauThuToiDa, SoCauThuNuocNgoaiToiDa = @SoCauThuNuocNgoaiToiDa, SoLanThayNguoiToiDa = @SoLanThayNguoiToiDa, DiemSoThang = @DiemSoThang, DiemSoThua = @DiemSoThua, DiemSoHoa = @DiemSoHoa WHERE MaMuaGiai = @MaMuaGiai";
            SqlCommand    command     = new SqlCommand(queryString);

            try
            {
                command.Parameters.AddWithValue("@MaMuaGiai", dk.MaMuaGiai);
                command.Parameters.AddWithValue("@TuoiToiThieu", dk.TuoiToiThieu);
                command.Parameters.AddWithValue("@TuoiToiDa", dk.TuoiToiDa);
                command.Parameters.AddWithValue("@SoCauThuToiThieu", dk.SoCauThuToiThieu);
                command.Parameters.AddWithValue("@SoCauThuToiDa", dk.SoCauThuToiDa);
                command.Parameters.AddWithValue("@SoCauThuNuocNgoaiToiDa", dk.SoCauThuNuocNgoaiToiDa);
                command.Parameters.AddWithValue("@SoLanThayNguoiToiDa", dk.SoLanThayNguoiToiDa);
                command.Parameters.AddWithValue("@DiemSoThang", dk.DiemSoThang);
                command.Parameters.AddWithValue("@DiemSoThua", dk.DiemSoThua);
                command.Parameters.AddWithValue("@DiemSoHoa", dk.DiemSoHoa);
                command.Connection = conn;
                int res = command.ExecuteNonQuery();
                if (res == 0)
                {
                    throw new Exception();
                }
            }
            catch (SqlException SQLex)
            {
                throw SQLex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public static void createDIEUKIEN(DIEUKIEN dk)
        {
            SqlConnection conn        = DatabaseManager.Instance.getConnection();
            string        queryString = "INSERT INTO DIEUKIEN Values (@MaMuaGiai, @TuoiToiThieu, @TuoiToiDa, @SoCauThuToiThieu, @SoCauThuToiDa, @SoCauThuNuocNgoaiToiDa, @SoLanThayNguoiToiDa, @DiemSoThang, @DiemSoThua, @DiemSoHoa)";
            SqlCommand    command     = new SqlCommand(queryString);

            try
            {
                command.Parameters.AddWithValue("@MaMuaGiai", dk.MaMuaGiai);
                command.Parameters.AddWithValue("@TuoiToiThieu", dk.TuoiToiThieu);
                command.Parameters.AddWithValue("@TuoiToiDa", dk.TuoiToiDa);
                command.Parameters.AddWithValue("@SoCauThuToiThieu", dk.SoCauThuToiThieu);
                command.Parameters.AddWithValue("@SoCauThuToiDa", dk.SoCauThuToiDa);
                command.Parameters.AddWithValue("@SoCauThuNuocNgoaiToiDa", dk.SoCauThuNuocNgoaiToiDa);
                command.Parameters.AddWithValue("@SoLanThayNguoiToiDa", dk.SoLanThayNguoiToiDa);
                command.Parameters.AddWithValue("@DiemSoThang", dk.DiemSoThang);
                command.Parameters.AddWithValue("@DiemSoThua", dk.DiemSoThua);
                command.Parameters.AddWithValue("@DiemSoHoa", dk.DiemSoHoa);
                command.Connection = conn;
                int res = command.ExecuteNonQuery();
                if (res == 0)
                {
                    throw new Exception();
                }
            }
            catch (SqlException SQLex)
            {
                throw SQLex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        private void MacDichButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Đã đặt lại quy định mặc định!", "Thông Báo");
            DIEUKIEN dk = new DIEUKIEN()
            {
                MaMuaGiai              = GlobalState.selectedSeasonId,
                SoCauThuToiThieu       = 11,
                SoCauThuToiDa          = 40,
                TuoiToiDa              = 40,
                TuoiToiThieu           = 18,
                SoLanThayNguoiToiDa    = 3,
                SoCauThuNuocNgoaiToiDa = 3,
                DiemSoHoa              = 1,
                DiemSoThang            = 3,
                DiemSoThua             = 0
            };

            Database.DieuKien_DAO.updateDieuKien(dk);
            ThayDoiQuyDinh_Load(this, new EventArgs());
        }
コード例 #5
0
        public static void selectDieuKien(string MaMuaGiai, out DIEUKIEN dk)
        {
            SqlConnection conn        = DatabaseManager.Instance.getConnection();
            string        queryString = "SELECT * FROM DIEUKIEN WHERE MaMuaGiai = @MaMuaGiai";
            SqlCommand    command     = new SqlCommand(queryString);

            dk = new DIEUKIEN()
            {
                MaMuaGiai = MaMuaGiai
            };
            try
            {
                command.Parameters.AddWithValue("@MaMuaGiai", MaMuaGiai);
                command.Connection = conn;
                SqlDataReader reader = command.ExecuteReader();
                if (reader.Read())
                {
                    dk.TuoiToiThieu           = reader.GetInt32(1);
                    dk.TuoiToiDa              = reader.GetInt32(2);
                    dk.SoCauThuToiThieu       = reader.GetInt32(3);
                    dk.SoCauThuToiDa          = reader.GetInt32(4);
                    dk.SoCauThuNuocNgoaiToiDa = reader.GetInt32(5);
                    dk.SoLanThayNguoiToiDa    = reader.GetInt32(6);
                    dk.DiemSoThang            = reader.GetInt32(7);
                    dk.DiemSoThua             = reader.GetInt32(8);
                    dk.DiemSoHoa              = reader.GetInt32(9);
                }
                reader.Close();
            }
            catch (SqlException SQLex)
            {
                throw SQLex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #6
0
        private void KhoiTaoMuaGiaiButton_Click(object sender, EventArgs e)
        {
            //call data access
            try
            {
                MUAGIAI muagiai = new MUAGIAI()
                {
                    TenMuaGiai = tenMuaGiaTextBox.Text,
                    TrangThai  = 0,
                };
                Database.MuaGiai_DAO.createMuaGiai(muagiai);
                string   new_MaMuaGiai = Database.MuaGiai_DAO.queryMaMuaGiai(muagiai);
                DIEUKIEN dk            = new DIEUKIEN()
                {
                    MaMuaGiai              = new_MaMuaGiai,
                    SoCauThuToiThieu       = 11,
                    SoCauThuToiDa          = 40,
                    TuoiToiDa              = 40,
                    TuoiToiThieu           = 18,
                    SoLanThayNguoiToiDa    = 3,
                    SoCauThuNuocNgoaiToiDa = 3,
                    DiemSoHoa              = 1,
                    DiemSoThang            = 3,
                    DiemSoThua             = 0
                };
                Database.DieuKien_DAO.createDIEUKIEN(dk);
                THUTUUUTIEN thutu = new THUTUUUTIEN()
                {
                    ChiSoUuTien   = 1,
                    MaMuaGiai     = new_MaMuaGiai,
                    TenLoaiUuTien = "Điểm",
                };
                Database.ThuTuUuTien_DAO.createThuTuUuTien(thutu);
                THUTUUUTIEN thutu2 = new THUTUUUTIEN()
                {
                    ChiSoUuTien   = 2,
                    MaMuaGiai     = new_MaMuaGiai,
                    TenLoaiUuTien = "Hiệu Số",
                };
                Database.ThuTuUuTien_DAO.createThuTuUuTien(thutu2);
                THUTUUUTIEN thutu3 = new THUTUUUTIEN()
                {
                    ChiSoUuTien   = 3,
                    MaMuaGiai     = new_MaMuaGiai,
                    TenLoaiUuTien = "Số Bàn Sân Khách",
                };
                Database.ThuTuUuTien_DAO.createThuTuUuTien(thutu3);
                THUTUUUTIEN thutu4 = new THUTUUUTIEN()
                {
                    ChiSoUuTien   = 4,
                    MaMuaGiai     = new_MaMuaGiai,
                    TenLoaiUuTien = "Kết Quả Đối Đầu",
                };
                Database.ThuTuUuTien_DAO.createThuTuUuTien(thutu4);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi xảy ra");
            }

            // Kiểm tra điền đầy đủ thông tin chưa? Nếu đầy đủ thì sẽ tiến thẳng tới màn hình
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                FirstScreen form = new FirstScreen();
                this.Hide();
                form.ShowDialog();
            }
        }