private void btnAdvFind_Click(object sender, EventArgs e)
        {
            clsIR irToSearch = new clsIR(0, 0, "", "", "", "", "", "", "", "", "", "");

            long lngFindIR = 0;

            using (frmFindIR objFindIR = new frmFindIR(irToSearch, "Find record", false))
            {
                if (objFindIR.ShowDialog() == DialogResult.OK)
                {
                    lngFindIR = objFindIR.irToSearch.lngRecordID;

                    if (lngFindIR > 0)
                        subLoadRecord(lngFindIR);
                }
                else
                    return;
            }
        }
Beispiel #2
0
        private void btnAddMember_Click(object sender, EventArgs e)
        {
            long lngIRID = 0;

            clsIR irMember = new clsIR(0, ((clsCboItem)cboMORState.SelectedItem).ID, "", "", "", txtMORAddress.Text, txtMORCity.Text, txtMORZip.Text, txtMORPhone.Text, "", "", "");

            using (frmFindIR objFindIR = new frmFindIR(irMember))
            {
                if (objFindIR.ShowDialog() == DialogResult.OK)
                {
                    if (objFindIR.irToSearch.lngRecordID == 0)
                        return;
                    else
                        lngIRID = objFindIR.irToSearch.lngRecordID;

                    subAddIRToMemberList(lngIRID);

                    subLoadPrimaryContact();
                }
                else
                    return;
            }
        }
Beispiel #3
0
        private void btnAddFather_Click(object sender, EventArgs e)
        {
            long lngFatherID = 0;

            clsIR irFather = new clsIR(0, ((clsCboItem)cboMORState.SelectedItem).ID, txtFatherFName.Text, txtFatherLName.Text, "", txtMORAddress.Text, txtMORCity.Text, txtMORZip.Text, txtFatherCellPhone.Text, "", txtFatherCellPhone.Text, txtFatherEmail.Text);
            irFather.blnGender = true;

            using (frmFindIR objFindIR = new frmFindIR(irFather, "Find camper's father"))
            {
                if (objFindIR.ShowDialog() == DialogResult.OK)
                {
                    if (objFindIR.irToSearch.lngRecordID == 0)
                        return;
                    else
                        lngFatherID = objFindIR.irToSearch.lngRecordID;

                    subAddIRToMemberList(lngFatherID);

                    subLoadPrimaryContact();
                }
                else
                    return;
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you wish to remove this registration without processing it?", "Continue?", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                //prompt for refund
                if (MessageBox.Show("Would you like to issue a refund for the deposit?", "Refund", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    decimal decRefundAmt = 0;

                    using (frmCollectRefundAmt objCollectRefundAmt = new frmCollectRefundAmt(lngGGCCRegWebID))
                    {
                        if (objCollectRefundAmt.ShowDialog() == DialogResult.OK)
                        {
                            decRefundAmt = objCollectRefundAmt.decAmt;

                            if (decRefundAmt > 0)
                            {
                                if (clsAppSettings.GetAppSettings().lngLiveCharge == clsGlobalEnum.conLIVECHARGE.XCharge)
                                {
                                    if (cboPmtType.SelectedItem.ToString() == "EFT")
                                        clsLiveCharge.subProcessRefundXCEFT(decRefundAmt, lngGGCCRegWebID, txtAcctNum.Text, txtRoutingNum.Text, txtFName.Text + " " + txtLName.Text, txtAddress.Text, txtZip.Text, (int)this.Handle, clsLiveCharge.fcnGetXChargePath());
                                    else
                                        clsLiveCharge.subProcessRefundXCCC(decRefundAmt, txtXCTransID.Text, txtXCAlias.Text);
                                }
                                else if (clsAppSettings.GetAppSettings().lngLiveCharge == clsGlobalEnum.conLIVECHARGE.CashLinq)
                                {
                                    if (cboPmtType.SelectedItem.ToString() == "EFT")
                                        clsLiveCharge.subProcessRefundCashLinqEFT(decRefundAmt, lngGGCCRegWebID, txtAcctNum.Text, txtRoutingNum.Text, txtFName.Text + " " + txtLName.Text, txtAddress.Text, txtZip.Text, (int)this.Handle);
                                    else
                                        clsLiveCharge.subProcessRefundCashLinqCC(decRefundAmt, txtPNRef.Text);
                                }
                                else if (clsAppSettings.GetAppSettings().lngLiveCharge == clsGlobalEnum.conLIVECHARGE.EPS)
                                {
                                    if (cboPmtType.SelectedItem.ToString() == "EFT")
                                        clsLiveCharge.subProcessRefundEPSEFT(decRefundAmt);
                                    else
                                        clsLiveCharge.subProcessRefundEPSCC(decRefundAmt, lngGGCCRegWebID, txtEPSTransID.Text);
                                }

                            }
                            else
                                return;
                        }
                        else
                            return;
                    }

                    string strMsg = "Would you like to record the deposit and refund in CampTrak?";

                    if (MessageBox.Show(strMsg, "Save in CampTrak?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        clsIR irToSearch = new clsIR(0, ((clsCboItem)cboState.SelectedItem).ID, txtFName.Text, txtLName.Text, "", txtAddress.Text, txtCity.Text, txtZip.Text, txtHomePhone.Text, "", txtCellPhone.Text, txtEMail.Text);

                        irToSearch.lngRecordWebID = lngRecordWebID;
                        irToSearch.lngRecordID = lngRecordID;

                        //find record
                        using (frmFindIR objFindIR = new frmFindIR(irToSearch, "Find registrant's record"))
                        {
                            if (objFindIR.ShowDialog() == DialogResult.OK)
                            {
                                if (objFindIR.irToSearch.lngRecordID == 0)
                                    return;
                                else
                                    lngRecordID = objFindIR.irToSearch.lngRecordID;
                            }
                        }

                        //add transactions
                        //////////////////////////////////////////////////////////////////////////
                        decimal decPmtAmt = 0;

                        try { decPmtAmt = decimal.Parse(txtPmtAmt.Text, System.Globalization.NumberStyles.Currency); }
                        catch { decPmtAmt = 0; }

                        using (OleDbConnection conDB = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn))
                        {
                            conDB.Open();

                            string strSQL = "";

                            //add payment
                            strSQL = "INSERT INTO tblTransactions " +
                                    "(blnMarkedForCC, " +
                                        "lngPaymentTypeID, lngTransTypeID, lngRecordID, lngBillStateID, lngUserID, " +
                                        "curPayment, " +
                                        "dteDateAdded, " +
                                        "strTransactionDesc, strCCNumber, strCCExpDate, strCCValCode, strBillName, strBillAddress, strBillCity, strBillZip, strBillPhone, strBankName, strAcctNum, strRoutingNum, strPNRef, strEPSTransID, strEPSApprovalNumber, strEPSValidationCode, strEPSPmtAcctID ) " +
                                    "SELECT 1, " +
                                        "@lngPaymentTypeID, 8 AS lngTransTypeID, @lngRecordID, @lngBillStateID, @lngUserID, " +
                                        "@curPayment, " +
                                        "@dteDateAdded, " +
                                        "@strTransactionDesc, @strCCNumber, @strCCExpDate, @strCCValCode, @strBillName, @strBillAddress, @strBillCity, @strBillZip, @strBillPhone, @strBankName, @strAcctNum, @strRoutingNum, @strPNRef, @strEPSTransID, @strEPSApprovalNumber, @strEPSValidationCode, @strEPSPmtAcctID ";

                            using (OleDbCommand cmdDB = new OleDbCommand(strSQL, conDB))
                            {
                                long lngPmtType = 0;

                                //if (txtBankName.Text != "")
                                //    lngPmtType = 11;
                                //else
                                lngPmtType = 2;

                                long lngBillStateID = 0;

                                try { lngBillStateID = ((clsCboItem)cboState.SelectedItem).ID; }
                                catch { lngBillStateID = 0; }

                                cmdDB.Parameters.Add(new OleDbParameter("@lngPaymentTypeID", lngPmtType));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngRecordID));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngBillStateID", lngBillStateID));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngUserID", CTWebMgmt.lngUserID));
                                cmdDB.Parameters.Add(new OleDbParameter("@curPayment", decPmtAmt));

                                cmdDB.Parameters.Add(new OleDbParameter("@dteDateAdded", OleDbType.Date));
                                cmdDB.Parameters["@dteDateAdded"].Value = DateTime.Now;

                                cmdDB.Parameters.Add(new OleDbParameter("@strTransactionDesc", "Web Reg Tuition"));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCNumber", txtCardNum.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCExpDate", txtCCExp.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCValCode", txtCVV2.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillName", txtFName.Text + " " + txtLName.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillAddress", txtAddress.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillCity", txtCity.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillZip", txtZip.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillPhone", txtHomePhone.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBankName", txtBankName.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strAcctNum", txtAcctNum.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strRoutingNum", txtRoutingNum.Text));

                                cmdDB.Parameters.Add(new OleDbParameter("@strPNRef", txtPNRef.Text));

                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSTransID", txtEPSTransID.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSApprovalNumber", txtEPSApprovalNumber.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSValidationCode", txtEPSValidationCode.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSPmtAcctID", txtEPSPmtAcctID.Text));

                                try { cmdDB.ExecuteNonQuery(); }
                                catch { }

                                //add refund record
                                strSQL = "INSERT INTO tblTransactions " +
                                        "(blnMarkedForCC, " +
                                            "lngTransTypeID, lngTransSubTypeID, lngBillStateID, lngRecordID, lngUserID, " +
                                            "curCharge, " +
                                            "dteDateAdded, " +
                                            "strBillName, strBillAddress, strBillCity, strBillZip, strBillPhone, strCCNumber, strCCExpDate, strTransactionDesc) " +
                                        "VALUES " +
                                        "(1, " +
                                            "4, 0, @lngBillStateID, @lngRecordID, @lngUserID, " +
                                            "@curCharge, " +
                                            "Now(), " +
                                            "@strBillName, @strBillAddress, @strBillCity, @strBillZip, @strBillPhone, @strCCNumber, @strCCExpDate, \"Refund for online registration\")";

                                cmdDB.CommandText = strSQL;
                                cmdDB.Parameters.Clear();

                                cmdDB.Parameters.Add(new OleDbParameter("@lngBillStateID", lngBillStateID));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngRecordID));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngUserID", CTWebMgmt.lngCTUserID));
                                cmdDB.Parameters.Add(new OleDbParameter("@curCharge", decRefundAmt));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillName", txtFName.Text + " " + txtLName.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillAddress", txtAddress.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillCity", txtCity.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillZip", txtZip.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillPhone", txtHomePhone.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCNumber", txtCardNum.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCExpDate", txtCCExp.Text));

                                try { cmdDB.ExecuteNonQuery(); }
                                catch { }

                            }//</command>

                            conDB.Close();
                        }//</connection>
                    }//</save in ct>
                }

                clsGGCCCRUD.subDeleteProcessedReg(lngGGCCRegWebID);
                clsNav.subCloseGGCCRegDetails();
                clsNav.subCloseProcessGGCCReg();
            }
        }
        private void txtFindByName_KeyPress(object sender, KeyPressEventArgs e)
        {
            bool blnEnter = false;

            try { blnEnter = (e.KeyChar == '\r'); }
            catch { blnEnter = false; }

            if (blnEnter)
            {
                clsIR irToSearch = new clsIR(0, 0, "", "", "", "", "", "", "", "", "", "");

                long lngFindIR = 0;

                using (frmFindIR objFindIR = new frmFindIR(irToSearch, "Find record", true, txtFindByName.Text))
                {
                    if (objFindIR.ShowDialog() == DialogResult.OK)
                    {
                        lngFindIR = objFindIR.irToSearch.lngRecordID;

                        if (lngFindIR > 0)
                            subLoadRecord(lngFindIR);
                    }
                    else
                        return;
                }

                txtFindByName.Text = "";
            }
        }
        private void btnRegister_Click(object sender, EventArgs e)
        {
            string strSQL = "";

            decimal decPmtAmt = 0;
            decimal decSpending = 0;

            long lngRegistrationID = 0;
            long lngPmtType = 0;

            int intTotChoices = 0;
            int[] intWaitList = new int[11];

            //'first check availability
            //'try to match camper to an existing record
            //'if a possible match is found, display a form to pick exact record
            //'if no match is found, try to find a mor that the record might fit into.  add record and assign to mor
            //'if no mor is found, add record
            //'return id, register camper
            DateTime dteRegDate;

            try { dteRegDate = Convert.ToDateTime(txtRegDate.Text); }
            catch (Exception ex)
            {
                MessageBox.Show("There was a problem with the registration date: " + ex.Message + "\nThe current date will be used.");
                dteRegDate = DateTime.Now;
            }

            DateTime dteCamperBDate;

            try { dteCamperBDate = Convert.ToDateTime(txtCamperBDate.Text); }
            catch (Exception ex)
            {
                MessageBox.Show("There was a problem with the birth date: " + ex.Message + "\nThe current date will be used.");
                dteCamperBDate = DateTime.Now;
            }

            for (int intI = 1; intI <= 11; intI++)
            {
                if (((CheckBox)pagRegInfo.Controls["chkReg" + intI.ToString()]).Checked)
                    intTotChoices++;
                else if (((CheckBox)pagRegInfo.Controls["chkWait" + intI.ToString()]).Checked)
                    intTotChoices++;
            }

            if (intTotChoices == 0)
            {
                MessageBox.Show("Please select a block to register or wait list this camper for.");
                pagRegInfo.Focus();
                return;
            }

            try { decSpending = decimal.Parse(txtSpending.Text, System.Globalization.NumberStyles.Currency); }
            catch { decSpending = 0; }

            try { decPmtAmt = decimal.Parse(txtPmtAmt.Text, System.Globalization.NumberStyles.Currency); }
            catch { decPmtAmt = 0; }

            //availability check--un-mark any full blocks, mark wait list
            for (int intI = 1; intI <= 11; intI++)
            {
                if (((CheckBox)pagRegInfo.Controls["chkReg" + intI]).Checked)
                {
                    if (((Label)pagRegInfo.Controls["lblFull" + intI]).Visible)
                    {
                        if (MessageBox.Show("This block (" + ((clsCboItem)((ComboBox)pagRegInfo.Controls["cboBlockChoice" + intI]).SelectedItem).Item + ") is full.\n\nWould you like to continue with this registration\nand thus overbook the block?\n\n(Selecting 'No' will place this camper on the waiting list.)", "Block Full", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            ((CheckBox)pagRegInfo.Controls["chkReg" + intI.ToString()]).Checked = false;
                            ((CheckBox)pagRegInfo.Controls["chkWait" + intI.ToString()]).Checked = true;
                        }
                    }
                }
            }

            if (intTotChoices == 0)
            {
                decSpending = 0;
                decPmtAmt = 0;
            }
            else
            {
                decSpending = decSpending / intTotChoices;
                decPmtAmt = decPmtAmt / intTotChoices;
            }

            // 'populate waiting list array
            for (int intI = 0; intI <= 10; intI++)
            {
                if (((CheckBox)pagRegInfo.Controls["chkWait" + (intI + 1)]).Checked) { intWaitList[intI] = Convert.ToInt32(((clsCboItem)((ComboBox)pagRegInfo.Controls["cboBlockChoice" + (intI + 1)]).SelectedItem).ID); }
                else
                    intWaitList[intI] = 0;
            }

            long lngParentIRID = 0;
            bool blnParentRequired = false;

            if (fraApplyDonationTo.Visible && radDonationToParent.Checked) blnParentRequired = true;

            try { lngParentIRID = fcnProcessProfileRecord(blnParentRequired); }
            catch (Exception ex) { lngParentIRID = 0; }

            if (blnParentRequired && lngParentIRID <= 0)
            {
                MessageBox.Show("You've chosen to assign the donation to the parent, so a parent record must be selected or created to continue.");
                txtDonation.Focus();
                return;
            }

            //'get record to add reg/wait list for
            //'if there are no eligible matches, go directly to add new.
            //'show list of possible matches
            long lngStateID = 0;

            try { lngStateID = ((clsCboItem)cboCamperState.SelectedItem).ID; }
            catch { lngStateID = 0; }

            clsIR irToSearch = new clsIR(0, lngStateID, txtCamperFName.Text, txtCamperLName.Text, "", txtCamperAddress.Text, txtCamperCity.Text, txtCamperZip.Text, txtCamperPhone.Text, "", txtCamperCellPhone.Text, txtCamperEMail.Text);

            //fill in ir details to pass to search screen
            irToSearch.blnGender = radM.Checked;

            irToSearch.blnCamper = true;
            irToSearch.blnParent = false;

            try { irToSearch.intGrade = Convert.ToInt32(txtCamperGrade.Text); }
            catch { irToSearch.intGrade = 0; }

            irToSearch.lngRecordWebID = lngRecordWebID;
            irToSearch.lngRecordID = lngRecordID;

            try { irToSearch.lngStateID = ((clsCboItem)cboCamperState.SelectedItem).ID; }
            catch { irToSearch.lngStateID = 0; }

            try { irToSearch.lngBillStateID = ((clsCboItem)cboBillState.SelectedItem).ID; }
            catch { irToSearch.lngBillStateID = 0; }

            irToSearch.dteBDate = dteCamperBDate;

            irToSearch.strMI = txtCamperMI.Text;
            irToSearch.strEmail = txtCamperEMail.Text;
            irToSearch.strConfEmail = txtProfileEmail.Text;
            irToSearch.strHomePhone = txtCamperPhone.Text;
            irToSearch.strZip = txtCamperZip.Text;
            irToSearch.strCity = txtCamperCity.Text;
            irToSearch.strAddress = txtCamperAddress.Text;
            irToSearch.strLName = txtCamperLName.Text;
            irToSearch.strFName = txtCamperFName.Text;
            irToSearch.strPmtType = txtPmtType.Text;
            irToSearch.strSpecialNeeds = "";
            irToSearch.strNotes = txtNotes.Text;
            irToSearch.strBankName = txtBankName.Text;
            irToSearch.strFather = txtFather.Text;
            irToSearch.strMother = txtMother.Text;
            irToSearch.strBillName = txtBillName.Text;
            irToSearch.strBillAddress = txtBillAddress.Text;
            irToSearch.strBillCity = txtBillCity.Text;
            irToSearch.strBillZip = txtBillZip.Text;
            irToSearch.strBillPhone = txtBillPhone.Text;

            //add custom vals to ir to search for
            for (int intI = 0; intI <pagCustomIR.Controls.Count; intI++)
            {
                if (pagCustomIR.Controls[intI].HasChildren)
                {
                    if (pagCustomIR.Controls[intI].Name.StartsWith("panCustomIR_"))
                    {
                        long lngCustomFieldDefIRID = 0;
                        string strID = pagCustomIR.Controls[intI].Name;

                        lngCustomFieldDefIRID = Convert.ToInt32(strID.Substring(strID.IndexOf("_") + 1, strID.Length - (strID.IndexOf("_") + 1)));

                        Panel panCustom = (Panel)pagCustomIR.Controls[intI];

                        string strLocalCaption = "";
                        string strValue = "";

                        //assume textbox or cbo for caption
                        try { strLocalCaption = ((Label)panCustom.Controls["lblCustFieldIR_" + lngCustomFieldDefIRID.ToString()]).Text; }
                        catch { strLocalCaption = ""; }

                        //either a flag or err
                        if (strLocalCaption == "")
                        {
                            try { strLocalCaption = ((CheckBox)panCustom.Controls["chkCustIR_" + lngCustomFieldDefIRID.ToString()]).Text; }
                            catch { strLocalCaption = ""; }
                        }

                        if (strLocalCaption != "")
                        {
                            try { strValue = ((TextBox)panCustom.Controls["txtCustFieldIR_" + lngCustomFieldDefIRID.ToString()]).Text; }
                            catch { strValue = ""; }

                            if (strValue == "")
                            {
                                try { strValue = ((CheckBox)panCustom.Controls["chkCustIR_" + lngCustomFieldDefIRID.ToString()]).Checked.ToString(); }
                                catch { strValue = ""; }
                            }

                            if (strValue == "")
                            {
                                try { strValue = ((ComboBox)panCustom.Controls["cboCustFieldIR_" + lngCustomFieldDefIRID.ToString()]).SelectedItem.ToString(); }
                                catch { strValue = ""; }
                            }
                        }

                        string[] strCustom = new string[2];

                        strCustom[0] = strLocalCaption;
                        strCustom[1] = strValue;

                        irToSearch.strCustom.Add(strCustom);
                    }
                }
            }

            using (frmFindIR objFindIR = new frmFindIR(irToSearch, "Find camper record"))
            {
                if (objFindIR.ShowDialog() == DialogResult.OK)
                {
                    if (objFindIR.irToSearch.lngRecordID == 0)
                        return;
                    else
                    {
                        lngRecordID = objFindIR.irToSearch.lngRecordID;
                        clsIRCRUD.subSetToSync(lngRecordID);

                        if (!objFindIR.blnAddNew)
                        {
                            using (IRUtils.frmReconcileIR objReconcileIR = new global::CTWebMgmt.IRUtils.frmReconcileIR("tblWebRecords", lngRecordID, lngRecordWebID))
                            {
                                if (objReconcileIR.ShowDialog() == DialogResult.Cancel)
                                    return;
                                else
                                    lngRecordID = objReconcileIR.lngDBID;
                            }
                        }
                    }
                }
                else
                    return;
            }

            using (OleDbConnection conDB = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn))
            {
                //'put web camper id in tblRecords
                strSQL = "UPDATE tblRecords " +
                        "SET blnCamper=True, " +
                            "lngWebCamperID=" + lngRecordWebID.ToString() + ", lngRecordWebID=" + lngRecordWebID.ToString() + " " +
                        "WHERE lngRecordID=" + lngRecordID.ToString();

                conDB.Open();

                using (OleDbCommand cmdDB = new OleDbCommand(strSQL, conDB))
                {
                    cmdDB.ExecuteNonQuery();

                    //update local id on server
                    using (wsXferEventInfoV2.xfereventinfov2 svc = new global::CTWebMgmt.wsXferEventInfoV2.xfereventinfov2())
                    {
                        string strWebRes = "";

                        strWebRes = svc.fcnUpdateLocalID(lngRecordWebID, lngRecordID, clsAppSettings.GetAppSettings().lngCTUserID, clsAppSettings.GetAppSettings().strWebDBConn);

                        if (strWebRes != "") MessageBox.Show("There was an error updating the camper's web id: " + strWebRes);
                    }

                    subManageSpecNeeds(cmdDB, lngRegWebID, lngRecordID);

                    //at this point, user has either selected a matching record, created a new record, or cancelled
                    //attempt to add mor for record (if one doesn't already exist)
                    long lngMORID = 0;

                    strSQL = "SELECT lngPrimaryMORID " +
                            "FROM tblRecords " +
                            "WHERE lngRecordID=" + lngRecordID;

                    cmdDB.CommandText = strSQL;

                    cmdDB.Parameters.Clear();

                    try { lngMORID = Convert.ToInt32(cmdDB.ExecuteScalar()); }
                    catch { lngMORID = 0; }

                    if (lngMORID == 0)
                    {
                        if (MessageBox.Show("Add MOR for this record?", "Add MOR?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            using (frmFindMOR objFindMOR = new frmFindMOR("%" + txtCamperLName.Text + "%", 1))
                            {
                                if (objFindMOR.ShowDialog() == DialogResult.OK)
                                {
                                    if (objFindMOR.lngMORID > 0)
                                        lngMORID = objFindMOR.lngMORID;
                                    else
                                    {//give option to create new MOR--forthcoming
                                        using (MORUtils.frmAddMOR objAddMOR = new global::CTWebMgmt.MORUtils.frmAddMOR(lngRecordWebID, lngRecordID, lngParentIRID))
                                        {
                                            if (objAddMOR.ShowDialog() == DialogResult.OK)
                                                lngMORID = objAddMOR.lngMORID;
                                            else
                                                return;
                                        }
                                    }

                                    if (lngMORID > 0)
                                    {
                                        //update camper's primary mor
                                        strSQL = "UPDATE tblRecords " +
                                                "SET blnUseMORAddress=-1, " +
                                                    "lngPrimaryMORID=" + lngMORID.ToString() + " " +
                                                "WHERE lngRecordID=" + lngRecordID.ToString();

                                        cmdDB.Parameters.Clear();
                                        cmdDB.CommandText = strSQL;

                                        try { cmdDB.ExecuteNonQuery(); }
                                        catch { }
                                    }
                                }
                                else
                                    return;
                            }

                            if (lngMORID > 0)
                            {
                                long lngMORIRLinkID = 0;

                                strSQL = "SELECT lngMORIRLinkID " +
                                        "FROM tblnkMORIR " +
                                        "WHERE lngMORID=" + lngMORID.ToString() + " AND " +
                                            "lngRecordID=" + lngRecordID.ToString();

                                cmdDB.CommandText = strSQL;
                                cmdDB.Parameters.Clear();

                                try { lngMORIRLinkID = Convert.ToInt32(cmdDB.ExecuteScalar()); }
                                catch { lngMORIRLinkID = 0; }

                                if (lngMORIRLinkID == 0)
                                {
                                    strSQL = "INSERT INTO tblnkMORIR " +
                                            "( lngMORID, lngRecordID, lngLastModifiedUser, " +
                                                "dteLastModified ) " +
                                            "SELECT " + lngMORID + ", " + lngRecordID + ", " + CTWebMgmt.lngCTUserID + ", " +
                                                "Now()";

                                    cmdDB.CommandText = strSQL;

                                    cmdDB.Parameters.Clear();

                                    cmdDB.ExecuteNonQuery();
                                }
                            }
                        }
                    }

                    //'make sure they are not already registered for one of the blocks

                    for (int intI = 1; intI <= 11; intI++)
                    {
                        if (((CheckBox)pagRegInfo.Controls["chkReg" + intI.ToString()]).Checked)
                        {
                            strSQL = "SELECT lngRegistrationID " +
                                    "FROM tblRegistrations " +
                                    "WHERE lngRecordID=" + lngRecordID + " AND " +
                                        "lngBlockID=" + ((clsCboItem)((ComboBox)pagRegInfo.Controls["cboBlockChoice" + intI]).SelectedItem).ID;

                            cmdDB.CommandText = strSQL;
                            cmdDB.Parameters.Clear();

                            lngRegistrationID = 0;

                            try { lngRegistrationID = Convert.ToInt32(cmdDB.ExecuteScalar()); }
                            catch { lngRegistrationID = 0; }

                            if (lngRegistrationID > 0)
                            {
                                MessageBox.Show("This record is already registered for this block. (" + ((clsCboItem)((ComboBox)pagRegInfo.Controls["cboBlockChoice" + intI]).SelectedItem).Item + ")");
                                return;
                            }
                        }
                    }

                    //check to see if approval is needed for the camper
                    try
                    {
                        strSQL = "SELECT tblRecords.blnApprovalNeeded " +
                                "FROM tblRecords " +
                                "WHERE tblRecords.lngRecordID=@lngRecordID";

                        cmdDB.CommandText = strSQL;
                        cmdDB.Parameters.Clear();

                        cmdDB.Parameters.AddWithValue("@lngRecordID", lngRecordID);

                        bool blnApprovalNeeded = false;

                        try { blnApprovalNeeded = Convert.ToBoolean(cmdDB.ExecuteScalar()); }
                        catch { blnApprovalNeeded = false; }

                        if (blnApprovalNeeded)
                        {
                            if (MessageBox.Show("This record needs administrative approval to register for an individual event.\nAre you sure you wish to continue?", "Approval Needed", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                                return;
                        }
                    }
                    catch (Exception ex) { }

                    //'add waiting list(s)
                    for (int intI = 0; intI <= 10; intI++)
                    {
                        if (intWaitList[intI] != 0)
                        {
                            //'make sure they aren't already on the list
                            strSQL = "SELECT lngWaitID " +
                                   "FROM tblWaitingList " +
                                   "WHERE lngRecordID=" + lngRecordID + " AND " +
                                       "lngBlockID=" + intWaitList[intI];

                            cmdDB.CommandText = strSQL;

                            cmdDB.Parameters.Clear();

                            using (OleDbDataReader drWait = cmdDB.ExecuteReader())
                            {
                                if (!drWait.Read())
                                {
                                    drWait.Close();

                                    int intGender = 0;

                                    //'make sure they are the right gender
                                    strSQL = "SELECT lngGenderID " +
                                           "FROM tblBlock " +
                                           "WHERE lngBlockID=" + intWaitList[intI];

                                    cmdDB.CommandText = strSQL;
                                    cmdDB.Parameters.Clear();

                                    try { intGender = Convert.ToInt32(cmdDB.ExecuteScalar()); }
                                    catch { intGender = 0; }

                                    if (!(intGender == 1 && radF.Checked) && !(intGender == 2 && radM.Checked))
                                    {
                                        //'add waiting list entry
                                        strSQL = "INSERT INTO tblWaitingList " +
                                               "( lngBlockID, lngRecordID, " +
                                                   "dteDateAdded ) " +
                                               "SELECT " + intWaitList[intI] + ", " + lngRecordID + ", " +
                                                   "@dteDateAdded";

                                        cmdDB.CommandText = strSQL;

                                        cmdDB.Parameters.Clear();
                                        cmdDB.Parameters.Add(new OleDbParameter("@dteDateAdded", dteRegDate));

                                        try { cmdDB.ExecuteNonQuery(); }
                                        catch { }

                                        //'update block stats
                                        strSQL = "SELECT Count(tblWaitingList.lngWaitID) AS CountOflngWaitID " +
                                                "FROM tblWaitingList " +
                                                "WHERE tblWaitingList.lngBlockID=" + intWaitList[intI];

                                        cmdDB.CommandText = strSQL;
                                        cmdDB.Parameters.Clear();

                                        int intWaitListCount = 0;

                                        try { intWaitListCount = Convert.ToInt32(cmdDB.ExecuteScalar()); }
                                        catch { intWaitListCount = 0; }

                                        strSQL = "UPDATE tblBlock " +
                                                "SET tblBlock.intWaitingList = " + intWaitListCount + " " +
                                                "WHERE tblBlock.lngBlockID=" + intWaitList[intI];

                                        cmdDB.CommandText = strSQL;
                                        cmdDB.Parameters.Clear();

                                        try { cmdDB.ExecuteNonQuery(); }
                                        catch { }
                                    }
                                    else
                                    {
                                        MessageBox.Show("The camper appears to be the wrong gender for the block.\n\nThe waiting list entry was not added.");
                                    }
                                }
                                else
                                    drWait.Close();
                            }

                            //add deposit and spending money for wait list selections
                            strSQL = "INSERT INTO tblTransactions " +
                                    "(blnMarkedForCC, " +
                                        "lngPaymentTypeID, lngRecordID, lngBillStateID, lngUserID, lngTransTypeID, " +
                                        "curPayment, " +
                                        "dteDateAdded, " +
                                        "strTransactionDesc, strCCNumber, strCCExpDate, strCCValCode, strBillName, strBillAddress, strBillCity, strBillZip, strBillPhone, strBankName, strAcctNum, strRoutingNum, strXCAlias, strXCTransID, strXCAuthCode, strPNRef, strEPSApprovalNumber, strEPSPmtAcctID, strEPSTransID, strEPSValidationCode ) " +
                                    "SELECT @blnMarkedForCC, " +
                                        "@lngPaymentTypeID, @lngRecordID, @lngBillStateID, @lngUserID, @lngTransTypeID, " +
                                        "@curPayment, " +
                                        "@dteDateAdded, " +
                                        "@strTransactionDesc, @strCCNumber, @strCCExpDate, @strCCValCode, @strBillName, @strBillAddress, @strBillCity, @strBillZip, @strBillPhone, @strBankName, @strAcctNum, @strRoutingNum, @strXCAlias, @strXCTransID, @strXCAuthCode, @strPNRef, @strEPSApprovalNumber, @strEPSPmtAcctID, @strEPSTransID, @strEPSValidationCode ";

                            cmdDB.CommandText = strSQL;
                            cmdDB.Parameters.Clear();

                            if (txtCardNumber.Text == "" && txtAcctNum.Text != "")
                                lngPmtType = 11;
                            else
                                lngPmtType = 2;

                            long lngBillStateID = 0;

                            try { lngBillStateID = ((clsCboItem)cboBillState.SelectedItem).ID; }
                            catch { lngBillStateID = 0; }

                            cmdDB.Parameters.Add(new OleDbParameter("@blnMarkedForCC", true));

                            cmdDB.Parameters.Add(new OleDbParameter("@lngPaymentTypeID", lngPmtType));
                            cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngRecordID));
                            cmdDB.Parameters.Add(new OleDbParameter("@lngBillStateID", lngBillStateID));
                            cmdDB.Parameters.Add(new OleDbParameter("@lngUserID", CTWebMgmt.lngUserID));
                            cmdDB.Parameters.Add(new OleDbParameter("@lngTransTypeID", 8));

                            cmdDB.Parameters.Add(new OleDbParameter("@curPayment", decPmtAmt));

                            cmdDB.Parameters.Add(new OleDbParameter("@dteDateAdded", dteRegDate));

                            cmdDB.Parameters.Add(new OleDbParameter("@strTransactionDesc", "Web Reg Tuition, Wait List"));
                            cmdDB.Parameters.Add(new OleDbParameter("@strCCNumber", txtCardNumber.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strCCExpDate", txtExpDate.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strCCValCode", txtCVV2.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillName", txtBillName.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillAddress", txtBillAddress.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillCity", txtBillCity.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillZip", txtBillZip.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillPhone", txtBillPhone.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBankName", txtBankName.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strAcctNum", txtAcctNum.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strRoutingNum", txtRoutingNum.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strXCAlias", txtXCAlias.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strXCTransID", txtXCTransID.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strXCAuthCode", txtXCAuthCode.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strPNRef", txtPNRef.Text));

                            cmdDB.Parameters.Add(new OleDbParameter("@strEPSApprovalNumber", txtEPSApprovalNumber.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strEPSPmtAcctID", txtEPSPmtAcctID.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strEPSTransID", txtEPSTransID.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strEPSValidationCode", txtEPSValidationCode.Text));

                            try { cmdDB.ExecuteNonQuery(); }
                            catch (Exception ex) { MessageBox.Show("There was an error recording the deposit: " + ex.Message); }

                            //add spending money credit for waiting list entry
                            if (decSpending > 0)
                            {
                                strSQL = "INSERT INTO tblTransactions " +
                                      "(blnMarkedForCC, " +
                                            "lngRecordID, lngTransTypeID, lngPaymentTypeID, lngBillStateID, lngUserID, " +
                                          "curPayment, " +
                                          "dteDateAdded, " +
                                          "strTransactionDesc, strCCNumber, strCCExpDate, strCCValCode, strBillName, strBillAddress, strBillCity, strBillZip, strBillPhone, strBankName, strAcctNum, strRoutingNum, strXCAlias, strXCTransID, strXCAuthCode, strPNRef, strEPSApprovalNumber, strEPSPmtAcctID, strEPSTransID, strEPSValidationCode )" +
                                  "SELECT @blnMarkedForCC, " +
                                            "@lngRecordID, @lngTransTypeID, @lngPaymentTypeID, @lngBillStateID, @lngUserID, " +
                                          "@curPayment, " +
                                          "@dteDateAdded, " +
                                          "@strTransactionDesc, @strCCNumber, @strCCExpDate, @strCCValCode, @strBillName, @strBillAddress, @strBillCity, @strBillZip, @strBillPhone, @strBankName, @strAcctNum, @strRoutingNum, @strXCAlias, @strXCTransID, @strXCAuthCode, @strPNRef, @strEPSApprovalNumber, @strEPSPmtAcctID, @strEPSTransID, @strEPSValidationCode ";

                                cmdDB.CommandText = strSQL;
                                cmdDB.Parameters.Clear();

                                cmdDB.Parameters.Add(new OleDbParameter("@blnMarkedForCC", true));

                                cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngRecordID));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngTransTypeID", 25));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngPaymentTypeID", lngPmtType));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngBillStateID", lngBillStateID));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngUserID", CTWebMgmt.lngUserID));
                                cmdDB.Parameters.Add(new OleDbParameter("@curPayment", decSpending));

                                cmdDB.Parameters.Add(new OleDbParameter("@dteDateAdded", dteRegDate));

                                cmdDB.Parameters.Add(new OleDbParameter("@strTransactionDesc", "Web Reg Spending Money, Wait List"));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCNumber", txtCardNumber.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCExpDate", txtExpDate.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCValCode", txtCVV2.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillName", txtBillName.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillAddress", txtBillAddress.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillCity", txtBillCity.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillZip", txtBillZip.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillPhone", txtBillPhone.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBankName", txtBankName.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strAcctNum", txtAcctNum.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strRoutingNum", txtRoutingNum.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strXCAlias", txtXCAlias.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strXCTransID", txtXCTransID.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strXCAuthCode", txtXCAuthCode.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strPNRef", txtPNRef.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSApprovalNumber", txtEPSApprovalNumber.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSPmtAcctID", txtEPSPmtAcctID.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSTransID", txtEPSTransID.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSValidationCode", txtEPSValidationCode.Text));

                                try { cmdDB.ExecuteNonQuery(); }
                                catch { }
                            }
                        }
                    }

                    //choice level variables that need to be checked for each reg box checked
                    string strBlockCode = "";

                    long lngBlockID = 0;
                    decimal decTuitionCharge = 0;

                    //get pref for how to apply reg flag charges for multiple block choices
                    bool blnMultRegFlagCharge = true;

                    if (intTotChoices > 1)
                    {
                        using (wsXferEventInfo.XferEventInfo svcCT = new global::CTWebMgmt.wsXferEventInfo.XferEventInfo())
                            blnMultRegFlagCharge = svcCT.fcnGetMultRegFlagCharge(clsAppSettings.GetAppSettings().lngCTUserID, clsWebTalk.strWebConn);
                    }
                    else
                        blnMultRegFlagCharge = false;

                    for (int intBlockChoice = 1; intBlockChoice <= 11; intBlockChoice++)
                    {
                        //if block is selected and reg box is checked
                        if (((ComboBox)pagRegInfo.Controls["cboBlockChoice" + intBlockChoice.ToString()]).SelectedIndex >= 0 && ((CheckBox)pagRegInfo.Controls["chkReg" + intBlockChoice.ToString()]).Checked)
                        {
                            try { lngBlockID = ((clsCboItem)((ComboBox)pagRegInfo.Controls["cboBlockChoice" + intBlockChoice.ToString()]).SelectedItem).ID; }
                            catch { lngBlockID = 0; }

                            try { strBlockCode = ((clsCboItem)((ComboBox)pagRegInfo.Controls["cboBlockChoice" + intBlockChoice.ToString()]).SelectedItem).Item; }
                            catch { strBlockCode = ""; }

                            //validate gender, grade, age group, availability of block choice
                            if (!fcnValBlockChoice(lngRecordID, lngBlockID))
                                return;
                            else
                            {
                                //camper selected is correct gender and grade, verify registration.
                                if (MessageBox.Show("Register " + txtCamperFName.Text + " " + txtCamperLName.Text + " for program block " + strBlockCode + "?", "Register?", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                                    return;
                                else
                                {
                                    //add registration record

                                    strSQL = "INSERT INTO tblRegistrations " +
                                            "( lngBlockID, lngRecordID, lngRegSourceID, lngUserID, lngConfMethodID, " +
                                                "dteRegistrationDate, " +
                                                "strBuddy1, strBuddy2, strReleaseTo, strReferredBy, strOrgCode, " +
                                                "mmoRegNotes ) " +
                                            "SELECT @lngBlockID, @lngRecordID, @lngRegSourceID, @lngUserID, 2, " +
                                                "@dteRegistrationDate, " +
                                                "@strBuddy1, @strBuddy2, @strReleaseTo, @strReferredBy, @strOrgCode, " +
                                                "@mmoRegNotes";

                                    cmdDB.Parameters.Clear();
                                    cmdDB.CommandText = strSQL;

                                    cmdDB.Parameters.Add(new OleDbParameter("@lngBlockID", lngBlockID));
                                    cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngRecordID));
                                    cmdDB.Parameters.Add(new OleDbParameter("@lngRegSourceID", 3));
                                    cmdDB.Parameters.Add(new OleDbParameter("@lngUserID", CTWebMgmt.lngUserID));
                                    cmdDB.Parameters.Add(new OleDbParameter("@dteRegistrationDate", dteRegDate));
                                    cmdDB.Parameters.Add(new OleDbParameter("@strBuddy1", txtBuddy1.Text));
                                    cmdDB.Parameters.Add(new OleDbParameter("@strBuddy2", txtBuddy2.Text));
                                    cmdDB.Parameters.Add(new OleDbParameter("@strReleaseTo", txtReleaseTo.Text));

                                    string strReferredBy = "";

                                    try { strReferredBy = ((clsCboItem)cboReferredBy.SelectedItem).Item; }
                                    catch { strReferredBy = ""; }

                                    cmdDB.Parameters.Add(new OleDbParameter("@strReferredBy", strReferredBy));

                                    cmdDB.Parameters.AddWithValue("@strOrgCode", txtOrgCode.Text);

                                    string mmoRegNotes = "";

                                    try { mmoRegNotes = txtNotes.Text; }
                                    catch { mmoRegNotes = ""; }

                                    cmdDB.Parameters.AddWithValue("@mmoRegNotes", mmoRegNotes);

                                    try { cmdDB.ExecuteNonQuery(); }
                                    catch { }

                                    strSQL = "SELECT @@IDENTITY;";

                                    cmdDB.Parameters.Clear();
                                    cmdDB.CommandText = strSQL;

                                    try { lngRegistrationID = Convert.ToInt32(cmdDB.ExecuteScalar()); }
                                    catch { lngRegistrationID = 0; }

                                    //add reg custom data vals
                                    strSQL = "DELETE tblCustomFieldValReg.* " +
                                            "FROM tblCustomFieldValReg " +
                                            "WHERE lngRegistrationID=@lngRegistrationID";

                                    cmdDB.Parameters.Clear();
                                    cmdDB.CommandText = strSQL;

                                    cmdDB.Parameters.AddWithValue("@lngRegistrationID", lngRegistrationID);

                                    try { cmdDB.ExecuteNonQuery(); }
                                    catch { }

                                    //loop through reg data and add to registration
                                    ////////////////////////////////////////////////////////////////////
                                    for (int intI = 0; intI < pagCustomReg.Controls.Count; intI++)
                                    {
                                        if (pagCustomReg.Controls[intI].HasChildren)
                                        {
                                            if (pagCustomReg.Controls[intI].Name.StartsWith("panCustomReg_"))
                                            {
                                                long lngCustomFieldDefRegID = 0;
                                                string strID = pagCustomReg.Controls[intI].Name;

                                                lngCustomFieldDefRegID= Convert.ToInt32(strID.Substring(strID.IndexOf("_") + 1, strID.Length - (strID.IndexOf("_") + 1)));

                                                Panel panCustom = (Panel)pagCustomReg.Controls[intI];

                                                string strLocalCaption = "";
                                                string strValue = "";

                                                //assume textbox or cbo for caption
                                                try { strLocalCaption = ((Label)panCustom.Controls["lblCustFieldReg_" +lngCustomFieldDefRegID.ToString()]).Text; }
                                                catch { strLocalCaption = ""; }

                                                //either a flag or err
                                                if (strLocalCaption == "")
                                                {
                                                    try { strLocalCaption = ((CheckBox)panCustom.Controls["chkCustReg_" +lngCustomFieldDefRegID.ToString()]).Text; }
                                                    catch { strLocalCaption = ""; }
                                                }

                                                if (strLocalCaption != "")
                                                {
                                                    try { strValue = ((TextBox)panCustom.Controls["txtCustFieldReg_" +lngCustomFieldDefRegID.ToString()]).Text; }
                                                    catch { strValue = ""; }

                                                    if (strValue == "")
                                                    {
                                                        try { strValue = ((CheckBox)panCustom.Controls["chkCustReg_" +lngCustomFieldDefRegID.ToString()]).Checked.ToString(); }
                                                        catch { strValue = ""; }
                                                    }

                                                    if (strValue == "")
                                                    {
                                                        try { strValue = ((ComboBox)panCustom.Controls["cboCustFieldReg_" +lngCustomFieldDefRegID.ToString()]).SelectedItem.ToString(); }
                                                        catch { strValue = ""; }
                                                    }
                                                }

                                                //strLocalCaption;
                                                //strValue;
                                                strSQL = "INSERT INTO tblCustomFieldValReg " +
                                                        "( lngRegistrationID, " +
                                                            "strLocalCaption, strValue ) " +
                                                        "VALUES " +
                                                        "( @lngRegistrationID, " +
                                                            "@strLocalCaption, @strValue )";

                                                cmdDB.CommandText = strSQL;
                                                cmdDB.Parameters.Clear();

                                                cmdDB.Parameters.AddWithValue("@lngRegistrationID", lngRegistrationID);
                                                cmdDB.Parameters.AddWithValue("@strLocalCaption", strLocalCaption);
                                                cmdDB.Parameters.AddWithValue("@strValue", strValue);

                                                try { cmdDB.ExecuteNonQuery(); }
                                                catch { }
                                            }
                                        }
                                    }

                                    //get reg id to add transaction
                                    long lngTuitionChargeID = fcnAddTuitionCharge(cmdDB, lngRecordID, lngBlockID, lngRegistrationID, ref decTuitionCharge);

                                    //update reg w/ transaction id
                                    strSQL = "UPDATE tblRegistrations " +
                                            "SET lngTransactionID=" + lngTuitionChargeID.ToString() + " " +
                                            "WHERE lngRegistrationID=" + lngRegistrationID.ToString();

                                    cmdDB.CommandText = strSQL;
                                    cmdDB.Parameters.Clear();

                                    cmdDB.ExecuteNonQuery();

                                    //adjust block stats
                                    subOneBlockRegCount(cmdDB, lngBlockID);

                                    long lngBillStateID = 0;

                                    try { lngBillStateID = ((clsCboItem)cboBillState.SelectedItem).ID; }
                                    catch { lngBillStateID = 0; }

                                    if (decPmtAmt > 0)
                                    {
                                        //add payment
                                        strSQL = "INSERT INTO tblTransactions " +
                                                "(blnMarkedForCC, " +
                                                    "lngPaymentTypeID, lngRecordID, lngRegistrationID, lngBillStateID, lngUserID, lngTransTypeID, " +
                                                    "curPayment, " +
                                                    "dteDateAdded, " +
                                                    "strTransactionDesc, strCCNumber, strCCExpDate, strCCValCode, strBillName, strBillAddress, strBillCity, strBillZip, strBillPhone, strBankName, strAcctNum, strRoutingNum, strXCAlias, strXCTransID, strXCAuthCode, strPNRef, strEPSApprovalNumber, strEPSPmtAcctID, strEPSTransID, strEPSValidationCode ) " +
                                                "SELECT @blnMarkedForCC, " +
                                                    "@lngPaymentTypeID, @lngRecordID, @lngRegistrationID, @lngBillStateID, @lngUserID, @lngTransTypeID, " +
                                                    "@curPayment, " +
                                                    "@dteDateAdded, " +
                                                    "@strTransactionDesc, @strCCNumber, @strCCExpDate, @strCCValCode, @strBillName, @strBillAddress, @strBillCity, @strBillZip, @strBillPhone, @strBankName, @strAcctNum, @strRoutingNum, @strXCAlias, @strXCTransID, @strXCAuthCode, @strPNRef, @strEPSApprovalNumber, @strEPSPmtAcctID, @strEPSTransID, @strEPSValidationCode ";

                                        cmdDB.CommandText = strSQL;
                                        cmdDB.Parameters.Clear();

                                        if (txtCardNumber.Text == "" && txtAcctNum.Text != "")
                                            lngPmtType = 11;
                                        else
                                            lngPmtType = 2;

                                        cmdDB.Parameters.Add(new OleDbParameter("@blnMarkedForCC", true));

                                        cmdDB.Parameters.Add(new OleDbParameter("@lngPaymentTypeID", lngPmtType));
                                        cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngRecordID));
                                        cmdDB.Parameters.Add(new OleDbParameter("@lngRegistrationID", lngRegistrationID));
                                        cmdDB.Parameters.Add(new OleDbParameter("@lngBillStateID", lngBillStateID));
                                        cmdDB.Parameters.Add(new OleDbParameter("@lngUserID", CTWebMgmt.lngUserID));
                                        cmdDB.Parameters.Add(new OleDbParameter("@lngTransTypeID", 8));

                                        cmdDB.Parameters.Add(new OleDbParameter("@curPayment", decPmtAmt));

                                        cmdDB.Parameters.Add(new OleDbParameter("@dteDateAdded", dteRegDate));

                                        cmdDB.Parameters.Add(new OleDbParameter("@strTransactionDesc", "Web Reg Tuition"));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strCCNumber", txtCardNumber.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strCCExpDate", txtExpDate.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strCCValCode", txtCVV2.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBillName", txtBillName.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBillAddress", txtBillAddress.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBillCity", txtBillCity.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBillZip", txtBillZip.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBillPhone", txtBillPhone.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBankName", txtBankName.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strAcctNum", txtAcctNum.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strRoutingNum", txtRoutingNum.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strXCAlias", txtXCAlias.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strXCTransID", txtXCTransID.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strXCAuthCode", txtXCAuthCode.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strPNRef", txtPNRef.Text));

                                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSApprovalNumber", txtEPSApprovalNumber.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSPmtAcctID", txtEPSPmtAcctID.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSTransID", txtEPSTransID.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSValidationCode", txtEPSValidationCode.Text));

                                        try { cmdDB.ExecuteNonQuery(); }
                                        catch { }

                                        strSQL = "SELECT @@IDENTITY";

                                        cmdDB.CommandText = strSQL;
                                        cmdDB.Parameters.Clear();

                                        long lngPmtTransID = 0;

                                        try { lngPmtTransID = Convert.ToInt32(cmdDB.ExecuteScalar()); }
                                        catch { lngPmtTransID = 0; }

                                        //update pn ref in billing info
                                        clsIRCRUD.subUpdateBillingInfoCC(lngRecordID, txtPNRef.Text, txtCardNumber.Text, txtXCAlias.Text, txtEPSPmtAcctID.Text);
                                    }

                                    //add spending money if amt > 0
                                    if (decSpending > 0)
                                    {
                                        strSQL = "INSERT INTO tblTransactions " +
                                              "(blnMarkedForCC, " +
                                                    "lngRecordID, lngTransTypeID, lngPaymentTypeID, lngRegistrationID, lngBillStateID, lngUserID, " +
                                                  "curPayment, " +
                                                  "dteDateAdded, " +
                                                  "strTransactionDesc, strCCNumber, strCCExpDate, strCCValCode, strBillName, strBillAddress, strBillCity, strBillZip, strBillPhone, strBankName, strAcctNum, strRoutingNum, strXCAlias, strXCTransID, strXCAuthCode, strPNRef, strEPSApprovalNumber, strEPSPmtAcctID, strEPSTransID, strEPSValidationCode )" +
                                          "SELECT @blnMarkedForCC, " +
                                                    "@lngRecordID, @lngTransTypeID, @lngPaymentTypeID, @lngRegistrationID, @lngBillStateID, @lngUserID, " +
                                                  "@curPayment, " +
                                                  "@dteDateAdded, " +
                                                  "@strTransactionDesc, @strCCNumber, @strCCExpDate, @strCCValCode, @strBillName, @strBillAddress, @strBillCity, @strBillZip, @strBillPhone, @strBankName, @strAcctNum, @strRoutingNum, @strXCAlias, @strXCTransID, @strXCAuthCode, @strPNRef, @strEPSApprovalNumber, @strEPSPmtAcctID, @strEPSTransID, @strEPSValidationCode ";

                                        cmdDB.CommandText = strSQL;
                                        cmdDB.Parameters.Clear();

                                        cmdDB.Parameters.Add(new OleDbParameter("@blnMarkedForCC", true));

                                        cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngRecordID));
                                        cmdDB.Parameters.Add(new OleDbParameter("@lngTransTypeID", 25));
                                        cmdDB.Parameters.Add(new OleDbParameter("@lngPaymentTypeID", lngPmtType));
                                        cmdDB.Parameters.Add(new OleDbParameter("@lngRegistrationID", lngRegistrationID));
                                        cmdDB.Parameters.Add(new OleDbParameter("@lngBillStateID", lngBillStateID));
                                        cmdDB.Parameters.Add(new OleDbParameter("@lngUserID", CTWebMgmt.lngUserID));
                                        cmdDB.Parameters.Add(new OleDbParameter("@curPayment", decSpending));

                                        cmdDB.Parameters.Add(new OleDbParameter("@dteDateAdded", dteRegDate));

                                        cmdDB.Parameters.Add(new OleDbParameter("@strTransactionDesc", "Web Reg Spending Money"));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strCCNumber", txtCardNumber.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strCCExpDate", txtExpDate.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strCCValCode", txtCVV2.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBillName", txtBillName.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBillAddress", txtBillAddress.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBillCity", txtBillCity.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBillZip", txtBillZip.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBillPhone", txtBillPhone.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strBankName", txtBankName.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strAcctNum", txtAcctNum.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strRoutingNum", txtRoutingNum.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strXCAlias", txtXCAlias.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strXCTransID", txtXCTransID.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strXCAuthCode", txtXCAuthCode.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strPNRef", txtPNRef.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSApprovalNumber", txtEPSApprovalNumber.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSPmtAcctID", txtEPSPmtAcctID.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSTransID", txtEPSTransID.Text));
                                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSValidationCode", txtEPSValidationCode.Text));

                                        cmdDB.ExecuteNonQuery();

                                        strSQL = "SELECT @@IDENTITY";

                                        cmdDB.CommandText = strSQL;
                                        cmdDB.Parameters.Clear();

                                        long lngSpendingTransID = 0;

                                        try { lngSpendingTransID = Convert.ToInt32(cmdDB.ExecuteScalar()); }
                                        catch { lngSpendingTransID = 0; }
                                    }

                                    //check for discounts
                                    strSQL = "SELECT curDiscAmt1, curDiscAmt10, curDiscAmt2, curDiscAmt3, curDiscAmt4, curDiscAmt5, curDiscAmt6, curDiscAmt7, curDiscAmt8, curDiscAmt9, " +
                                                "strDiscDesc1, strDiscDesc10, strDiscDesc2, strDiscDesc3, strDiscDesc4, strDiscDesc5, strDiscDesc6, strDiscDesc7, strDiscDesc8, strDiscDesc9 " +
                                            "FROM tblCampDefaults;";

                                    cmdDB.CommandText = strSQL;
                                    cmdDB.Parameters.Clear();

                                    using (OleDbDataReader drDiscount = cmdDB.ExecuteReader())
                                    {
                                        if (drDiscount.Read())
                                        {
                                            string strDiscDesc = "";

                                            decimal decDiscAmt = 0;

                                            for (int intJ = 1; intJ <= 10; intJ++)
                                            {
                                                try
                                                {
                                                    decDiscAmt = Convert.ToDecimal(drDiscount["curDiscAmt" + intJ.ToString()]);
                                                    strDiscDesc = Convert.ToString(drDiscount["strDiscDesc" + intJ.ToString()]);
                                                }
                                                catch
                                                {
                                                    strDiscDesc = "";
                                                    decDiscAmt = 0;
                                                }

                                                //if discount is being used by camp, check to see if it is applied to this camper
                                                if (decDiscAmt > 0)
                                                {
                                                    if (((CheckBox)fraDiscounts.Controls["chkDiscount" + intJ.ToString()]).Checked)
                                                    {
                                                        strSQL = "INSERT INTO tblTransactions " +
                                                                "( lngRecordID, lngTransTypeID, lngPaymentTypeID, lngRegistrationID, lngUserID, " +
                                                                    "curPayment, " +
                                                                    "dteDateAdded, " +
                                                                    "strTransactionDesc ) " +
                                                                "SELECT " + lngRecordID + ", 69, 6, " + lngRegistrationID + ", " + CTWebMgmt.lngUserID + ", " +
                                                                    decDiscAmt + ", " +
                                                                    "@dteDateAdded, " +
                                                                    "\"" + strDiscDesc + "\"";

                                                        using (OleDbCommand cmdDisc = new OleDbCommand(strSQL, conDB))
                                                        {
                                                            cmdDisc.Parameters.Add(new OleDbParameter("@dteDateAdded", dteRegDate));
                                                            cmdDisc.ExecuteNonQuery();
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        drDiscount.Close();
                                    }

                                    //add any charges associated w/ custom reg flags
                                    //get trans type to use for charges
                                    if (blnMultRegFlagCharge || intBlockChoice==1)
                                    {
                                        long lngDefCustRegFlagTransType = 0;

                                        strSQL = "SELECT lngDefCustRegFlagTransType " +
                                                "FROM tblCampDefaults";

                                        cmdDB.CommandText = strSQL;
                                        cmdDB.Parameters.Clear();

                                        try { lngDefCustRegFlagTransType = Convert.ToInt32(cmdDB.ExecuteScalar()); }
                                        catch { lngDefCustRegFlagTransType = 0; }

                                        //next get rs of reg flags w/ a charge
                                        strSQL = "SELECT tblCustomFieldDefReg.lngCustomFieldDefRegID, " +
                                                    "tblCustomFieldDefReg.decCharge, " +
                                                    "tblCustomFieldDefReg.strLocalCaption " +
                                                "FROM tblCustomFieldDefReg " +
                                                "WHERE tblCustomFieldDefReg.blnUseLocal=True AND " +
                                                    "tblCustomFieldDefReg.decCharge>0 AND " +
                                                    "tblCustomFieldDefReg.strFieldType='FLAG'";

                                        cmdDB.Parameters.Clear();
                                        cmdDB.CommandText = strSQL;

                                        using (OleDbDataReader drFlagCharge = cmdDB.ExecuteReader())
                                        {
                                            while (drFlagCharge.Read())
                                            {
                                                long lngCustomFieldDefRegID = 0;

                                                try { lngCustomFieldDefRegID = Convert.ToInt32(drFlagCharge["lngCustomFieldDefRegID"]); }
                                                catch { lngCustomFieldDefRegID = 0; }

                                                if (((CheckBox)pagCustomReg.Controls["panCustomReg_" + lngCustomFieldDefRegID.ToString()].Controls["chkCustReg_" + lngCustomFieldDefRegID.ToString()]).Checked)
                                                {
                                                    decimal decCharge = 0;

                                                    try { decCharge = Convert.ToDecimal(drFlagCharge["decCharge"]); }
                                                    catch { decCharge = 0; }

                                                    string strDesc = "";

                                                    try { strDesc = "Charge for " + Convert.ToString(drFlagCharge["strLocalCaption"]); }
                                                    catch { strDesc = "Charge for custom reg flag"; }

                                                    //add transaction
                                                    if (decCharge > 0)
                                                        subAddRegFlagCharge(decCharge, lngRegistrationID, lngRecordID, CTWebMgmt.lngUserID, lngDefCustRegFlagTransType, strDesc);
                                                }
                                            }

                                            drFlagCharge.Close();
                                        }
                                    }
                                }
                            }
                        }
                    }

                    //add donation if required
                    decimal decDonation = 0;

                    try { decDonation = decimal.Parse(txtDonation.Text, System.Globalization.NumberStyles.Currency); }
                    catch { decDonation = 0; }

                    if (decDonation > 0)
                    {
                        long lngGiftCategory = 0;
                        long lngCampaign = 0;
                        long lngTrigger = 0;

                        strSQL = "SELECT lngOLGiftCategoryID, lngOLGiftCampaign, lngOLTriggerID " +
                                "FROM tblCampDefaults";

                        cmdDB.CommandText = strSQL;
                        cmdDB.Parameters.Clear();

                        using (OleDbDataReader drDef = cmdDB.ExecuteReader())
                        {
                            if (drDef.Read())
                            {
                                try { lngGiftCategory = Convert.ToInt32(drDef["lngOLGiftCategoryID"]); }
                                catch { lngGiftCategory = 0; }

                                try { lngCampaign = Convert.ToInt32(drDef["lngOLGiftCampaign"]); }
                                catch { lngCampaign = 0; }

                                try { lngTrigger = Convert.ToInt32(drDef["lngOLTriggerID"]); }
                                catch { lngTrigger = 0; }
                            }

                            drDef.Close();
                        }

                        long lngGiftID = 0;

                        strSQL = "INSERT INTO tblGift " +
                                "(lngGiftCategoryID, lngRecordID, lngCampaignID, lngGiftTypeID, lngTriggerID, lngPaymentTypeID, lngBillStateID, " +
                                    "dteGiftDate, dteDateEntered, " +
                                    "curAmount, " +
                                    "strAcctNum, strBankName, strBillAddress, strBillCity, strBillName, strBillPhone, strBillZip, strCCExpDate, strCCNumber, strCCValCode, strRoutingNum, strXCAlias, strXCTransID, strXCAuthCode, strPNRef, strEPSApprovalNumber, strEPSPmtAcctID, strEPSTransID, strEPSValidationCode, " +
                                    "mmoNotes) " +
                                "SELECT @lngGiftCategoryID, @lngRecordID, @lngCampaignID, @lngGiftTypeID, @lngTriggerID, @lngPaymentTypeID, @lngBillStateID, " +
                                    "@dteGiftDate, @dteDateEntered, " +
                                    "@curAmount, " +
                                    "@strAcctNum, @strBankName, @strBillAddress, @strBillCity, @strBillName, @strBillPhone, @strBillZip, @strCCExpDate, @strCCNumber, @strCCValCode, @strRoutingNum, @strXCAlias, @strXCTransID, @strXCAuthCode, @strPNRef, @strEPSApprovalNumber, @strEPSPmtAcctID, @strEPSTransID, @strEPSValidationCode, " +
                                    "@mmoNotes";

                        cmdDB.CommandText = strSQL;
                        cmdDB.Parameters.Clear();

                        long lngBillStateID = 0;

                        try { lngBillStateID = ((clsCboItem)cboBillState.SelectedItem).ID; }
                        catch { lngBillStateID = 0; }

                        cmdDB.Parameters.Add(new OleDbParameter("@lngGiftCategoryID", lngGiftCategory));

                        long lngDonorID = 0;

                        if (radDonationToParent.Checked)
                            lngDonorID = lngParentIRID;
                        else
                            lngDonorID = lngRecordID;

                        cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngDonorID));

                        cmdDB.Parameters.Add(new OleDbParameter("@lngCampaignID", lngCampaign));
                        cmdDB.Parameters.Add(new OleDbParameter("@lngGiftTypeID", 1));
                        cmdDB.Parameters.Add(new OleDbParameter("@lngTriggerID", lngTrigger));
                        cmdDB.Parameters.Add(new OleDbParameter("@lngPaymentTypeID", lngPmtType));
                        cmdDB.Parameters.Add(new OleDbParameter("@lngBillStateID", lngBillStateID));

                        cmdDB.Parameters.Add(new OleDbParameter("@dteGiftDate", dteRegDate));
                        cmdDB.Parameters.Add(new OleDbParameter("@dteDateEntered", OleDbType.Date));
                        cmdDB.Parameters["@dteDateEntered"].Value = DateTime.Now;

                        cmdDB.Parameters.Add(new OleDbParameter("@curAmount", decDonation));
                        cmdDB.Parameters.Add(new OleDbParameter("@strAcctNum", txtAcctNum.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strBankName", txtBankName.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strBillAddress", txtBillAddress.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strBillCity", txtBillCity.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strBillName", txtBillName.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strBillPhone", txtBillPhone.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strBillZip", txtBillZip.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strCCExpDate", txtExpDate.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strCCNumber", txtCardNumberUnmasked.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strCCValCode", txtCVV2.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strRoutingNum", txtRoutingNum.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strXCAlias", txtXCAlias.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strXCTransID", txtXCTransID.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strXCAuthCode", txtXCAuthCode.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strPNRef", txtPNRef.Text));

                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSApprovalNumber", txtEPSApprovalNumber.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSPmtAcctID", txtEPSPmtAcctID.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSTransID", txtEPSTransID.Text));
                        cmdDB.Parameters.Add(new OleDbParameter("@strEPSValidationCode", txtEPSValidationCode.Text));

                        cmdDB.Parameters.Add(new OleDbParameter("@mmoNotes", "Online Donation"));

                        cmdDB.ExecuteNonQuery();

                        strSQL = "SELECT @@IDENTITY";

                        cmdDB.CommandText = strSQL;
                        cmdDB.Parameters.Clear();

                        try { lngGiftID = Convert.ToInt32(cmdDB.ExecuteScalar()); }
                        catch { lngGiftID = 0; }

                        //mark record as donor
                        strSQL = "UPDATE tblRecords " +
                                "SET blnDonor = True " +
                                "WHERE lngRecordID=" + lngDonorID.ToString();

                        cmdDB.CommandText = strSQL;
                        cmdDB.Parameters.Clear();

                        cmdDB.ExecuteNonQuery();
                    }

                    //add choices for camper
                    strSQL = "SELECT lngChoiceID " +
                            "FROM tblChoices " +
                            "WHERE lngRecordID=" + lngRecordID.ToString();

                    cmdDB.CommandText = strSQL;
                    cmdDB.Parameters.Clear();

                    if (Convert.ToInt32(cmdDB.ExecuteScalar()) > 0)
                    {
                        //create choices record
                        strSQL = "INSERT INTO tblChoices ( lngRecordID, lngBlockID1, lngBlockID2, lngBlockID3, lngBlockID4, lngBlockID5, lngBlockID6, lngBlockID7, lngBlockID8, lngBlockID9, lngBlockID10 ) " +
                                "SELECT " + lngRecordID.ToString();

                        for (int intI = 1; intI <= 10; intI++)
                        {
                            try { strSQL += ", " + ((clsCboItem)((ComboBox)pagRegInfo.Controls["cboBlockChoice" + intI.ToString()]).SelectedItem).ID.ToString(); }
                            catch { strSQL += ", 0"; }
                        }
                    }
                    else
                    {
                        //update existing choices record
                        strSQL = "UPDATE tblChoices " +
                                "SET ";

                        for (int intI = 1; intI <= 10; intI++)
                        {
                            try
                            {
                                long lngChoiceBlockID = 0;

                                try { lngChoiceBlockID = ((clsCboItem)((ComboBox)pagRegInfo.Controls["cboBlockChoice" + intI.ToString()]).SelectedItem).ID; }
                                catch { lngChoiceBlockID = 0; }

                                strSQL += "lngBlockID" + intI.ToString() + "=" + lngChoiceBlockID.ToString() + ", ";
                            }
                            catch { strSQL += "lngBlockID" + intI.ToString() + "=0, "; }
                        }

                        strSQL = strSQL.Substring(0, strSQL.Length - 2);

                    }

                    cmdDB.CommandText = strSQL;
                    cmdDB.Parameters.Clear();

                    cmdDB.ExecuteNonQuery();

                    //apply hold registration, shared cost
                    //////////////////////////////
                    if (cboRegHold.SelectedIndex > 0)
                    {
                        long lngRegHoldID = 0;

                        try { lngRegHoldID = Convert.ToInt32(((clsCboItem)cboRegHold.SelectedItem).ID); }
                        catch { lngRegHoldID = 0; }

                        if (lngRegHoldID > 0)
                        {
                            //add transaction (if applicable) to registration holder, camper
                            decimal decSplitAmt = 0;
                            long lngRegHolderID = 0;

                            bool blnSharedCostPercent = false;

                            strSQL = "SELECT blnSharedCostPercent, " +
                                        "curCostShare, " +
                                        "lngRecordID " +
                                    "FROM tblRegHold " +
                                    "WHERE lngRegHoldID=" + lngRegHoldID.ToString();

                            cmdDB.Parameters.Clear();
                            cmdDB.CommandText = strSQL;

                            using (OleDbDataReader drHold = cmdDB.ExecuteReader())
                            {
                                if (drHold.Read())
                                {
                                    try { blnSharedCostPercent = Convert.ToBoolean(drHold["blnSharedCostPercent"]); }
                                    catch { blnSharedCostPercent = false; }

                                    try { decSplitAmt = Convert.ToDecimal(drHold["curCostShare"]); }
                                    catch { decSplitAmt = 0; }

                                    try { lngRegHolderID = Convert.ToInt32(drHold["lngRecordID"]); }
                                    catch { lngRegHolderID = 0; }
                                }

                                drHold.Close();
                            }

                            if (decSplitAmt > 0)
                            {
                                if (blnSharedCostPercent)
                                    decSplitAmt = decSplitAmt * decTuitionCharge;

                                strSQL = "INSERT INTO tblTransactions ( lngRecordID, lngTransTypeID, lngRegistrationID, lngRegHoldID, lngUserID, " +
                                            "curCharge, " +
                                            "dteDateAdded ) " +
                                        "VALUES " +
                                            "(" + lngRegHolderID + ", 38, " + lngRegistrationID + ", " + lngRegHoldID + ", " + CTWebMgmt.lngCTUserID.ToString() + ", " +
                                            decSplitAmt + ", " +
                                            "@dteDateAdded)";

                                cmdDB.CommandText = strSQL;
                                cmdDB.Parameters.Clear();

                                cmdDB.Parameters.Add(new OleDbParameter("@dteDateAdded", dteRegDate));

                                cmdDB.ExecuteNonQuery();

                                //add credit to registering camper
                                strSQL = "INSERT INTO tblTransactions ( lngRecordID, lngTransTypeID, lngRegistrationID, lngRegHoldID, lngUserID, " +
                                            "curPayment, " +
                                            "dteDateAdded ) " +
                                        "VALUES " +
                                        "(" + lngRecordID + ", 39 , " + lngRegistrationID + ", " + lngRegHoldID + ", " + CTWebMgmt.lngCTUserID.ToString() + ", " +
                                            decSplitAmt + ", " +
                                            "@dteDateAdded)";

                                cmdDB.CommandText = strSQL;
                                cmdDB.Parameters.Clear();

                                cmdDB.Parameters.Add(new OleDbParameter("@dteDateAdded", dteRegDate));

                                cmdDB.ExecuteNonQuery();
                            }

                            strSQL = "UPDATE tblRegistrations " +
                                    "SET tblRegistrations.lngRegHoldID = " + lngRegHoldID.ToString() + " " +
                                    "WHERE tblRegistrations.lngRegistrationID=" + lngRegistrationID.ToString();

                            cmdDB.CommandText = strSQL;
                            cmdDB.Parameters.Clear();

                            cmdDB.ExecuteNonQuery();
                        }
                    }
                    ////////////////////////////////

                    //mark camper as processed
                    strSQL = "UPDATE tblWebIndRegistrations " +
                        "SET blnProcessed=True " +
                        "WHERE lngRegistrationWebID=" + lngRegWebID.ToString();

                    cmdDB.CommandText = strSQL;
                    cmdDB.Parameters.Clear();

                    cmdDB.ExecuteNonQuery();
                }

                conDB.Close();
            }

            Close();
        }
        private long fcnProcessProfileRecord(bool _blnRequired)
        {
            //match profile info to existing record in camptrak.
            //give option to create a record if it doesn't exist
            //update local record's web id, update web record's local id
            //return local record id of profile

            long lngProfileWebID = 0;
            long lngProfileID = 0;
            long lngStateID = 0;
            string strFName = "";
            string strLName = "";
            string strAddress = "";
            string strCity = "";
            string strZip = "";
            string strPhone = "";
            string strCellPhone = "";
            string strEmail = "";
            string strPassword="";
            string strConfEmail = "";

            string strSQL = "";

            try { lngProfileWebID = Convert.ToInt32(btnProfileDetails.Tag); }
            catch { lngProfileWebID = 0; }

            //collect details of profile
            using (OleDbConnection conDB = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn))
            {
                conDB.Open();

                strSQL = "SELECT lngStateID, lngRecordID, " +
                            "strFirstName, strLastCoName, strAddress, strCity, strZip, strHomePhone, strCellPhone, strEmail, strPassword " +
                        "FROM tblWebRecords " +
                        "WHERE lngRecordWebID=" + lngProfileWebID.ToString();

                using (OleDbCommand cmdDB = new OleDbCommand(strSQL, conDB))
                {
                    using (OleDbDataReader drWeb = cmdDB.ExecuteReader())
                    {
                        if (drWeb.Read())
                        {
                            try { lngStateID = Convert.ToInt32(drWeb["lngStateID"]); }
                            catch { lngStateID = 0; }

                            try { lngProfileID = Convert.ToInt32(drWeb["lngRecordID"]); }
                            catch { lngProfileID = 0; }

                            try { strFName = Convert.ToString(drWeb["strFirstName"]); }
                            catch { strFName = ""; }

                            try { strLName = Convert.ToString(drWeb["strLastCoName"]); }
                            catch { strLName = ""; }

                            try { strAddress = Convert.ToString(drWeb["strAddress"]); }
                            catch { strAddress = ""; }

                            try { strCity = Convert.ToString(drWeb["strCity"]); }
                            catch { strCity = ""; }

                            try { strZip = Convert.ToString(drWeb["strZip"]); }
                            catch { strZip = ""; }

                            try { strPhone = Convert.ToString(drWeb["strHomePhone"]); }
                            catch { strPhone = ""; }

                            try { strCellPhone = Convert.ToString(drWeb["strCellPhone"]); }
                            catch { strCellPhone = ""; }

                            try { strEmail = Convert.ToString(drWeb["strEmail"]); }
                            catch { strEmail = ""; }
                            try{strPassword=Convert.ToString(drWeb["strPassword"]);}
                            catch{strPassword="";}
                        }

                        drWeb.Close();
                    }

                    clsIR irToSearch = new clsIR(0, lngStateID, strFName, strLName, "", strAddress, strCity, strZip, strPhone, "", strCellPhone, strEmail);

                    irToSearch.blnParent = true;
                    irToSearch.blnCamper = false;

                    irToSearch.lngRecordWebID = lngProfileWebID;
                    irToSearch.lngRecordID = lngProfileID;

                    irToSearch.lngStateID = lngStateID;

                    irToSearch.strEmail = strEmail;
                    irToSearch.strConfEmail = strEmail;
                    irToSearch.strHomePhone = strPhone;
                    irToSearch.strZip = strZip;
                    irToSearch.strCity = strCity;
                    irToSearch.strAddress = strAddress;
                    irToSearch.strLName = strLName;
                    irToSearch.strFName = strFName;

                    irToSearch.strCustom = fcnGetCustomValsWebIR(lngProfileWebID);

                    if (lngProfileID <= 0)
                    {
                        bool blnContinueToSearch = false;

                        if (_blnRequired)
                            blnContinueToSearch = true;
                        else
                        {
                            if (MessageBox.Show("The profile for this registration appears to be new.\nWould you like to match the profile to a record in CampTrak?\nIf an existing record is not found you will be prompted to create a new one.\n\nClick 'No' to register the camper but not link a record to their profile.", "Match Profile Record?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                blnContinueToSearch = true;
                            else
                                blnContinueToSearch = false;
                        }

                        if (blnContinueToSearch)
                        {
                            using (frmFindIR objFindIR = new frmFindIR(irToSearch, "Find parent record"))
                            {
                                if (objFindIR.ShowDialog() == DialogResult.OK)
                                {
                                    if (objFindIR.irToSearch.lngRecordID == 0)
                                        return lngProfileID;
                                    else
                                    {
                                        lngProfileID = objFindIR.irToSearch.lngRecordID;

                                        if (!objFindIR.blnAddNew)
                                        {
                                            using (IRUtils.frmReconcileIR objReconcileIR = new global::CTWebMgmt.IRUtils.frmReconcileIR("tblWebRecords", lngProfileID, lngProfileWebID))
                                            {
                                                if (objReconcileIR.ShowDialog() == DialogResult.Cancel)
                                                    return lngProfileID;
                                                else
                                                    lngProfileID = objReconcileIR.lngDBID;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (lngProfileID > 0) clsIRCRUD.subSetToSync(lngProfileID);
                                    return lngProfileID;
                                }
                            }

                            //now we've got local id (lngProfileID) and web id (lngProfileWebID)
                            //update web record w/ local id, and local record w/ web id

                            //'put web record id in tblRecords
                            strSQL = "UPDATE tblRecords " +
                                    "SET blnToSync=@blnToSync, "+
                                        "lngRecordWebID=" + lngProfileWebID.ToString() + ", "+
                                        "strPassword=@strPassword " +
                                    "WHERE lngRecordID=" + lngProfileID.ToString();

                            cmdDB.CommandText = strSQL;
                            cmdDB.Parameters.Clear();

                            cmdDB.Parameters.AddWithValue("@blnToSync", true);
                            cmdDB.Parameters.AddWithValue("@strPassword", strPassword);

                            try { cmdDB.ExecuteNonQuery(); }
                            catch { }

                            //put local ir id in tblWebRecords
                            strSQL = "UPDATE tblWebRecords " +
                                    "SET lngRecordID = " + lngProfileID.ToString() + " " +
                                    "WHERE lngRecordWebID=" + lngProfileWebID.ToString();

                            cmdDB.CommandText = strSQL;
                            cmdDB.Parameters.Clear();

                            try { cmdDB.ExecuteNonQuery(); }
                            catch { }
                        }
                    }
                }

                conDB.Close();
            }

            if (lngProfileID > 0)
            {
                clsIRCRUD.subSetToSync(lngProfileID);

                //post connected record id to web server
                //using (wsXferEventInfoV2.xfereventinfov2SoapClient svc = new global::CTWebMgmt.wsXferEventInfoV2.xfereventinfov2SoapClient("xfereventinfov2Soap"))
                using (wsXferEventInfoV2.xfereventinfov2 svc = new global::CTWebMgmt.wsXferEventInfoV2.xfereventinfov2())
                {
                    string strWebRes = "";

                    strWebRes = svc.fcnUpdateLocalID(lngProfileWebID, lngProfileID, clsAppSettings.GetAppSettings().lngCTUserID, clsAppSettings.GetAppSettings().strWebDBConn);

                    if (strWebRes != "") MessageBox.Show("There was an error updating the parent's web id: " + strWebRes);
                }
            }

            return lngProfileID;
        }
        private void btnUpdateToProcessed_Click(object sender, EventArgs e)
        {
            string strSQL = "";
            string strMsg = "";

            bool blnIssueRefund = false;

            DialogResult resRefund;

            strMsg = "Would you like to issue a refund for the payment?";

            resRefund = MessageBox.Show(strMsg, "Issue Refund?", MessageBoxButtons.YesNoCancel);

            if (resRefund == DialogResult.Yes)
                blnIssueRefund = true;
            else if (resRefund == DialogResult.Cancel)
                return;
            else
                blnIssueRefund = false;

            DateTime dteRegDate;

            try { dteRegDate = Convert.ToDateTime(txtRegDate.Text); }
            catch (Exception ex)
            {
                MessageBox.Show("There was a problem with the registration date: " + ex.Message + "\nThe current date will be used.");
                dteRegDate = DateTime.Now;
            }

            if (blnIssueRefund)
            {
                decimal decRefundAmt = 0;

                using (frmCollectRefundAmt objCollectRefundAmt = new frmCollectRefundAmt(lngRegWebID))
                {
                    if (objCollectRefundAmt.ShowDialog() == DialogResult.OK)
                    {
                        decRefundAmt = objCollectRefundAmt.decAmt;

                        if (decRefundAmt > 0)
                        {
                            if (clsAppSettings.GetAppSettings().lngLiveCharge == clsGlobalEnum.conLIVECHARGE.XCharge)
                            {
                                if (txtPmtType.Text == "EFT")
                                    clsLiveCharge.subProcessRefundXCEFT(decRefundAmt, lngRegWebID, txtAcctNum.Text, txtRoutingNum.Text, txtProfileName.Text, txtCamperAddress.Text, txtCamperZip.Text, (int)this.Handle, clsLiveCharge.fcnGetXChargePath());
                                else
                                    clsLiveCharge.subProcessRefundXCCC(decRefundAmt, txtXCTransID.Text, txtXCAlias.Text);
                            }
                            else if (clsAppSettings.GetAppSettings().lngLiveCharge == clsGlobalEnum.conLIVECHARGE.CashLinq)
                            {
                                if (txtPmtType.Text == "EFT")
                                    clsLiveCharge.subProcessRefundCashLinqEFT(decRefundAmt, lngRegWebID, txtAcctNum.Text, txtRoutingNum.Text, txtProfileName.Text, txtCamperAddress.Text, txtCamperZip.Text, (int)this.Handle);
                                else
                                    clsLiveCharge.subProcessRefundCashLinqCC(decRefundAmt, txtPNRef.Text);
                            }
                            else if (clsAppSettings.GetAppSettings().lngLiveCharge == clsGlobalEnum.conLIVECHARGE.EPS)
                            {
                                if (txtPmtType.Text == "EFT")
                                    clsLiveCharge.subProcessRefundEPSEFT(decRefundAmt);
                                else
                                    clsLiveCharge.subProcessRefundEPSCC(decRefundAmt, lngRegWebID, txtEPSTransID.Text);
                            }
                        }
                        else
                            return;
                    }
                    else
                        return;
                }

                strMsg = "Would you like to record the deposit and refund in CampTrak?";

                if (MessageBox.Show(strMsg, "Save in CampTrak?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    long lngStateID = 0;

                    try { lngStateID = ((clsCboItem)cboCamperState.SelectedItem).ID; }
                    catch { lngStateID = 0; }

                    clsIR irToSearch = new clsIR(0, lngStateID, txtCamperFName.Text, txtCamperLName.Text, "", txtCamperAddress.Text, txtCamperCity.Text, txtCamperZip.Text, txtCamperPhone.Text, "", txtCamperCellPhone.Text, txtCamperEMail.Text);

                    irToSearch.lngRecordWebID = lngRecordWebID;
                    irToSearch.lngRecordID = lngRecordID;

                    irToSearch.strConfEmail = txtProfileEmail.Text;

                    irToSearch.blnGender = radM.Checked;

                    //find record
                    using (frmFindIR objFindIR = new frmFindIR(irToSearch, "Find camper"))
                    {
                        if (objFindIR.ShowDialog() == DialogResult.OK)
                        {
                            if (objFindIR.irToSearch.lngRecordID == 0)
                                return;
                            else
                                lngRecordID = objFindIR.irToSearch.lngRecordID;
                        }
                    }

                    //add transactions
                    //////////////////////////////////////////////////////////////////////////
                    decimal decPmtAmt = 0;
                    decimal decSpending = 0;

                    try { decSpending = decimal.Parse(txtSpending.Text, System.Globalization.NumberStyles.Currency); }
                    catch { decSpending = 0; }

                    try { decPmtAmt = decimal.Parse(txtPmtAmt.Text, System.Globalization.NumberStyles.Currency); }
                    catch { decPmtAmt = 0; }

                    using (OleDbConnection conDB = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn))
                    {
                        conDB.Open();

                        //add payment
                        strSQL = "INSERT INTO tblTransactions " +
                                "(blnMarkedForCC, " +
                                    "lngPaymentTypeID, lngTransTypeID, lngRecordID, lngBillStateID, lngUserID, " +
                                    "curPayment, " +
                                    "dteDateAdded, " +
                                    "strTransactionDesc, strCCNumber, strCCExpDate, strCCValCode, strBillName, strBillAddress, strBillCity, strBillZip, strBillPhone, strBankName, strAcctNum, strRoutingNum, strPNRef, strEPSApprovalNumber, strEPSPmtAcctID, strEPSTransID, strEPSValidationCode) " +
                                "SELECT 1, " +
                                    "@lngPaymentTypeID, 8 AS lngTransTypeID, @lngRecordID, @lngBillStateID, @lngUserID, " +
                                    "@curPayment, " +
                                    "@dteDateAdded, " +
                                    "@strTransactionDesc, @strCCNumber, @strCCExpDate, @strCCValCode, @strBillName, @strBillAddress, @strBillCity, @strBillZip, @strBillPhone, @strBankName, @strAcctNum, @strRoutingNum, @strPNRef, @strEPSApprovalNumber, @strEPSPmtAcctID, @strEPSTransID, @strEPSValidationCode";

                        using (OleDbCommand cmdDB = new OleDbCommand(strSQL, conDB))
                        {
                            long lngPmtType = 0;

                            if (txtCardNumber.Text == "" && txtAcctNum.Text != "")
                                lngPmtType = 11;
                            else
                                lngPmtType = 2;

                            long lngBillStateID = 0;

                            try { lngBillStateID = ((clsCboItem)cboBillState.SelectedItem).ID; }
                            catch { lngBillStateID = 0; }

                            cmdDB.Parameters.Add(new OleDbParameter("@lngPaymentTypeID", lngPmtType));
                            cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngRecordID));
                            cmdDB.Parameters.Add(new OleDbParameter("@lngBillStateID", lngBillStateID));
                            cmdDB.Parameters.Add(new OleDbParameter("@lngUserID", CTWebMgmt.lngUserID));
                            cmdDB.Parameters.Add(new OleDbParameter("@curPayment", decPmtAmt));

                            cmdDB.Parameters.Add(new OleDbParameter("@dteDateAdded", dteRegDate));

                            cmdDB.Parameters.Add(new OleDbParameter("@strTransactionDesc", "Web Reg Tuition"));
                            cmdDB.Parameters.Add(new OleDbParameter("@strCCNumber", txtCardNumber.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strCCExpDate", txtExpDate.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strCCValCode", txtCVV2.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillName", txtBillName.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillAddress", txtBillAddress.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillCity", txtBillCity.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillZip", txtBillZip.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillPhone", txtBillPhone.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBankName", txtBankName.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strAcctNum", txtAcctNum.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strRoutingNum", txtRoutingNum.Text));

                            cmdDB.Parameters.Add(new OleDbParameter("@strPNRef", txtPNRef.Text));

                            cmdDB.Parameters.Add(new OleDbParameter("@strEPSApprovalNumber", txtEPSApprovalNumber.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strEPSPmtAcctID", txtEPSPmtAcctID.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strEPSTransID", txtEPSTransID.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strEPSValidationCode", txtEPSValidationCode.Text));

                            try { cmdDB.ExecuteNonQuery(); }
                            catch { }

                            //add spending money if amt > 0
                            if (decSpending > 0)
                            {
                                strSQL = "INSERT INTO tblTransactions " +
                                      "(blnMarkedForCC, " +
                                          "lngRecordID, lngTransTypeID, lngPaymentTypeID, lngBillStateID, lngUserID, " +
                                          "curPayment, " +
                                          "dteDateAdded, " +
                                          "strTransactionDesc, strCCNumber, strCCExpDate, strCCValCode, strBillName, strBillAddress, strBillCity, strBillZip, strBillPhone, strBankName, strAcctNum, strRoutingNum, strPNRef, strEPSApprovalNumber, strEPSPmtAcctID, strEPSTransID, strEPSValidationCode)" +
                                    "SELECT 1, " +
                                        "@lngRecordID, @lngTransTypeID, @lngPaymentTypeID, @lngBillStateID, @lngUserID, " +
                                        "@curPayment, " +
                                        "@dteDateAdded, " +
                                        "@strTransactionDesc, @strCCNumber, @strCCExpDate, @strCCValCode, @strBillName, @strBillAddress, @strBillCity, @strBillZip, @strBillPhone, @strBankName, @strAcctNum, @strRoutingNum, @strPNRef, @strEPSApprovalNumber, @strEPSPmtAcctID, @strEPSTransID, @strEPSValidationCode";

                                cmdDB.CommandText = strSQL;
                                cmdDB.Parameters.Clear();

                                cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngRecordID));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngTransTypeID", 25));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngPaymentTypeID", lngPmtType));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngBillStateID", lngBillStateID));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngUserID", CTWebMgmt.lngUserID));
                                cmdDB.Parameters.Add(new OleDbParameter("@curPayment", decSpending));

                                cmdDB.Parameters.Add(new OleDbParameter("@dteDateAdded", dteRegDate));

                                cmdDB.Parameters.Add(new OleDbParameter("@strTransactionDesc", "Web Reg Spending Money"));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCNumber", txtCardNumber.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCExpDate", txtExpDate.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCValCode", txtCVV2.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillName", txtBillName.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillAddress", txtBillAddress.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillCity", txtBillCity.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillZip", txtBillZip.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillPhone", txtBillPhone.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBankName", txtBankName.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strAcctNum", txtAcctNum.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strRoutingNum", txtRoutingNum.Text));

                                cmdDB.Parameters.Add(new OleDbParameter("@strPNRef", txtPNRef.Text));

                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSApprovalNumber", txtEPSApprovalNumber.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSPmtAcctID", txtEPSPmtAcctID.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSTransID", txtEPSTransID.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSValidationCode", txtEPSValidationCode.Text));

                                cmdDB.Parameters.Add(new OleDbParameter("@strEPSTransactionID", txtEPSTransID.Text));

                                try { cmdDB.ExecuteNonQuery(); }
                                catch { }
                            }

                            //add donation if required
                            decimal decDonation = 0;

                            try { decDonation = decimal.Parse(txtDonation.Text, System.Globalization.NumberStyles.Currency); }
                            catch { decDonation = 0; }

                            if (decDonation > 0)
                            {
                                long lngGiftCategory = 0;
                                long lngCampaign = 0;
                                long lngTrigger = 0;

                                strSQL = "SELECT lngOLGiftCategoryID, lngOLGiftCampaign, lngOLTriggerID " +
                                        "FROM tblCampDefaults";

                                cmdDB.CommandText = strSQL;
                                cmdDB.Parameters.Clear();

                                using (OleDbDataReader drDef = cmdDB.ExecuteReader())
                                {
                                    if (drDef.Read())
                                    {
                                        try { lngGiftCategory = Convert.ToInt32(drDef["lngOLGiftCategoryID"]); }
                                        catch { lngGiftCategory = 0; }

                                        try { lngCampaign = Convert.ToInt32(drDef["lngOLGiftCampaign"]); }
                                        catch { lngCampaign = 0; }

                                        try { lngTrigger = Convert.ToInt32(drDef["lngOLTriggerID"]); }
                                        catch { lngTrigger = 0; }
                                    }

                                    drDef.Close();
                                }

                                strSQL = "INSERT INTO tblGift " +
                                        "(lngGiftCategoryID, lngRecordID, lngCampaignID, lngGiftTypeID, lngTriggerID, lngPaymentTypeID, lngBillStateID, " +
                                            "dteGiftDate, dteDateEntered, " +
                                            "curAmount, " +
                                            "strAcctNum, strBankName, strBillAddress, strBillCity, strBillName, strBillPhone, strBillZip, strCCExpDate, strCCNumber, strCCValCode, strRoutingNum, " +
                                            "mmoNotes) " +
                                        "SELECT @lngGiftCategoryID, @lngRecordID, @lngCampaignID, @lngGiftTypeID, @lngTriggerID, @lngPaymentTypeID, @lngBillStateID, " +
                                            "@dteGiftDate, @dteDateEntered, " +
                                            "@curAmount, " +
                                            "@strAcctNum, @strBankName, @strBillAddress, @strBillCity, @strBillName, @strBillPhone, @strBillZip, @strCCExpDate, @strCCNumber, @strCCValCode, @strRoutingNum, " +
                                            "@mmoNotes";

                                cmdDB.CommandText = strSQL;
                                cmdDB.Parameters.Clear();

                                try { lngBillStateID = ((clsCboItem)cboBillState.SelectedItem).ID; }
                                catch { lngBillStateID = 0; }

                                cmdDB.Parameters.Add(new OleDbParameter("@lngGiftCategoryID", lngGiftCategory));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngRecordID));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngCampaignID", lngCampaign));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngGiftTypeID", 1));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngTriggerID", lngTrigger));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngPaymentTypeID", lngPmtType));
                                cmdDB.Parameters.Add(new OleDbParameter("@lngBillStateID", lngBillStateID));

                                cmdDB.Parameters.Add(new OleDbParameter("@dteGiftDate", dteRegDate));
                                cmdDB.Parameters.Add(new OleDbParameter("@dteDateEntered", OleDbType.Date));

                                try { cmdDB.Parameters["@dteDateEntered"].Value = DateTime.Now; }
                                catch (Exception ex) { MessageBox.Show("There was an error setting the 'DateEntered' field: " + ex.Message); }

                                cmdDB.Parameters.Add(new OleDbParameter("@curAmount", decDonation));
                                cmdDB.Parameters.Add(new OleDbParameter("@strAcctNum", txtAcctNum.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBankName", txtBankName.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillAddress", txtBillAddress.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillCity", txtBillCity.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillName", txtBillName.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillPhone", txtBillPhone.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strBillZip", txtBillZip.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCExpDate", txtExpDate.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCNumber", txtCardNumberUnmasked.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strCCValCode", txtCVV2.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@strRoutingNum", txtRoutingNum.Text));
                                cmdDB.Parameters.Add(new OleDbParameter("@mmoNotes", "Online Donation"));

                                try { cmdDB.ExecuteNonQuery(); }
                                catch { }

                                //mark record as donor
                                strSQL = "UPDATE tblRecords " +
                                        "SET blnDonor = True " +
                                        "WHERE lngRecordID=" + lngRecordID;

                                cmdDB.CommandText = strSQL;
                                cmdDB.Parameters.Clear();

                                try { cmdDB.ExecuteNonQuery(); }
                                catch { }
                            }//</donation

                            //add refund record
                            strSQL = "INSERT INTO tblTransactions " +
                                    "(blnMarkedForCC, " +
                                        "lngTransTypeID, lngTransSubTypeID, lngBillStateID, lngRecordID, lngUserID, " +
                                        "curCharge, " +
                                        "dteDateAdded, " +
                                        "strBillName, strBillAddress, strBillCity, strBillZip, strBillPhone, strCCNumber, strCCExpDate, strTransactionDesc) " +
                                    "VALUES " +
                                    "(1, " +
                                        "4, 0, @lngBillStateID, @lngRecordID, @lngUserID, " +
                                        "@curCharge, " +
                                        "@dteDateAdded, " +
                                        "@strBillName, @strBillAddress, @strBillCity, @strBillZip, @strBillPhone, @strCCNumber, @strCCExpDate, \"Refund for online registration\")";

                            cmdDB.CommandText = strSQL;
                            cmdDB.Parameters.Clear();

                            cmdDB.Parameters.Add(new OleDbParameter("@lngBillStateID", lngBillStateID));
                            cmdDB.Parameters.Add(new OleDbParameter("@lngRecordID", lngRecordID));
                            cmdDB.Parameters.Add(new OleDbParameter("@lngUserID", CTWebMgmt.lngCTUserID));
                            cmdDB.Parameters.Add(new OleDbParameter("@curCharge", decRefundAmt));

                            cmdDB.Parameters.Add(new OleDbParameter("@dteDateAdded", dteRegDate));

                            cmdDB.Parameters.Add(new OleDbParameter("@strBillName", txtBillName.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillAddress", txtBillAddress.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillCity", txtBillCity.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillZip", txtBillZip.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strBillPhone", txtBillPhone.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strCCNumber", txtCardNumber.Text));
                            cmdDB.Parameters.Add(new OleDbParameter("@strCCExpDate", txtExpDate.Text));

                            try { cmdDB.ExecuteNonQuery(); }
                            catch { }

                        }//</command>

                        conDB.Close();
                    }//</connection>
                }//</save in ct>
            }//</issue refund>

            using (OleDbConnection conDB = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn))
            {
                conDB.Open();

                strSQL = "UPDATE tblWebIndRegistrations " +
                        "SET blnProcessed=True " +
                        "WHERE lngRegistrationWebID=" + lngRegWebID;

                using (OleDbCommand cmdDB = new OleDbCommand(strSQL, conDB))
                    cmdDB.ExecuteNonQuery();

                conDB.Close();
            }

            Close();
        }
Beispiel #9
0
        public static long fcnGetWebRegIR(frmGGCCRegDetails _objGGCCRegDetails)
        {
            //match existing or add new ir for received ggccregweb id.
            //return matched or new ir id.
            long lngRes = 0;

            try
            {
                long lngStateID = 0;

                try { lngStateID = ((clsCboItem)_objGGCCRegDetails.cboState.SelectedItem).ID; }
                catch { lngStateID = 0; }

                clsIR irToSearch = new clsIR(0, lngStateID, _objGGCCRegDetails.txtFName.Text, _objGGCCRegDetails.txtLName.Text, _objGGCCRegDetails.txtCompanyName.Text, _objGGCCRegDetails.txtAddress.Text, _objGGCCRegDetails.txtCity.Text, _objGGCCRegDetails.txtZip.Text, _objGGCCRegDetails.txtHomePhone.Text, _objGGCCRegDetails.txtWorkPhone.Text, _objGGCCRegDetails.txtCellPhone.Text, _objGGCCRegDetails.txtEMail.Text);

                //fill in ir details to pass to search screen
                irToSearch.blnGender = true;

                irToSearch.lngRecordWebID = _objGGCCRegDetails.lngRecordWebID;
                irToSearch.lngRecordID = _objGGCCRegDetails.lngRecordID;

                irToSearch.strEmail = _objGGCCRegDetails.txtEMail.Text;
                irToSearch.strHomePhone = _objGGCCRegDetails.txtHomePhone.Text;
                irToSearch.strCellPhone = _objGGCCRegDetails.txtCellPhone.Text;
                irToSearch.strZip = _objGGCCRegDetails.txtZip.Text;
                irToSearch.strCity = _objGGCCRegDetails.txtCity.Text;
                irToSearch.strAddress = _objGGCCRegDetails.txtAddress.Text;
                irToSearch.strLName = _objGGCCRegDetails.txtLName.Text;
                irToSearch.strFName = _objGGCCRegDetails.txtFName.Text;

                using (frmFindIR objFindIR = new frmFindIR(irToSearch, "Find camper record"))
                {
                    if (objFindIR.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        if (objFindIR.irToSearch.lngRecordID == 0)
                            return 0;
                        else
                        {
                            lngRes = objFindIR.irToSearch.lngRecordID;

                            if (!objFindIR.blnAddNew)
                            {
                                using (IRUtils.frmReconcileIR objReconcileIR = new global::CTWebMgmt.IRUtils.frmReconcileIR("tblWebRecordsGGCCReg", _objGGCCRegDetails.lngRecordID, _objGGCCRegDetails.lngRecordWebID))
                                {
                                    if (objReconcileIR.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                                        return 0;
                                    else
                                        _objGGCCRegDetails.lngRecordID = objReconcileIR.lngDBID;
                                }
                            }
                        }
                    }
                    else
                        return 0;
                }

                if (lngRes > 0)
                {
                    string strSQL = "";

                    using (OleDbConnection conDB = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn))
                    {
                        conDB.Open();

                        strSQL = "UPDATE tblRecords " +
                                "SET blnCamper=-1 " +
                                "WHERE lngRecordID=" + lngRes.ToString();

                        using (OleDbCommand cmdDB = new OleDbCommand(strSQL, conDB))
                        {
                            try { cmdDB.ExecuteNonQuery(); }
                            catch { }
                        }

                        conDB.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                clsErr.subLogErr("fcnGetWebRegIR", ex);
            }

            return lngRes;
        }
        private void btnAddGift_Click(object sender, EventArgs e)
        {
            string strSQL = "";

            long lngGiftID = 0;

            //validate
            if (cboCampaign.SelectedIndex < 0)
            {
                MessageBox.Show("Please select a campaign for the gift.");
                tabGiftDetails.SelectedTab = pagGiftInfo;
                cboCampaign.Focus();
                return;
            }

            if (cboGiftCategory.SelectedIndex < 0)
            {
                MessageBox.Show("Please select a category for the gift.");
                tabGiftDetails.SelectedTab = pagGiftInfo;
                cboGiftCategory.Focus();
                return;
            }

            long lngRecordID = 0;

            //'if there are no eligible matches, go directly to add new.
            //'show list of possible matches
            long lngStateID = 0;

            try { lngStateID = clsIRCRUD.fcnGetStateIDFromAbbr(txtState.Text); }
            catch { lngStateID = 0; }

            clsIR irToSearch = new clsIR(0, lngStateID, txtFName.Text, txtLName.Text, "", txtAddress.Text, txtCity.Text, txtZip.Text, txtHomePhone.Text, "", "", txtEMail.Text);

            try { irToSearch.lngStateID = lngStateID; }
            catch { irToSearch.lngStateID = 0; }

            try { irToSearch.lngBillStateID = lngStateID; }
            catch { irToSearch.lngBillStateID = 0; }

            irToSearch.strEmail = txtEMail.Text;
            irToSearch.strHomePhone =txtHomePhone.Text;
            irToSearch.strZip =txtZip.Text;
            irToSearch.strCity =txtCity.Text;
            irToSearch.strAddress =txtAddress.Text;
            irToSearch.strLName =txtLName.Text;
            irToSearch.strFName =txtFName.Text;

            try { irToSearch.strPmtType = ((clsCboItem)cboPaymentType.SelectedItem).Item; }
            catch { irToSearch.strPmtType = "CC"; }

            irToSearch.strSpecialNeeds = "";
            irToSearch.strBankName = txtBankName.Text;
            irToSearch.strBillName = txtFName.Text + " " + txtLName.Text;
            irToSearch.strBillAddress =txtAddress.Text;
            irToSearch.strBillCity =txtCity.Text;
            irToSearch.strBillZip =txtZip.Text;
            irToSearch.strBillPhone =txtHomePhone.Text;

            using (frmFindIR objFindIR = new frmFindIR(irToSearch, "Find donor record"))
            {
                if (objFindIR.ShowDialog() == DialogResult.OK)
                {
                    if (objFindIR.irToSearch.lngRecordID == 0)
                        return;
                    else
                    {
                        lngRecordID = objFindIR.irToSearch.lngRecordID;
                        clsIRCRUD.subSetToSync(lngRecordID);

                        using (IRUtils.frmReconcileIR objReconcileIR = new global::CTWebMgmt.IRUtils.frmReconcileIR("tblDonorExpress", lngRecordID, lngDonorExpressID))
                        {
                            if (objReconcileIR.ShowDialog() == DialogResult.Cancel)
                                return;
                            else
                                lngRecordID = objReconcileIR.lngDBID;
                        }
                    }
                }
                else
                    return;
            }
            /////////////////////////////////////////////////////////////////
            if (lngRecordID > 0)
            {
                subMarkIRAsDonor(lngRecordID, (txtFName.Text + " " + txtLName.Text).Replace("  ", " "), "");

                long lngCampaignID = 0;
                long lngPaymentTypeID = 0;
                long lngBillStateID = 0;

                try { lngCampaignID = ((clsCboItem)cboCampaign.SelectedItem).ID; }
                catch { lngCampaignID = 0; }

                try { lngPaymentTypeID = ((clsCboItem)cboPaymentType.SelectedItem).ID; }
                catch { lngPaymentTypeID = 2; }

                //add gift
                lngGiftID = clsDonorCRUD.fcnAddGift(chkMemorial.Checked, chkInHonorOf.Checked, ((clsCboItem)cboGiftCategory.SelectedItem).ID, lngRecordID, lngCampaignID, lngPaymentTypeID, lngBillStateID, 0, lngDonorExpressID, decimal.Parse(txtAmount.Text), DateTime.Parse(txtGiftDate.Text), txtMemorial.Text, txtInHonorOf.Text, txtAcctNum.Text, txtBankName.Text, txtAddress.Text, txtCity.Text, txtFName.Text + " " + txtLName.Text, txtHomePhone.Text, txtZip.Text, txtExpDate.Text, txtCCNumberUnMasked.Text, txtCVV2.Text, txtRoutingNum.Text, txtAuthNum.Text, txtPNRef.Text, txtXCAlias.Text, txtXCTransID.Text, txtEPSTransID.Text, txtEPSApprovalNumber.Text, txtEPSValidationCode.Text, txtEPSPmtAcctID.Text);

                //update billing info (this gives pnref for future transactions)
                clsIRCRUD.subUpdateBillingInfoCC(lngRecordID, txtPNRef.Text, txtCCNumberUnMasked.Text, txtXCAlias.Text, txtEPSPmtAcctID.Text);

                using (OleDbConnection conDB = new OleDbConnection(clsAppSettings.GetAppSettings().strCTConn))
                {
                    conDB.Open();

                    //mark gift processed
                    strSQL = "UPDATE tblDonorExpress " +
                            "SET blnProcessed=-1 " +
                            "WHERE lngDonorExpressID=" + lngDonorExpressID.ToString();

                    using (OleDbCommand cmdDB = new OleDbCommand(strSQL, conDB))
                    {
                        cmdDB.ExecuteNonQuery();
                    }

                    conDB.Close();
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }