コード例 #1
0
        public void btnSave_click(object sender, System.EventArgs e)
        {
            bool bRes = false;

            //Start transaction - we need update all records or none
            DBase.BeginTransaction("admWebSaveLoyalityPoints");
            DataTable oDT = DBase.GetDataTableBatch(Config.DbUpdateLoyalityPoints);

            if (oDT != null)
            {
                DataView oDV = new DataView(oDT);
                int      nID = 0;
                foreach (string sKey in Request.Form.AllKeys)
                {
                    nID = GetID(sKey, "MinValueForPoint_");
                    if (nID > 0)
                    {
                        SetValue(oDV, nID, "MinValueForPoint", sKey);
                    }
                    nID = GetID(sKey, "PointsValue_");
                    if (nID > 0)
                    {
                        SetValue(oDV, nID, "PointsValue", sKey);
                    }
                    nID = GetID(sKey, "NameSQLProcedure_");
                    if (nID > 0)
                    {
                        SetValue(oDV, nID, "NameSQLProcedure", sKey);
                    }
                }

                bRes = DBase.Update(oDT);
            }

            if (bRes)
            {
                //Commit successful transaction
                DBase.CommitTransaction("admWebSaveLoyalityPoints");
                BindData();
                lblError.Text      = "Data has been saved";
                lblError.ForeColor = Color.Green;
            }
            else
            {
                //Rollback transaction in error ocurred
                DBase.RollbackTransaction("admWebSaveLoyalityPoints");
                lblError.Text      = "DataBase error occured";
                lblError.ForeColor = Color.Red;
            }
        }
コード例 #2
0
        protected void btnSave_click(object sender, System.EventArgs e)
        {
            bool bRes = false;

            //Start transaction - we need update all records or none
            DBase.BeginTransaction("admWebSaveOptions");
            DataTable oDT = DBase.GetDataTableBatch(Config.DbUpdateConfig);

            if (oDT != null)
            {
                DataView oDV = new DataView(oDT);
                foreach (string sKey in Request.Form.AllKeys)
                {
                    if (sKey.StartsWith("edtVal_"))
                    {
                        int nID = Utils.GetInt(sKey.Substring(7));
                        if (nID > 0)                           // Must be positive integer
                        {
                            oDV.RowFilter = string.Format("[id]={0}", nID);
                            if (oDV.Count == 1)
                            {                                   // Update exists row
                                oDV[0]["PropertyValue"] = Request[sKey];
                            }
                        }
                    }
                }

                bRes = DBase.Update(oDT);
            }

            if (bRes)
            {
                //Commit successful transaction
                DBase.CommitTransaction("admWebSaveOptions");
                BindGrid();
                lblError.Text      = "Data has been saved";
                lblError.ForeColor = Color.Green;

                Response.Redirect(GetGoBackUrl());
            }
            else
            {
                //Rollback transaction in error ocurred
                DBase.RollbackTransaction("admWebSaveOptions");
                lblError.Text      = "DataBase error occured";
                lblError.ForeColor = Color.Red;
            }
        }
コード例 #3
0
        protected void btnTransfer_click(object sender, System.EventArgs e)
        {
            int nTrgAccountID = 0;

            if (Utils.GetDecimal(hdnBalance.Value) < Utils.GetDecimal(txtAmountTr.Text))
            {
                return;
            }
            if (Utils.GetDecimal(txtAmountTr.Text) == 0)
            {
                return;
            }
            int UserID = DBase.ExecuteReturnInt(Config.DbGetUserID, new object[] { "@LoginName", txtUser.Text });

            if (UserID <= 0)
            {
                lblInfo.Text = "Invalid Login name";
                return;
            }
            DataRow oDR = GetFirstRow(Config.DbGetUserDetailsAccount, new object[] { "@UserID", UserID, "@CurrencyID", nCurrencyID });

            if (oDR != null)
            {
                nTrgAccountID = Utils.GetInt(oDR["AccountID"]);
            }
            else
            {
                return;
            }

            DBase.BeginTransaction("TransferAmmount");
            if (!SaveMoney(nAccountID, (0 - Utils.GetDecimal(txtAmountTr.Text)), txtReasonTr.Text))
            {
                DBase.RollbackTransaction();
                return;
            }
            if (!SaveMoney(nTrgAccountID, Utils.GetDecimal(txtAmountTr.Text), txtReasonTr.Text))
            {
                DBase.RollbackTransaction();
                return;
            }

            DBase.CommitTransaction();

            lblInfo.Text      = "User balance was changed";
            lblInfo.ForeColor = Color.Green;
            GetData();
        }
コード例 #4
0
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            string tranName = "SaveAffiliate";

            DBase.BeginTransaction(tranName);
            bool rez = false;

            lblInfo.Text      = "";
            lblInfo.ForeColor = Color.Red;

            try
            {
                if (chDeny.Checked)
                {
                    DBase.Execute(Config.DbDeleteAffiliate, new object[] { "@IDs", nAffiliateID.ToString() });
                    btnReturn_Click(null, null);
                    return;
                }

                //1. Save/Update affiliate in DB
                int nRes = DBase.ExecuteReturnInt(Config.DbSaveAffiliateDetails,
                                                  "@ID", nAffiliateID, "@Name", txtName.Text, "@EmailFrom", txtEmail.Text, "@StatusID", int.Parse(ddStatus.SelectedValue),
                                                  "@SkinsID", int.Parse(ddSkins.SelectedValue), "@Password", txtPassword.Text, "@BeneficiaryName", txtBeneficiaryName.Text, "@MailingAddress",
                                                  txtAddress.Text, "@City", txtCity.Text, "@StateID", int.Parse(ddState.SelectedValue), "@Zip", txtZip.Text,
                                                  "@CountryID", int.Parse(ddCountry.SelectedValue), "@FirstName", txtFirstName.Text,
                                                  "@LastName", txtLastName.Text, "@Title", txtTitle.Text, "@Phone", txtPhone.Text, "@Fax", txtFax.Text);
                if (nRes <= 0)
                {
                    switch (nRes)
                    {
                    case -1:
                        lblInfo.Text = "Such Affiliate name already exists";
                        break;

                    default:
                        lblInfo.Text = "Database error occured";
                        break;
                    }
                    DBase.RollbackTransaction(tranName);
                    return;
                }
                // Everything is Ok
                DBase.CommitTransaction(tranName);
                nAffiliateID         = nRes;
                hdnAffiliateID.Value = nRes.ToString();
                StoreBackID(nRes);
                lblInfo.Text      = "Affiliate has been saved";
                lblInfo.ForeColor = Color.Green;

                if (hdnState.Value != ddStatus.SelectedValue && ddStatus.SelectedValue == "4")
                {
                    string val = Config.GetDbConfigValue(DBase, 18);                   //Template name for affiliates
                    if (val == String.Empty)
                    {
                        rez = true;
                        return;
                    }
                    DataTable tb = DBase.GetDataTable(Config.DbGetEmailTemplateDetailsByName, "@Name", val);
                    if (tb == null)
                    {
                        rez = true;
                        return;
                    }
                    if (tb.Rows.Count <= 0)
                    {
                        rez = true;
                        return;
                    }
                    val = Config.GetDbConfigValue(DBase, 1);                  // Admin Email
                    if (val == String.Empty)
                    {
                        rez = true;
                        return;
                    }
                    CommonUse.CSentMail.Send(DBase, txtEmail.Text, val, tb.Rows[0]["subject"].ToString(),                    //Send message as autoresponder
                                             tb.Rows[0]["body"].ToString().Replace("<BR>", "\n").Replace("<br>", "\n").Replace("&nbsp;", " "), 3, MailFormat.Text);
                }
            }
            catch (Exception ex)
            {
                Common.Log.Write(this, ex);
                DBase.RollbackTransaction(tranName);
                lblInfo.Text      = "Error occured";
                lblInfo.ForeColor = Color.Red;
            }
            finally
            {
                if (rez)
                {
                    lblInfo.Text     += "  Error send Email";
                    lblInfo.ForeColor = Color.Red;
                }
                if (lblInfo.ForeColor != Color.Red)
                {
                    btnReturn_Click(null, null);
                }
            }
        }
コード例 #5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int     fileID            = -1;
            int     originalFileID    = -1;
            string  sKey              = "";
            string  sError            = "";
            string  sErrorVersion     = "";
            string  sErrorContentType = "";
            int     iVersion          = -1;
            bool    bRes              = false;
            string  tranName          = "";
            int     iContentType      = -1;
            int     executableCount   = 0;
            string  fileList          = "";
            DataRow oRow              = null;

            if (AffID <= 0)
            {
                return;
            }

            oPostedFile = new PostedFile(AffID);

            //1. Content type and version changes
            tranName = "updateClientApplication";
            DBase.BeginTransaction(tranName);
            DataTable oDT = DBase.GetDataTableBatch(String.Format(Config.ClientFilesBatchSQL, AffID));

            DataColumn[] PrimaryKeyArrayVersion = new DataColumn[1];
            PrimaryKeyArrayVersion[0] = oDT.Columns["ID"];
            oDT.PrimaryKey            = PrimaryKeyArrayVersion;
            for (int i = 0; i < Request.Form.AllKeys.Length; i++)
            {
                string    sFormKey = Request.Form.AllKeys[i];
                string [] tags     = sFormKey.TrimStart('_').Split('_');

                if (tags.Length < 2)
                {
                    continue;
                }

                //a. content Type
                if (tags[0] == chkComboName.TrimEnd('_'))
                {
                    fileID       = Convert.ToInt32(sFormKey.Substring(chkComboName.Length));
                    iContentType = Convert.ToInt32(Request[sFormKey]);
                    if ((fileID > 0) && (iContentType == ContentTypeExecutable))
                    {
                        executableCount++;
                    }
                    oRow = oDT.Rows.Find(fileID);
                    if ((oRow != null) && (oRow["contentTypeID"] != DBNull.Value) &&
                        (Convert.ToInt32(oRow["contentTypeID"]) != iContentType))
                    {
                        if (executableCount > 1)
                        {
                            sErrorContentType += "You can not have more than one executable file. Content type of file " + oRow["name"] + " remains the same.<br>";
                        }
                        else
                        {
                            oRow["contentTypeID"] = iContentType;
                        }
                    }
                }
                else if (tags[0] == edtName.TrimEnd('_'))                 //b. File Version
                {
                    fileID = Convert.ToInt32(tags[1]);
                    oRow   = oDT.Rows.Find(fileID);
                    if (oRow != null)
                    {
                        if (tags[2] == "version")
                        {
                            iVersion = Utils.GetInt(Request[sFormKey]);
                            if (oRow[tags[2]] != DBNull.Value)
                            {
                                if (Convert.ToInt32(oRow[tags[2]]) > iVersion)
                                {
                                    sErrorVersion += "Version you specified for file: " + oRow["name"] + " is not correct or lower than existing one. File version was not changed.<br>";
                                }
                                else if (Convert.ToInt32(oRow[tags[2]]) < iVersion)
                                {
                                    oRow[tags[2]] = iVersion;
                                }
                            }
                            else
                            {
                                oRow[tags[2]] = iVersion;
                            }
                        }
                        else
                        {
                            oRow[tags[2]] = Utils.GetInt(Request[sFormKey]);
                        }
                    }
                }
            }

            bRes = DBase.Update(oDT);
            if (bRes)
            {
                DBase.CommitTransaction(tranName);
            }
            else
            {
                DBase.RollbackTransaction(tranName);
                lblInfo.Text      = "DataBase error occured during updating table";
                lblInfo.ForeColor = Color.Red;
                return;
            }
            sError += sErrorContentType + sErrorVersion;


            //2. file upload
            for (int i = 0; i < Request.Files.Count; i++)
            {
                sKey   = Request.Files.AllKeys[i];
                fileID = -1;
                if ((sKey != null) && (sKey != ""))
                {
                    fileID = Convert.ToInt32(sKey);
                }
                originalFileID = fileID;
                iContentType   = -1;
                if (Request[chkComboName + sKey] != null)
                {
                    iContentType = Convert.ToInt32(Request[chkComboName + sKey]);
                }
                if ((iContentType == ContentTypeExecutable) && (originalFileID <= 0))
                {
                    executableCount++;
                }
                if ((executableCount > 1) && (originalFileID <= 0))
                {
                    sError += "You can not upload one more executable file. New file wasn't upload";
                }
                else
                {
                    HttpPostedFile postFile = Request.Files[i];
                    if ((postFile.FileName != "") && (postFile.FileName != null))
                    {
                        string sErrorUpload  = "";
                        string fileExtension = Path.GetExtension(postFile.FileName);
                        if (fileExtension == zipExtension)
                        {
                            sErrorUpload = oPostedFile.SaveZipFile(Page, postFile, iContentType, ref fileList);
                        }
                        else
                        {
                            sErrorUpload = oPostedFile.SaveFile(Page, postFile, iContentType, ref fileID);
                        }
                        if (sErrorUpload != "")
                        {
                            sError += sErrorUpload + "<br>";
                        }
                    }
                }
            }

            //File Upload result
            if (sError == "")
            {
                lblInfo.Text      = "File upload succeeded";
                lblInfo.ForeColor = Color.Green;
            }
            else
            {
                lblInfo.Text      = "There were errors during file upload. Some files could not be uploaded. See details below:<br>" + sError;
                lblInfo.ForeColor = Color.Red;
            }
            RunBat();
            BindDataGrid();
        }
コード例 #6
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());
        }
コード例 #7
0
        private bool SaveData(int stateID)
        {
            string tranName = "SaveEvent";

            DBase.BeginTransaction(tranName);
            //1. Save/Update Event
            object StartDate = Utils.GetDbDate(Request["comboDate"] + " " + Request["comboTime"] + ":00");
            int    nRes      = DBase.ExecuteReturnInt(Config.DbSaveEvent,
                                                      "@EventID", nEventID,
                                                      "@StateID", stateID,
                                                      "@StartSchedule", sGuid,
                                                      "@SubCategoryID", Request["comboSubCategory"],
                                                      "@AwayTeamID", Request["comboAway"],
                                                      "@HomeTeamID", Request["comboHome"],
                                                      "@StartDate", StartDate);

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

            //2. Update Outcomes
            decimal   Rate   = 0;
            decimal   Point  = 0;
            bool      isSave = false;
            string    sPoint = "";
            DataTable oDT    = DBase.GetDataTableBatch(string.Format(Config.DbUpdateOutcome, nRes));

            DataColumn[] PrimaryKeyArray = new DataColumn[4];
            PrimaryKeyArray[0] = oDT.Columns["EventID"];
            PrimaryKeyArray[1] = oDT.Columns["BetTypeID"];
            PrimaryKeyArray[2] = oDT.Columns["isHome"];
            PrimaryKeyArray[3] = oDT.Columns["PeriodID"];
            oDT.PrimaryKey     = PrimaryKeyArray;

            //Home Spread
            Rate   = Utils.GetDecimal(txtHomeSpread.Text);
            sPoint = Request["comboHomeSpread"];
            Point  = Utils.GetDecimal(sPoint);
            isSave = isNumber(sPoint);
            UpdateRow(oDT, nRes, typeSpread, againstHome, periodFull, Rate, Point, isSave);
            UpdateRow(oDT, nRes, typeSpread, againstAway, periodFull, -Rate, -Point, isSave);
            Rate   = Utils.GetDecimal(txtHomeSpreadHalf.Text);
            sPoint = Request["comboHomeSpreadHalf"];
            Point  = Utils.GetDecimal(sPoint);
            isSave = isNumber(sPoint);
            UpdateRow(oDT, nRes, typeSpread, againstHome, periodHalf, Rate, Point, isSave);
            UpdateRow(oDT, nRes, typeSpread, againstAway, periodHalf, -Rate, -Point, isSave);
            //Over Under
            Rate   = Utils.GetDecimal(txtTotalOU.Text);
            sPoint = Request["comboTotalOU"];
            Point  = Utils.GetDecimal(sPoint);
            isSave = isNumber(sPoint);
            UpdateRow(oDT, nRes, typeOu, againstHome, periodFull, Rate, Point, isSave);
            UpdateRow(oDT, nRes, typeOu, againstAway, periodFull, -Rate, -Point, isSave);
            Rate   = Utils.GetDecimal(txtTotalOUHalf.Text);
            sPoint = Request["comboTotalOUHalf"];
            Point  = Utils.GetDecimal(sPoint);
            isSave = isNumber(sPoint);
            UpdateRow(oDT, nRes, typeOu, againstHome, periodHalf, Rate, Point, isSave);
            UpdateRow(oDT, nRes, typeOu, againstAway, periodHalf, -Rate, -Point, isSave);
            //ML
            Rate   = Utils.GetDecimal(txtHomeTeam.Text);
            sPoint = Request["comboHomeTeam"];
            Point  = Utils.GetDecimal(sPoint);
            isSave = isNumber(sPoint);
            UpdateRow(oDT, nRes, typeML, againstHome, periodFull, Rate, Point, isSave);
            UpdateRow(oDT, nRes, typeML, againstAway, periodFull, -Rate, -Point, isSave);

            bool bRes = DBase.Update(oDT);

            if (!bRes)
            {
                ShowError("DataBase error occured during saving Outcomes");
                DBase.RollbackTransaction(tranName);
                return(false);
            }


            // Everything is Ok
            DBase.CommitTransaction(tranName);
            nEventID = nRes;
            StoreBackID(nRes);
            hdnEventID.Value = nRes.ToString();
            return(true);
        }
コード例 #8
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();
        }
コード例 #9
0
        /*	public string GetBannerURL()
         *      {
         *              return Config.GetConfigValue("SkinsBannerURL")+"/Skin_"+ nSkinID.ToString()+"/Banner/"+Config.GetConfigValue("ImageBannerName");
         *      }*/

        private void btnSignUp_Click(object sender, System.EventArgs e)
        {
            int nSkinID = 0;

            nSkinID = Common.Utils.GetInt(ddSkins.SelectedValue);
            if (nSkinID <= 0)
            {
                return;
            }

            if (!chAgree.Checked)
            {
                lblInfo.Text = "You must agree to the Affiliate Agreement";
                return;
            }

            if (txtPassword.Text != txtPasswordRet.Text)
            {
                lblInfo.Text = "Re-Typed password not equal to Password";
                return;
            }

            string tranName = "SaveAffiliate";

            try
            {
                DBase.BeginTransaction(tranName);

                //1. Save/Update affiliate in DB
                int nRes = DBase.ExecuteReturnInt(Config.DbSaveAffiliateDetails,
                                                  "@ID", -1, "@Name", txtName.Text, "@EmailFrom", txtEmail.Text, "@StatusID", 5, "@SkinsID", nSkinID
                                                  , "@Password", txtPassword.Text, "@BeneficiaryName", txtBeneficiaryName.Text, "@MailingAddress",
                                                  txtAddress.Text, "@City", txtCity.Text, "@StateID", int.Parse(ddState.SelectedValue), "@Zip", txtZip.Text,
                                                  "@CountryID", int.Parse(ddCountry.SelectedValue), "@FirstName", txtFirstName.Text,
                                                  "@LastName", txtLastName.Text, "@Title", txtTitle.Text, "@Phone", txtPhone.Text, "@Fax", txtFax.Text);
                if (nRes <= 0)
                {
                    switch (nRes)
                    {
                    case -1:
                        lblInfo.Text = "Such Affiliate Login already exists";
                        break;

                    default:
                        lblInfo.Text = "Database error occured";
                        break;
                    }
                    DBase.RollbackTransaction(tranName);
                    return;
                }
                // Everything is Ok
                DBase.CommitTransaction(tranName);
                lblInfo.Text      = "Affiliate has been saved";
                lblInfo.ForeColor = Color.Green;
                Response.Redirect("Signupcomplete.aspx?SkinsID=" + nSkinID.ToString());
            }
            catch (Exception ex)
            {
                Log.Write(this, ex);
                DBase.RollbackTransaction(tranName);
                lblInfo.Text = "Error occured during save data";
            }
        }
コード例 #10
0
        /// <summary>
        /// Save event handler.
        /// </summary>
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            //1. Get XML
            sXML = hdnXML.Value;
            oPrize.FillTable(ref sXML, ref table, true, false);              //fill table from xml

            //2. Save category in DB
            string tranNameTotal = "admSaveSBCategoryDetails";

            DBase.BeginTransaction(tranNameTotal);
            int nRes = DBase.ExecuteReturnInt(Config.DbSaveSBCategoryDetails, new object[] { "@id", nCategoryID, "@Name", txtName.Text });

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

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

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


            //3. Batch upload of Teaser Table
            try
            {
                DataTable    xmlDT           = oPrize.getDataTable(sXML);    //DataTable from xml
                DataColumn[] PrimaryKeyArray = new DataColumn[3];
                PrimaryKeyArray[0] = xmlDT.Columns[PrizeTable.tblColName];
                PrimaryKeyArray[1] = xmlDT.Columns[PrizeTable.tblRowName];
                PrimaryKeyArray[2] = xmlDT.Columns[PrizeTable.tblValueName];
                xmlDT.PrimaryKey   = PrimaryKeyArray;
                //using primary key we can update only recods that were changed
                DataTable oDT = DBase.GetDataTableBatch("select id, Points, BetCount, Rate, CategoryID from Teaser where categoryID = " + nRes.ToString() + " order by Points, BetCount");                  //dataTable from SQL
                //clear all old data
                foreach (DataRow oDR in oDT.Rows)
                {
                    DataRow oRow = xmlDT.Rows.Find(new object[3] {
                        oDR["Points"].ToString(), oDR["BetCount"].ToString(), oDR["Rate"].ToString()
                    });
                    if (oRow != null)
                    {
                        oRow.Delete();
                    }
                    else
                    {
                        oDR.Delete();
                    }
                }
                //do we have any records to add
                bool hasRecords = true;
                if (xmlDT.Rows.Count < 1)
                {
                    hasRecords = false;
                }
                if ((xmlDT.Rows.Count == 1) && (xmlDT.Rows[0][PrizeTable.tblValueName].ToString() == ""))
                {
                    hasRecords = false;                                                                                                    //one record, but value is empty
                }
                if (hasRecords)
                {
                    //add new data
                    foreach (DataRow oDR in xmlDT.Rows)
                    {
                        DataRow row = oDT.NewRow();
                        row["Points"]     = oDR[PrizeTable.tblColName];
                        row["BetCount"]   = oDR[PrizeTable.tblRowName];
                        row["Rate"]       = Utils.GetDecimal(oDR[PrizeTable.tblValueName]);
                        row["CategoryID"] = nRes;
                        oDT.Rows.Add(row);
                    }
                }
                bool bRes = DBase.Update(oDT);
                if (!bRes)
                {
                    DBase.RollbackTransaction(tranNameTotal);
                    ShowError("DB error occured during Teaser data update.");
                    return;
                }
            }
            catch (Exception oEx)
            {
                DBase.RollbackTransaction(tranNameTotal);
                ShowError("DB error occured during Teaser data update block.");
                Log.Write(this, oEx);
                return;
            }
            //End of Batch upload of Teaser Table

            //4. Sucess message
            DBase.CommitTransaction(tranNameTotal);
            nCategoryID = nRes;
            StoreBackID(nRes);
            hdnID.Value       = nRes.ToString();
            lblInfo.ForeColor = Color.Green;
            lblInfo.Text      = "Category details have been saved";

            Response.Redirect(GetGoBackUrl());
        }
コード例 #11
0
        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;
            }
        }
コード例 #12
0
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            string tranName = "SaveAffiliate";

            DBase.BeginTransaction(tranName);
            bool rez = false;

            lblInfo.Text      = "";
            lblInfo.ForeColor = Color.Red;

            try
            {
                if (chDeny.Checked)
                {
                    DBase.Execute(Config.DbDeleteSkin, new object[] { "@IDs", nAffiliateID.ToString() });
                    btnReturn_Click(null, null);
                    return;
                }

                //1. Save/Update affiliate in DB
                int nRes = DBase.ExecuteReturnInt(Config.DbSaveSkinsDetails,
                                                  "@ID", nAffiliateID, "@Name", txtName.Text, "@EmailFrom", txtEmail.Text, "@StatusID", int.Parse(ddStatus.SelectedValue),
                                                  "@SkinsDomain", txtDomain.Text, "@EmailSupport", txtSuppEmail.Text);
                if (nRes <= 0)
                {
                    switch (nRes)
                    {
                    case -1:
                        lblInfo.Text = "Such Skins name already exists";
                        break;

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

                /*
                 *                      //2. Create installation files
                 *                      Admin.CommonUse.Affiliate oAffiliate = new Admin.CommonUse.Affiliate(Page);
                 *                      bool bRes = oAffiliate.CreateAffiliate(nRes);
                 *                      if (!bRes)
                 *                      {
                 *                              lblInfo.Text = "Affiliate install shield error occured";
                 *                              DBase.RollbackTransaction(tranName);
                 *                              return;
                 *                      }
                 */
                // Everything is Ok
                DBase.CommitTransaction(tranName);
                nAffiliateID         = nRes;
                hdnAffiliateID.Value = nRes.ToString();
                StoreBackID(nRes);
                lblInfo.Text      = "Skin has been saved";
                lblInfo.ForeColor = Color.Green;

                if (hdnState.Value != ddStatus.SelectedValue && ddStatus.SelectedValue == "4")
                {
                    string val = Config.GetDbConfigValue(DBase, 18);                   //Template name for affiliates
                    if (val == String.Empty)
                    {
                        rez = true;
                        return;
                    }
                    DataTable tb = DBase.GetDataTable(Config.DbGetEmailTemplateDetailsByName, "@Name", val);
                    if (tb == null)
                    {
                        rez = true;
                        return;
                    }
                    if (tb.Rows.Count <= 0)
                    {
                        rez = true;
                        return;
                    }
                    val = Config.GetDbConfigValue(DBase, 1);                  // Admin Email
                    if (val == String.Empty)
                    {
                        rez = true;
                        return;
                    }
                    CommonUse.CSentMail.Send(DBase, txtEmail.Text, val, tb.Rows[0]["subject"].ToString(),                    //Send message as autoresponder
                                             tb.Rows[0]["body"].ToString().Replace("<BR>", "\n").Replace("<br>", "\n").Replace("&nbsp;", " "), 3, MailFormat.Text);
                }
            }
            catch (Exception ex)
            {
                Common.Log.Write(this, ex);
                DBase.RollbackTransaction(tranName);
                lblInfo.Text      = "Error occured";
                lblInfo.ForeColor = Color.Red;
            }
            finally
            {
                if (rez)
                {
                    lblInfo.Text     += "  Error send Email";
                    lblInfo.ForeColor = Color.Red;
                }
                if (lblInfo.ForeColor != Color.Red)
                {
                    btnReturn_Click(null, null);
                }
            }
        }