Beispiel #1
0
        public string ToString(string format, IFormatProvider formatProvider)
        {
            if (string.IsNullOrWhiteSpace(format))
            {
                format = "G";
            }

            switch (format)
            {
            case "P":
                return(Price.ToString());

            case "C":
                return(Class.ToString());

            case "D":
                return(ValidityDate.ToString());

            case "G":
                return($"Class: {Class}, valid until: {ValidityDate}");

            default:
                throw new FormatException("Format specified was invalid.");
            }
        }
Beispiel #2
0
        private bool isValuesAssigned()
        {
            decimal mdecAmount = 0;

            try
            {
                mdecAmount = Convert.ToDecimal(txtAmount.Text);
            }
            catch
            {
                txtAmount.Focus();
                MessageBox.Show("Sorry you have entered an invalid amount for credit card payment." +
                                "Please type a valid credit amount.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (txtCardNo.Text == null || txtCardNo.Text == "")
            {
                txtCardNo.Focus();
                MessageBox.Show("Please type a valid Card No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (txtCardHolder.Text == null || txtCardHolder.Text == "")
            {
                txtCardHolder.Focus();
                MessageBox.Show("Please type a valid Card Holder.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            DateTime ValidityDate = DateTime.MinValue;

            if (txtValidityDates.Text == null || txtValidityDates.Text == "")
            {
                txtValidityDates.Focus();
                MessageBox.Show("Please type a valid Validity Date.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            else if (txtValidityDates.Text != null && txtValidityDates.Text != "")
            {
                try
                {
                    string Month = txtValidityDates.Text.Substring(0, 2);
                    string Year  = "20" + txtValidityDates.Text.Substring(2, 2);
                    string Day   = DateTime.DaysInMonth(Convert.ToInt32(Year), Convert.ToInt32(Month)).ToString();
                    ValidityDate = new DateTime(int.Parse(Year), int.Parse(Month), int.Parse(Day));
                }
                catch
                {
                    txtValidityDates.Focus();
                    MessageBox.Show("Please type a valid Validity Date. Format must be mmyy", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                if (ValidityDate < DateTime.Now)
                {
                    txtValidityDates.Focus();
                    MessageBox.Show("Card has been expired, please ask for a valid credit card.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }


            Data.CardType        clsCardType     = new Data.CardType();
            Data.CardTypeDetails cardtypedetails = clsCardType.Details(cboCardType.Text);
            clsCardType.CommitAndDispose();

            mDetails.BranchDetails = mclsTerminalDetails.BranchDetails;
            mDetails.TerminalNo    = mclsTerminalDetails.TerminalNo;
            mDetails.TransactionID = mclsSalesTransactionDetails.TransactionID;
            mDetails.TransactionNo = mclsSalesTransactionDetails.TransactionNo;
            mDetails.Amount        = mdecAmount;
            mDetails.CardTypeID    = cardtypedetails.CardTypeID;
            mDetails.CardTypeCode  = cardtypedetails.CardTypeCode;
            mDetails.CardTypeName  = cardtypedetails.CardTypeName;
            mDetails.CardNo        = txtCardNo.Text;
            mDetails.CardHolder    = txtCardHolder.Text;
            mDetails.ValidityDates = ValidityDate.ToString("MMddyy");
            mDetails.Remarks       = txtRemarks.Text;

            return(true);
        }