Exemple #1
0
        public static void saveTranDau_CauThu(TranDau_CauThuDTO tdct, string method)
        {
            SqlParameter[] sqlP = new SqlParameter[3];
            sqlP[0] = new SqlParameter("@matrandau", tdct.MaTranDau);
            sqlP[1] = new SqlParameter("@madoi", tdct.MaDoi);
            sqlP[2] = new SqlParameter("@macauthu", tdct.MaCauThu);

            if (method == sys.INSERT)
            {
                GenericDAO.execNonQuery("sp_Insert_TranDauCauThu", sqlP, Conn);
            }
        }
Exemple #2
0
        //Thêm trận đấu
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int vongdau;

            try
            {
                if (txtMaTranDau.Text == "")
                {
                    MessageBox.Show("Bạn chưa tạo mã trận đấu!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtMaCT.Focus();
                }
                else if (cbxLuotDau.SelectedIndex == -1)
                {
                    MessageBox.Show("Bạn chưa chọn lượt đấu!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (txtVongDau.Text == "")
                {
                    MessageBox.Show("Bạn chưa nhập vòng đấu!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtVongDau.Focus();
                }
                else if (int.TryParse(txtVongDau.Text, out vongdau) == false)
                {
                    MessageBox.Show("Vòng đấu không hợp lệ!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtVongDau.Text = "";
                    txtVongDau.Focus();
                }
                else if (cbxMaDoiNha.SelectedIndex == -1)
                {
                    MessageBox.Show("Bạn chưa chọn đội nhà!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (cbxMaDoiKhach.SelectedIndex == -1)
                {
                    MessageBox.Show("Bạn chưa chọn đội khách!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    if (vongdau <= 0 || vongdau > 40)
                    {
                        MessageBox.Show("Vòng đấu không hợp lệ!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtVongDau.Text = "";
                        txtVongDau.Focus();
                        return;
                    }

                    string maTran = txtMaTranDau.Text;

                    TranDauDTO tranDauDTO = new TranDauDTO(maTran, cbxLuotDau.Text, int.Parse(txtVongDau.Text), cbxMaDoiNha.SelectedValue.ToString(), cbxMaDoiKhach.SelectedValue.ToString());
                    TranDauDAO.saveTranDau(tranDauDTO, sys.INSERT);

                    /*Luu thong tin cau thu doi nha -----------------------------*/
                    foreach (DataRow item in dtDoiNha.Rows)
                    {
                        item["SoLanRaSan"] = (int.Parse(item["SoLanRaSan"].ToString()) + 1).ToString();
                        TranDau_CauThuDTO dto = new TranDau_CauThuDTO(maTran, item["MaDoi"].ToString(), item["MaCauThu"].ToString());
                        dsCauThuThamGia.Add(dto);
                    }

                    foreach (TranDau_CauThuDTO item in dsCauThuThamGia)
                    {
                        TranDau_CauThu_DAO.saveTranDau_CauThu(item, sys.INSERT);
                    }

                    /*Luu thong tin cau thu doi khach ------------------------*/
                    foreach (DataRow item in dtDoiKhach.Rows)
                    {
                        item["SoLanRaSan"] = (int.Parse(item["SoLanRaSan"].ToString()) + 1).ToString();
                        TranDau_CauThuDTO dto = new TranDau_CauThuDTO(maTran, item["MaDoi"].ToString(), item["MaCauThu"].ToString());
                        dsCauThuThamGia1.Add(dto);
                    }

                    foreach (TranDau_CauThuDTO item in dsCauThuThamGia1)
                    {
                        TranDau_CauThu_DAO.saveTranDau_CauThu(item, sys.INSERT);
                    }

                    /* luu thong tin the phat cua tran dau*/
                    foreach (TranDau_TheDTO item in dsThe)
                    {
                        TranDau_The.saveTranDau_The(item, sys.INSERT);
                    }

                    /*luu thong tin ban thang cua tran dau */
                    foreach (TranDau_BanThangDTO item in dsBThang)
                    {
                        TranDau_BanThang_DAO.saveTranDau_BanThang(item, sys.INSERT);
                    }

                    TranDauDAO.tinhDiemDoiBong(maTran, sys.INSERT);
                    TranDauDAO.TinhSBT_SauTranDau(maTran, sys.INSERT);

                    MessageBox.Show("Thêm trận đấu thành công!");
                    resetTranDau();
                }
            }
            catch
            {
                MessageBox.Show("Lỗi dữ liệu!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                resetTranDau();
            }
        }