コード例 #1
0
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            int    nRes     = nSubCategoryID;
            string tranName = "SaveSubcategory";

            DBase.BeginTransaction(tranName);

            //1. Save subcategory info
            if (nSubCategoryID <= 0)
            {
                nRes = DBase.ExecuteReturnInt(Config.DbSaveSBSubCategory,
                                              new object[] { "@id", nSubCategoryID,
                                                             "@CategoryID", Core.GetSelectedValueInt(comboCategory),
                                                             "@name", txtName.Text,
                                                             "@SpreadFrom", txtSpreadFrom.Text,
                                                             "@SpreadTo", txtSpreadTo.Text,
                                                             "@SpreadStep", txtSpreadStep.Text,
                                                             "@OuFrom", txtOuFrom.Text,
                                                             "@OuTo", txtOuTo.Text,
                                                             "@OuStep", txtOuStep.Text });

                if (nRes <= 0)
                {
                    lblInfo.ForeColor = Color.Red;
                    switch (nRes)
                    {
                    case -1:
                        lblInfo.Text = "Typed subcategory name already exists";
                        break;

                    case 0:
                        lblInfo.Text = "Database error occured";
                        break;

                    default:
                        lblInfo.Text = "Unknown error occured";
                        break;
                    }
                    DBase.RollbackTransaction(tranName);
                    return;
                }
            }

            //2. Update Team info
            int nRes2 = DBase.ExecuteNonQuery(Config.DbSaveTeamTable, "@SubcategoryID", nRes,
                                              "@TeamValues", hdnTeamCSV.Value);

            if (nRes2 < 0)
            {
                DBase.RollbackTransaction(tranName);
                lblInfo.Text      = "DB erors occured during processing Team Table";
                lblInfo.ForeColor = Color.Red;
                return;
            }

            DBase.CommitTransaction(tranName);
            lblInfo.ForeColor = Color.Green;
            lblInfo.Text      = "SubCategory details have been saved";
            StoreBackID(nRes);
            hdnID.Value = nRes.ToString();
            //BindTeam();

            Response.Redirect(GetGoBackUrl());
        }
コード例 #2
0
        protected void btnProcess_Click(object sender, System.EventArgs e)
        {
            string tranName = "ProcessEvent";

            DBase.BeginTransaction(tranName);
            //1. Save Event Score
            int nRes = DBase.ExecuteNonQuery(Config.DbSaveEventScore,
                                             "@EventID", nEventID,
                                             "@HomeScore", txtHomeScore.Text,
                                             "@AwayScore", txtAwayScore.Text,
                                             "@HomeScoreHalf", txtHomeScoreHalf.Text,
                                             "@AwayScoreHalf", txtAwayScoreHalf.Text,
                                             "@StateID", stateProcessing);

            if (nRes < 0)
            {
                ShowError("DataBase error occured");
                DBase.RollbackTransaction(tranName);
                return;
            }

            //2. Update Outcomes
            DataTable oDT = DBase.GetDataTableBatch(string.Format(Config.DbUpdateOutcome, nEventID));

            DataColumn[] PrimaryKeyArray = new DataColumn[1];
            PrimaryKeyArray[0] = oDT.Columns["ID"];
            oDT.PrimaryKey     = PrimaryKeyArray;

            int HomeScore     = Utils.GetInt(txtHomeScore.Text);
            int HomeScoreHalf = Utils.GetInt(txtHomeScoreHalf.Text);
            int AwayScore     = Utils.GetInt(txtAwayScore.Text);
            int AwayScoreHalf = Utils.GetInt(txtAwayScoreHalf.Text);

            foreach (DataRow oRow in oDT.Rows)
            {
                int BetTypeID = Utils.GetInt(oRow["BetTypeID"]);
                int IsHome    = Utils.GetInt(oRow["IsHome"]);
                int PeriodID  = Utils.GetInt(oRow["PeriodID"]);
                switch (BetTypeID)
                {
                case typeSpread:
                    if (IsHome == againstHome)
                    {
                        oRow["WonValue"] = HomeScore - AwayScore;
                    }
                    else
                    {
                        oRow["WonValue"] = AwayScore - HomeScore;
                    }

                    if (PeriodID == periodFull)
                    {
                        oRow["OutcomeResultID"] = hdnResultHomeSpread.Value;
                    }
                    else
                    {
                        oRow["OutcomeResultID"] = hdnResultHomeSpreadHalf.Value;
                    }
                    break;

                case typeOu:
                    oRow["WonValue"] = HomeScore + AwayScore;

                    if (PeriodID == periodFull)
                    {
                        oRow["OutcomeResultID"] = hdnResultTotalOU.Value;
                    }
                    else
                    {
                        oRow["OutcomeResultID"] = hdnResultTotalOUHalf.Value;
                    }
                    break;

                case typeML:
                    if (IsHome == againstHome)
                    {
                        oRow["OutcomeResultID"] = hdnResultHomeML.Value;
                    }
                    else
                    {
                        oRow["OutcomeResultID"] = hdnResultAwayML.Value;
                    }
                    break;
                }
            }


            bool bRes = DBase.Update(oDT);

            if (!bRes)
            {
                ShowError("DataBase error occured during puting results");
                DBase.RollbackTransaction(tranName);
                return;
            }

            //3. Processing Bets
            int nRes2 = DBase.ExecuteNonQuery(Config.DbProcessBetsOnEventFinish, "@EventID", nEventID);

            if (nRes2 < 0)
            {
                ShowError("DataBase error occured in nprocessing Bets");
                DBase.RollbackTransaction(tranName);
                return;
            }

            //Commit transaction
            DBase.CommitTransaction(tranName);


            //4. Invoke Com
            object StartDate = DateTime.Now;
            string sRet      = InvokeCom(StartDate, sGuid, stateProcessing);

            if (sRet == null)
            {
                return;
            }
            sGuid = sRet;

            // Everything is Ok
            nStateID          = stateProcessing;
            hdnStateID.Value  = nStateID.ToString();
            hdnGuid.Value     = sGuid;
            lblInfo.ForeColor = Color.Green;
            lblInfo.Text      = "Event was processed successfully";

            //Response.Redirect(GetGoBackUrl());

            GetPageData();
            InitJS();
            DisplayControls();
        }