Example #1
0
        /// <summary>
        /// Method to get tax exemption reasons
        /// </summary>
        /// <param name="reasonType">Reason type</param>
        /// <returns>Tax exemption reasons</returns>
        public List <TaxExemptReason> GetTaxExemptReasons(string reasonType)
        {
            var reasons  = new List <TaxExemptReason>();
            var rsReason = GetRecords("select * from TaxExemptReasons Where ReasonType=\'" + reasonType + "\'", DataSource.CSCMaster);

            foreach (DataRow fields in rsReason.Rows)
            {
                var ter = new TaxExemptReason
                {
                    Code            = CommonUtility.GetStringValue(fields["ReasonCode"]),
                    Description     = CommonUtility.GetStringValue(fields["ReasonDescription"]),
                    ExplanationCode = CommonUtility.GetShortValue(fields["ExplanationCode"]),
                    Explanation     =
                        string.IsNullOrEmpty(CommonUtility.GetStringValue(fields["Explanation"]))
                            ? "0"
                            : CommonUtility.GetStringValue(fields["Explanation"])
                };
                reasons.Add(ter);
            }
            return(reasons);
        }
        /// <summary>
        /// Methd to verify if valid explaination
        /// </summary>
        /// <param name="oTeSale">Tax exempt sale</param>
        /// <param name="productType">Product type</param>
        /// <param name="cobReason">Reason</param>
        /// <param name="txtExplanation">Explaination</param>
        /// <param name="txtLocation">Location</param>
        /// <param name="dtpDate">Date</param>
        /// <returns>True or false</returns>
        private bool ValidExplanation(ref TaxExemptSale oTeSale, byte productType, string cobReason, string txtExplanation, string txtLocation, DateTime dtpDate)
        {
            bool returnValue = false;


            TaxExemptReason  ter  = default(TaxExemptReason);
            TaxExemptReasons ters = default(TaxExemptReasons);

            bool   fndReason       = false;
            string strReason       = "";
            string strReasonDesp   = "";
            string strReasonDetail = "";

            string   cobBox  = string.Empty;
            string   expBox  = string.Empty;
            string   locBox  = string.Empty;
            DateTime dateBox = DateTime.Now;

            if (string.IsNullOrEmpty(txtExplanation))
            {
                txtExplanation = String.Empty;
            }
            if (string.IsNullOrEmpty(locBox))
            {
                locBox = String.Empty;
            }

            if (productType != (byte)TeProductType.Tobacco & productType != (byte)TeProductType.Gas & productType != (byte)TeProductType.Propane)
            {
                return(false);
            }


            if (productType == (byte)TeProductType.Tobacco)
            {
                ters    = mPrivateGlobals.theSystem.TobaccoReasons;
                cobBox  = cobReason;
                expBox  = txtExplanation;
                locBox  = txtLocation;
                dateBox = dtpDate;
            }
            else if (productType == (byte)TeProductType.Gas)
            {
                ters    = mPrivateGlobals.theSystem.GasReasons;
                cobBox  = cobReason;
                expBox  = txtExplanation;
                locBox  = txtLocation;
                dateBox = dtpDate;
            }
            else if (productType == (byte)TeProductType.Propane)
            {
                ters    = mPrivateGlobals.theSystem.PropaneReasons;
                cobBox  = cobReason;
                expBox  = txtExplanation;
                locBox  = txtLocation;
                dateBox = dtpDate;
            }


            if (ters != null)
            {
                foreach (TaxExemptReason tempLoopVarTer in ters)
                {
                    ter = tempLoopVarTer;
                    if (cobBox == ter.Code + "-" + ter.Description)
                    {
                        fndReason = true;
                        break;
                    }
                }
            }

            if (fndReason)
            {
                switch (ter.ExplanationCode)
                {
                case 0:
                    returnValue     = true;
                    strReason       = ter.Code;
                    strReasonDesp   = ter.Description;
                    strReasonDetail = expBox.Trim();
                    break;

                case 1:
                case 2:
                    if (expBox.Trim() == "")
                    {
                        returnValue = false;
                    }
                    else
                    {
                        returnValue     = true;
                        strReason       = ter.Code;
                        strReasonDesp   = ter.Description;
                        strReasonDetail = expBox.Trim();
                    }
                    break;

                case 3:
                    if (string.IsNullOrEmpty(locBox))
                    {
                        returnValue = false;
                    }
                    else
                    {
                        returnValue   = true;
                        strReason     = ter.Code;
                        strReasonDesp = ter.Description;

                        strReasonDetail = dateBox.ToString("MM/dd/yyyy") + "####" + locBox.Trim();
                    }
                    break;
                }
            }

            if (productType == (byte)TeProductType.Tobacco)
            {
                oTeSale.TobaccoReason       = strReason;
                oTeSale.TobaccoReasonDesp   = strReasonDesp;
                oTeSale.TobaccoReasonDetail = strReasonDetail;
            }
            else if (productType == (byte)TeProductType.Gas)
            {
                oTeSale.GasReason       = strReason;
                oTeSale.GasReasonDesp   = strReasonDesp;
                oTeSale.GasReasonDetail = strReasonDetail;
            }
            else if (productType == (byte)TeProductType.Propane)
            {
                oTeSale.PropaneReason       = strReason;
                oTeSale.PropaneReasonDesp   = strReasonDesp;
                oTeSale.PropaneReasonDetail = strReasonDetail;
            }
            return(returnValue);
        }