Пример #1
0
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            int nRes = 0;

            SqlCommand             oCmd    = DBase.GetCommand(Config.DbSaveUserDetails);
            SqlParameterCollection oParams = oCmd.Parameters;

            //user Data
            oParams.Add("@ID", nUserID);
            oParams.Add("@FirstName", txtFirstName.Text);
            oParams.Add("@LastName", txtLastName.Text);
            oParams.Add("@Email", txtEmail.Text);
            oParams.Add("@Location", txtLocation.Text);
            oParams.Add("@StatusID", Core.GetSelectedValueInt(comboStatus));
            oParams.Add("@SexID", Core.GetSelectedValueInt(comboSex));
            oParams.Add("@LoginName", txtLogin.Text);
            oParams.Add("@Password", txtPassword.Text);
            //Mailing Address data
            oParams.Add("@Address", txtAddress.Text);
            oParams.Add("@City", txtCity.Text);
            oParams.Add("@Zip", txtZip.Text);
            oParams.Add("@Phone", txtPhone.Text);
            oParams.Add("@StateID", Core.GetSelectedValueInt(comboState));
            oParams.Add("@CountryID", Core.GetSelectedValueInt(comboCountry));
            oParams.Add("@ChatAccess", (ChatCheck.Checked ? 1: 0));

            nRes = DBase.ExecuteReturnInt(oCmd);
            if (nRes > 0)
            {
                nUserID         = nRes;
                hdnUserID.Value = nRes.ToString();
                StoreBackID(nRes);
                lblInfo.Text      = "User has been saved";
                lblInfo.ForeColor = Color.Green;

                Response.Redirect(GetGoBackUrl());

                ShowControls();
            }
            else
            {
                switch (nRes)
                {
                case -1:
                    lblInfo.Text = "Such login name already exists";
                    break;

                default:
                    lblInfo.Text = "Database error occured";
                    break;
                }
            }
        }
Пример #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //1. Create new xml
            string     xmlString = "";
            ApiControl oEngine   = Config.GetApIEngine();

            try
            {
                DateTime actTime;
                try
                {
                    actTime = DateTime.Parse(txtActivatedTime.Text, new CultureInfo("en-US"));
                }
                catch
                {
                    lblInfo.Text = "Incorrect value for Activated Time. Please enter valid date.";
                    return;
                }

                nEngineID = Core.GetSelectedValueInt(comboEngine);

                xmlString = oEngine.GetDefaultProperty(nEngineID, ApiMsg.enProcessFormTarget.Process);

                xmlString = oCom.getFormXml(xmlString, "gameengine/properties/property", Page);
                xmlString = oCom.setAttributeValue(xmlString, "gameengine/properties/property", "Tournament Type", (string)Session["Tournament Type Process"]);
                if (xmlString == null)
                {
                    return;
                }

                //2. Save values in DB
                nCurrencyID    = Core.GetSelectedValueInt(comboCurrency);
                nSubCategoryID = Core.GetSelectedValueInt(comboSubCategory);
                nActDispID     = Core.GetSelectedValueInt(comboActDisp);


                SqlCommand             oCmd    = DBase.GetCommand(Config.DbCreateFirstGameProcess);
                SqlParameterCollection oParams = oCmd.Parameters;

                oParams.Add("@Name", txtName.Text);
                oParams.Add("@GameEngineID", nEngineID);
                oParams.Add("@CurrencyTypeID", nCurrencyID);
                oParams.Add("@SubCategoryID", nSubCategoryID);
                oParams.Add("@SettingsXml", xmlString);
                oParams.Add("@ActionDispatcherID", nActDispID);
                oParams.Add("@ActivatedTime", actTime);
                oParams.Add("@ProtectedCode", txtProtCode.Text);
                oParams.Add("@RewardID", txtReward.Text);
                oParams.Add("@Visible", chVisible.Checked ? 1:0);
                oParams.Add("@CreatorUserID", SqlDbType.Int);
                oParams["@CreatorUserID"].Value = 0;
                oParams.Add("@ProtectedMode", Utils.GetInt(ddProtectedM.SelectedValue));
                oParams.Add("@IsHighlighted", Utils.GetInt(ddHighlightedM.SelectedValue));
                oParams.Add("@IsMassWatchingAllowed", Utils.GetInt(ddMassWatchingAllowed.SelectedValue));

                SqlParameter oParam = new SqlParameter("@GameProcessID", SqlDbType.Int);
                oParam.Direction = ParameterDirection.Output;
                oParams.Add(oParam);
                int Return = DBase.ExecuteReturnInt(oCmd);

                if (Return <= 0)
                {
                    if (Return < 0)
                    {
                        lblInfo.Text = "Such game process name already exists. Please try another one.";
                    }
                    else
                    {
                        lblInfo.Text = "Database error occured";
                    }
                    oCom.FillTable(xmlString, "gameengine/properties/property", true, ref table);
                    return;
                }

                int processID = Utils.GetInt(oParams["@GameProcessID"].Value);

                //3. Call InitGameProcess method of Com
                int pID = processID;
                if (!oEngine.InitGameProcess(nEngineID, (int)ApiMsg.enProcessFormTarget.Process, ref pID, xmlString, nActDispID))
                {
                    Log.Write(this, "Init game process error");
                    ShowError("Error occured. Game process wasn't created.");
                    oCom.FillTable(xmlString, "gameengine/properties/property", true, ref table);
                    return;
                }

                //4. Success message
                nGameProcessID         = processID;
                hdnGameProcessID.Value = nGameProcessID.ToString();
                lblInfo.Text           = "Game process was created";
                lblInfo.ForeColor      = Color.Green;
                oCom.FillTable(xmlString, "gameengine/properties/property", false, ref table);
                ShowControls();
            }
            finally
            { oEngine = null; }
        }
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            string tranName = "UpdateSubCategoryStats";

            DBase.BeginTransaction(tranName);

            //1. Save/update Subcategory details
            SqlCommand             oCmd    = DBase.GetCommand(Config.DbSaveSubCategoryDetails);
            SqlParameterCollection oParams = oCmd.Parameters;

            oParams.Add("@ID", nSubCategoryID);
            oParams.Add("@Name", txtName.Text);
            oParams.Add("@StatusID", Core.GetSelectedValueInt(comboStatus));
            oParams.Add("@CategoryID", Core.GetSelectedValueInt(comboCategory));

            int nRes = DBase.ExecuteReturnInt(oCmd);

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

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


            //2. update SubCategoryStats table
            DataTable oDT = DBase.GetDataTableBatch(string.Format(Config.DbUpdateSubCategoryStats, nRes));

            DataColumn[] PrimaryKeyArray = new DataColumn[2];
            PrimaryKeyArray[0] = oDT.Columns["SubCategoryID"];
            PrimaryKeyArray[1] = oDT.Columns["StatsTypeID"];
            oDT.PrimaryKey     = PrimaryKeyArray;

            try
            {
                //a. Delete rows that are not any more in the list
                string[] statsList = hdnStatsList.Value.Split(',');
                int      statsLen  = statsList.Length;
                if (hdnStatsList.Value == "")
                {
                    statsLen = 0;
                }
                int k = 0;
                while (k < oDT.Rows.Count)
                {
                    DataRow oRow  = oDT.Rows[k];
                    bool    bFind = false;
                    for (int i = 0; i < statsLen; i++)
                    {
                        if (oRow["StatsTypeID"].ToString() == statsList[i])
                        {
                            bFind = true;
                        }
                    }
                    if (!bFind)
                    {
                        oRow.Delete();
                    }
                    k++;
                }

                //b. Add/update order for the list
                for (int i = 0; i < statsLen; i++)
                {
                    DataRow oRow = oDT.Rows.Find(new object[] { nRes, statsList[i] });
                    if (oRow == null)
                    {
                        oDT.Rows.Add(new object[] { nSubCategoryID, statsList[i], i + 1 });
                    }
                    else
                    {
                        if (Convert.ToInt32(oRow["Order"]) != i + 1)
                        {
                            oRow["Order"] = i + 1;
                        }
                    }
                }
            }
            catch (Exception oEx)
            {
                Log.Write(this, "DataTable operations Error: " + oEx.Message);
                DBase.RollbackTransaction(tranName);
                lblInfo.Text      = "DataBase error occured during updating table";
                lblInfo.ForeColor = Color.Red;
                return;
            }

            bool bRes = DBase.Update(oDT);

            if (bRes)
            {
                DBase.CommitTransaction(tranName);
                hdnSubCategoryID.Value = nRes.ToString();
                StoreBackID(nRes);
                lblInfo.Text      = "Category details have been saved";
                lblInfo.ForeColor = Color.Green;

                Response.Redirect(GetGoBackUrl());

                nSubCategoryID = nRes;
                BindStatsList();
                rowRelatedProcesses.Visible = true;
                BindRelatedProcessList();
            }
            else
            {
                DBase.RollbackTransaction(tranName);
                lblInfo.Text      = "DataBase error occured during updating table";
                lblInfo.ForeColor = Color.Red;
            }
        }
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            //Invoke Com Api method to process outcomes
            ComProperty oCom    = new ComProperty();
            string      comData = string.Format("<objects xmlns='nsAction'><object name='pobuddywager.buddywager'><actions xmlns='nsAction'><sbmovetoticker newsid='{0}'/></actions></object></objects>", nNewsID);
            string      sResult = oCom.InvokeMember(Config.ComApi, Config.ComApiCreateRemind, 0, 0, DateTime.Now, comData, "", "");

            if (sResult == null)
            {
                lblInfo.ForeColor = Color.Red;
                lblInfo.Text      = "Com Error occured.";
                return;
            }

            int nRes     = 0;
            int nEventID = GetParamInt(Config.ParamEventID);

            if (nEventID <= 0)
            {
                nEventID = Utils.GetInt(hdnEventID.Value);
            }

            string strNewsDate = "";

            if (nEventID > 0)
            {
                SqlCommand             oCmd    = DBase.GetCommand(Config.DbSaveEventNewsDetails);
                SqlParameterCollection oParams = oCmd.Parameters;

                oParams.Add("@EventNewsID", nNewsID);
                oParams.Add("@EventID", nEventID);
                oParams.Add("@Subject", txtSubject.Text);
                oParams.Add("@Body", txtBody.Text);
                SqlParameter oParam = new SqlParameter("@NewsDate", System.Data.SqlDbType.DateTime);
                oParam.Direction = ParameterDirection.Output;
                oParams.Add(oParam);

                nRes        = DBase.ExecuteReturnInt(oCmd);
                strNewsDate = oParams["@NewsDate"].Value.ToString();
            }
            else
            {
                nRes = -10;
            }

            if (nRes > 0)
            {
                hdnNewsID.Value = nRes.ToString();
                StoreBackID(nRes);
                lblDate.Text = strNewsDate;

                lblInfo.ForeColor = Color.Green;
                lblInfo.Text      = "News details have been saved";

                Response.Redirect(GetGoBackUrl());
            }
            else
            {
                switch (nRes)
                {
                case -10:
                    lblInfo.Text = "Not specified event! (Parameter error)";
                    break;

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

                default:
                    lblInfo.Text = "Unknown error occured";
                    break;
                }
            }
        }
Пример #5
0
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            int nRes = 0;

            if (nEventID > 0)
            {
                SqlCommand             oCmd    = DBase.GetCommand(Config.DbSaveOutcomeDetails);
                SqlParameterCollection oParams = oCmd.Parameters;

                nTypeID = Core.GetSelectedValueInt(comboType);

                decimal BetValue = Utils.GetDecimal(txtValue.Text);
                decimal WonValue = Utils.GetDecimal(txtWonValue.Text);
                nResultID = waitingResultID;
                if (nTypeID == straightTypeID)
                {
                    nResultID = Core.GetSelectedValueInt(comboResult);
                }
                else if ((txtValue.Text != "") && (txtWonValue.Text != ""))
                {
                    nResultID = negativeResultID;
                    if ((nTypeID == handicapTypeID) && (WonValue > BetValue))
                    {
                        nResultID = positiveResultID;
                    }
                    if ((nTypeID == overTypeID) && (WonValue > BetValue))
                    {
                        nResultID = positiveResultID;
                    }
                    if ((nTypeID == underTypeID) && (WonValue < BetValue))
                    {
                        nResultID = positiveResultID;
                    }
                }

                int factor = 1;
                if (nTypeID == underTypeID)
                {
                    factor = -1;
                }
                if ((nTypeID == underTypeID) || (nTypeID == overTypeID))
                {
                    nTypeID = overUnderTypeID;
                }

                oParams.Add("@OutcomeID", nOutcomeID);
                oParams.Add("@Name", txtName.Text);
                oParams.Add("@EventID", nEventID);
                //oParams.Add("@Rate", Components.BetPriceConvert.Usa2Euro(txtRate.Text));
                oParams.Add("@Rate", txtRate.Text);
                oParams.Add("@Description", txtDescription.Text);
                oParams.Add("@ResultID", nResultID);
                oParams.Add("@BetTypeID", nTypeID);
                if (txtValue.Text == "")
                {
                    oParams.Add("@BetValue", System.DBNull.Value);
                }
                else
                {
                    oParams.Add("@BetValue", Convert.ToString(BetValue * factor));
                }
                if (txtWonValue.Text == "")
                {
                    oParams.Add("@WonValue", System.DBNull.Value);
                }
                else
                {
                    oParams.Add("@WonValue", Convert.ToString(WonValue * factor));
                }

                nRes = DBase.ExecuteReturnInt(oCmd);
            }
            else
            {
                nRes = -10;
            }

            if (nRes > 0)
            {
                hdnID.Value = nRes.ToString();
                StoreBackID(nRes);

                lblInfo.ForeColor = Color.Green;
                lblInfo.Text      = "Outcome details have been saved";

                Response.Redirect(GetGoBackUrl());
            }
            else
            {
                switch (nRes)
                {
                case -10:
                    lblInfo.Text = "Not specified event! (Parameter error)";
                    break;

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

                default:
                    lblInfo.Text = "Unknown error occured";
                    break;
                }
            }
        }