Example #1
0
        private void LoadRecord()
        {
            lblHeader.Text = mstHeader + " for customer : " + mContactDetails.ContactName;
            if ((CardTypeDetails.WithGuarantor) || (Guarantor.ContactID != 0 && Guarantor.ContactID != mContactDetails.ContactID)) lblHeader.Text += " --- Guarantor: " + Guarantor.ContactName + (Guarantor.CreditDetails.ExpiryDate == DateTime.MinValue ? "" : " [Expiry:" + Guarantor.CreditDetails.ExpiryDate.ToString("yyyy-MM-dd") + "]");

            txtCreditCardNo.Text = mContactDetails.ContactCode;

            //if ((CardTypeDetails.WithGuarantor) || (Guarantor.ContactID != 0 && Guarantor.ContactID != mContactDetails.ContactID))
            if (CardTypeDetails.WithGuarantor)
                if (Guarantor.CreditDetails.ExpiryDate.AddMonths(6) <= DateTime.Now)
                    txtCreditCardExpiryDate.Text = (new DateTime(DateTime.Now.AddYears(2).Year, DateTime.Now.AddYears(2).Month, DateTime.DaysInMonth(DateTime.Now.AddYears(2).Year, DateTime.Now.AddYears(2).Month))).ToString("yyyy-MM-dd");
                else
                    txtCreditCardExpiryDate.Text = Guarantor.CreditDetails.ExpiryDate.ToString("yyyy-MM-dd");
            else
                txtCreditCardExpiryDate.Text = (new DateTime(DateTime.Now.AddYears(1).Year, DateTime.Now.AddYears(1).Month, DateTime.DaysInMonth(DateTime.Now.AddYears(1).Year, DateTime.Now.AddYears(1).Month))).ToString("yyyy-MM-dd");

            txtCreditLimit.Text = mContactDetails.CreditLimit.ToString("#,##0.#0");
            txtRemarks.Text = mContactDetails.Remarks;

            switch (mCreditCardStatus)
            {
                case CreditCardStatus.New:
                    txtCreditCardNo.Text = "WILL BE ASSIGNED AFTER SAVING";
                    break;
                case CreditCardStatus.Lost:
                case CreditCardStatus.Expired:
                case CreditCardStatus.Replaced_Lost:
                case CreditCardStatus.Replaced_Expired:
                case CreditCardStatus.Reactivated_Lost:
                case CreditCardStatus.ManualDeactivated:
                case CreditCardStatus.Suspended:
                    txtCreditCardNo.Text = mContactDetails.CreditDetails.CreditCardNo;
                    txtCreditCardExpiryDate.Text = mContactDetails.CreditDetails.ExpiryDate.ToString("yyyy-MM-dd");
                    break;
                case CreditCardStatus.ReNew:
                    txtCreditCardNo.Text = mContactDetails.CreditDetails.CreditCardNo;
                    break;
                default:
                    txtCreditCardNo.Text = "WILL BE ASSIGNED AFTER SAVING";
                    break;
            }

            Data.ContactCreditCardInfos clsContactCreditCardInfos = new Data.ContactCreditCardInfos();
            Data.ContactCreditCardInfoDetails clsContactCreditDetails = clsContactCreditCardInfos.Details(mContactDetails.ContactID);
            
            clsContactCreditCardInfos.CommitAndDispose();

            if (mCreditCardStatus == CreditCardStatus.New && clsContactCreditDetails.CustomerID != Constants.ZERO)
            {
                txtCreditCardExpiryDate.Enabled = false; this.Refresh(); txtCreditCardNo.Focus();
                MessageBox.Show("Credit Card No: " + clsContactCreditDetails.CreditCardNo + " was already issued last " + clsContactCreditDetails.CreditAwardDate.ToString("MMM dd, yyyy") + " to " + mContactDetails.ContactName + "." +
                                Environment.NewLine + "Please select another customer.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (mCreditCardStatus == CreditCardStatus.Lost || mCreditCardStatus == CreditCardStatus.Expired || mCreditCardStatus == CreditCardStatus.Suspended)
            {
                txtCreditCardExpiryDate.Enabled = false; this.Refresh(); txtCreditCardNo.Focus();
            }
            else if (mCreditCardStatus == CreditCardStatus.Replaced_Lost || mCreditCardStatus == CreditCardStatus.Replaced_Expired)
            {
                txtCreditCardExpiryDate.Enabled = true; txtCreditCardExpiryDate.Focus();
            }
            else if (mCreditCardStatus == CreditCardStatus.ReNew)
            {
                txtCreditCardExpiryDate.Enabled = true; txtCreditCardExpiryDate.Focus();
            }
            else if (mCreditCardStatus == CreditCardStatus.Reactivated_Lost)
            {
                txtCreditCardNo.Enabled = true; txtCreditCardExpiryDate.Enabled = true; txtCreditLimit.Enabled = true; txtCreditCardNo.Focus();
            }
        }
Example #2
0
        private void LoadRecord()
        {
            lblHeader.Text = mstHeader + " for customer : " + mContactDetails.ContactName;
            if (Guarantor.ContactID != 0 && Guarantor.ContactID != mContactDetails.ContactID)
            {
                lblHeader.Text += " --- Guarantor: " + Guarantor.ContactName;
            }

            txtCreditCardNo.Text         = mContactDetails.ContactCode;
            txtCreditCardExpiryDate.Text = DateTime.Now.AddYears(1).ToString("yyyy-MM-dd");
            txtCreditLimit.Text          = mContactDetails.CreditLimit.ToString("#,##0.#0");

            switch (mCreditCardStatus)
            {
            case CreditCardStatus.New:
                txtCreditCardNo.Text = "WILL BE ASSIGNED AFTER SAVING";
                break;

            case CreditCardStatus.Lost:
            case CreditCardStatus.Expired:
            case CreditCardStatus.Replaced_Lost:
            case CreditCardStatus.Replaced_Expired:
            case CreditCardStatus.ReNew:
            case CreditCardStatus.Reactivated_Lost:
            case CreditCardStatus.ManualDeactivated:
                txtCreditCardNo.Text = mContactDetails.CreditDetails.CreditCardNo;
                break;

            default:
                txtCreditCardNo.Text = "WILL BE ASSIGNED AFTER SAVING";
                break;
            }

            Data.ContactCreditCardInfos       clsContactCreditCardInfos = new Data.ContactCreditCardInfos();
            Data.ContactCreditCardInfoDetails clsContactCreditDetails   = clsContactCreditCardInfos.Details(mContactDetails.ContactID);

            clsContactCreditCardInfos.CommitAndDispose();

            if (mCreditCardStatus == CreditCardStatus.New && clsContactCreditDetails.CustomerID != Constants.ZERO)
            {
                txtCreditCardExpiryDate.Enabled = false; this.Refresh(); txtCreditCardNo.Focus();
                MessageBox.Show("Credit Card No: " + clsContactCreditDetails.CreditCardNo + " was already issued last " + clsContactCreditDetails.CreditAwardDate.ToString("MMM dd, yyyy") + " to " + mContactDetails.ContactName + "." +
                                Environment.NewLine + "Please select another customer.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (mCreditCardStatus == CreditCardStatus.Lost || mCreditCardStatus == CreditCardStatus.Expired)
            {
                txtCreditCardExpiryDate.Enabled = false; this.Refresh(); txtCreditCardNo.Focus();
            }
            else if (mCreditCardStatus == CreditCardStatus.Replaced_Lost || mCreditCardStatus == CreditCardStatus.Replaced_Expired)
            {
                txtCreditCardExpiryDate.Enabled = true; txtCreditCardExpiryDate.Focus();
            }
            else if (mCreditCardStatus == CreditCardStatus.ReNew)
            {
                txtCreditCardExpiryDate.Enabled = true; txtCreditCardExpiryDate.Focus();
            }
            else if (mCreditCardStatus == CreditCardStatus.Reactivated_Lost)
            {
                txtCreditCardNo.Enabled = true; txtCreditCardExpiryDate.Enabled = true; txtCreditLimit.Enabled = true; txtCreditCardNo.Focus();
            }
        }
Example #3
0
		private bool SaveRecord()
		{
            bool boRetValue = false;

            if (string.IsNullOrEmpty(txtCreditCardNo.Text.Trim()))
            {
                MessageBox.Show("Sorry please enter a valid credit card no.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return boRetValue;
            }
            DateTime dteExpiryDate = DateTime.MinValue;
            try { dteExpiryDate = DateTime.Parse(txtCreditCardExpiryDate.Text); }
            catch
            {
                MessageBox.Show("Please enter a valid expiry date in the ff format: YYYY-MM-dd ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return boRetValue;
            }
            decimal decCreditLimit = 0;
            try { decCreditLimit = decimal.Parse(txtCreditLimit.Text); }
            catch
            {
                MessageBox.Show("Please enter a valid credit limit amount.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return boRetValue;
            }

            if (mCreditCardStatus == CreditCardStatus.New)
            {
                if (MessageBox.Show("Are you sure you want to issue a new credit card to " + mContactDetails.ContactName + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                { return boRetValue; }
            }
            else if (mCreditCardStatus == CreditCardStatus.Lost || mCreditCardStatus == CreditCardStatus.Expired || mCreditCardStatus == RetailPlus.CreditCardStatus.Suspended)
            {
                if (MessageBox.Show("Are you sure you want to declare card no: " + txtCreditCardNo.Text + " as " + mCreditCardStatus.ToString("G") + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                { return boRetValue; }
            }
            else if (mCreditCardStatus == CreditCardStatus.Replaced_Lost || mCreditCardStatus == CreditCardStatus.Replaced_Expired)
            {
                if (MessageBox.Show("Are you sure you want to replace existing credit card w/ new card no?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                { return boRetValue; }
            }
            else if (mCreditCardStatus == CreditCardStatus.Reactivated_Lost)
            {
                if (MessageBox.Show("Are you sure you want to reactivate existing credit card no: " + txtCreditCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                { return boRetValue; }
            }
            else if (mCreditCardStatus == CreditCardStatus.ReNew)
            {
                if (MessageBox.Show("Are you sure you want to renew card no: " + txtCreditCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                { return boRetValue; }

                if (dteExpiryDate < DateTime.Now)
                {
                    MessageBox.Show("Expiry date must not be less than date today. Please enter a valid expiry date. ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return boRetValue;
                }
            }

            Data.ContactCreditCardInfos clsContactCreditCardInfos = new Data.ContactCreditCardInfos();
            Data.ContactCreditCardInfoDetails clsContactCreditCardInfoDetails = clsContactCreditCardInfos.Details(mContactDetails.ContactID);
            if (clsContactCreditCardInfoDetails.CustomerID != Constants.ZERO)
            {
                txtCreditCardNo.Text = clsContactCreditCardInfoDetails.CreditCardNo;
                //remove this override
                //txtCreditCardExpiryDate.Text = clsContactCreditCardInfoDetails.ExpiryDate.ToString("yyyy-MM-dd");

            }
            if (((mCreditCardStatus == CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID == Constants.ZERO) ||
                    mCreditCardStatus == CreditCardStatus.Replaced_Lost) && (CardTypeDetails.WithGuarantor))
            {
                Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactCreditCardInfos.Connection, clsContactCreditCardInfos.Transaction);
                BarcodeHelper ean13 = new BarcodeHelper(BarcodeHelper.GroupCreditCard_Country_Code, BarcodeHelper.GroupCreditCard_ManufacturerCode, clsERPConfig.get_LastGroupCreditCardNo());
                txtCreditCardNo.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit;
            }
            else if ((mCreditCardStatus == CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID == Constants.ZERO) ||
                    mCreditCardStatus == CreditCardStatus.Replaced_Lost)
            {
                Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactCreditCardInfos.Connection, clsContactCreditCardInfos.Transaction);
                BarcodeHelper ean13 = new BarcodeHelper(BarcodeHelper.CreditCard_Country_Code, BarcodeHelper.CreditCard_ManufacturerCode, clsERPConfig.get_LastCreditCardNo());
                txtCreditCardNo.Text = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit;
            }
            clsContactCreditCardInfos.CommitAndDispose();
            
            Data.ContactCreditCardInfoDetails clsDetails = new Data.ContactCreditCardInfoDetails();
            clsDetails.CustomerID = mContactDetails.ContactID;
            clsDetails.CardTypeDetails = CardTypeDetails;
            clsDetails.CreditCardNo = txtCreditCardNo.Text;
            clsDetails.CreditAwardDate = DateTime.Now;
            clsDetails.ExpiryDate = dteExpiryDate;
            clsDetails.CreditLimit = decCreditLimit;

            clsContactCreditCardInfos = new Data.ContactCreditCardInfos();
            clsContactCreditCardInfoDetails = clsContactCreditCardInfos.Details(txtCreditCardNo.Text);

            if (clsContactCreditCardInfoDetails.CustomerID != Constants.ZERO)
            {
                if (mCreditCardStatus == CreditCardStatus.New || (mCreditCardStatus != CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID != mContactDetails.ContactID))
                {
                    clsContactCreditCardInfos.CommitAndDispose();

                    MessageBox.Show("Credit Card No: " + clsContactCreditCardInfoDetails.CreditCardNo + " was already issued on " + clsContactCreditCardInfoDetails.CreditAwardDate.ToString("MMM dd, yyyy") + " to another customer." +
                                    Environment.NewLine + "Please enter another Credit Card No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    txtCreditCardNo.Focus();
                    txtCreditCardNo.SelectAll();
                    return boRetValue;
                }
            }

            clsDetails.GuarantorID = clsContactCreditCardInfoDetails.GuarantorID;
            clsDetails.CardTypeDetails = clsContactCreditCardInfoDetails.CardTypeDetails;
            if (mCreditCardStatus == CreditCardStatus.New)
            {
                clsDetails.CreditActive = true;
                // override if new
                clsDetails.GuarantorID = Guarantor.ContactID;
                clsDetails.CardTypeDetails = CardTypeDetails;
            }
            else if (mCreditCardStatus == CreditCardStatus.Lost || mCreditCardStatus == CreditCardStatus.Expired || mCreditCardStatus == RetailPlus.CreditCardStatus.Suspended)
            {
                clsDetails.CreditActive = false;
            }
            else if (mCreditCardStatus == CreditCardStatus.Replaced_Lost || 
                mCreditCardStatus == CreditCardStatus.Replaced_Expired ||
                mCreditCardStatus == CreditCardStatus.Reactivated_Lost ||
                mCreditCardStatus == CreditCardStatus.ReNew)
            {
                clsDetails.CreditActive = true;
            }

            clsDetails.CreditCardStatus = mCreditCardStatus;

            // do an overwride if the date is already expired
            if (dteExpiryDate < new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59))
            {
                clsDetails.CreditActive = false;
                clsDetails.CreditCardStatus = CreditCardStatus.Expired;
            }


            boRetValue = clsContactCreditCardInfos.Update(clsDetails);

            Data.Contacts clsContacts = new Data.Contacts(clsContactCreditCardInfos.Connection, clsContactCreditCardInfos.Transaction);

            clsContacts.UpdateRemarks(clsDetails.CustomerID, txtRemarks.Text, "");

            mContactDetails.CreditDetails = clsDetails;

            clsContactCreditCardInfos.CommitAndDispose();
            
            boRetValue = true;

            return boRetValue;
		}
Example #4
0
        private bool SaveRecord()
        {
            bool boRetValue = false;

            if (string.IsNullOrEmpty(txtCreditCardNo.Text.Trim()))
            {
                MessageBox.Show("Sorry please enter a valid credit card no.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(boRetValue);
            }
            DateTime dteExpiryDate = DateTime.MinValue;

            try { dteExpiryDate = DateTime.Parse(txtCreditCardExpiryDate.Text); }
            catch
            {
                MessageBox.Show("Please enter a valid expiry date in the ff format: YYYY-MM-dd ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(boRetValue);
            }
            decimal decCreditLimit = 0;

            try { decCreditLimit = decimal.Parse(txtCreditLimit.Text); }
            catch
            {
                MessageBox.Show("Please enter a valid credit limit amount.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(boRetValue);
            }

            if (mCreditCardStatus == CreditCardStatus.New)
            {
                if (MessageBox.Show("Are you sure you want to issue a new credit card to " + mContactDetails.ContactName + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return(boRetValue);
                }
            }
            else if (mCreditCardStatus == CreditCardStatus.Lost || mCreditCardStatus == CreditCardStatus.Expired)
            {
                if (MessageBox.Show("Are you sure you want to declare card no: " + txtCreditCardNo.Text + " as " + mCreditCardStatus.ToString("G") + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return(boRetValue);
                }
            }
            else if (mCreditCardStatus == CreditCardStatus.Replaced_Lost || mCreditCardStatus == CreditCardStatus.Replaced_Expired)
            {
                if (MessageBox.Show("Are you sure you want to replace existing credit card w/ new card no?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return(boRetValue);
                }
            }
            else if (mCreditCardStatus == CreditCardStatus.Reactivated_Lost)
            {
                if (MessageBox.Show("Are you sure you want to reactivate existing credit card no: " + txtCreditCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return(boRetValue);
                }
            }
            else if (mCreditCardStatus == CreditCardStatus.ReNew)
            {
                if (MessageBox.Show("Are you sure you want to renew card no: " + txtCreditCardNo.Text + "?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return(boRetValue);
                }

                if (dteExpiryDate < DateTime.Now)
                {
                    MessageBox.Show("Expiry date must not be less than date today. Please enter a valid expiry date. ", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(boRetValue);
                }
            }

            Data.ContactCreditCardInfos       clsContactCreditCardInfos       = new Data.ContactCreditCardInfos();
            Data.ContactCreditCardInfoDetails clsContactCreditCardInfoDetails = clsContactCreditCardInfos.Details(mContactDetails.ContactID);
            if (clsContactCreditCardInfoDetails.CustomerID != Constants.ZERO)
            {
                txtCreditCardNo.Text         = clsContactCreditCardInfoDetails.CreditCardNo;
                txtCreditCardExpiryDate.Text = clsContactCreditCardInfoDetails.ExpiryDate.ToString("yyyy-MM-dd");
            }
            if (((mCreditCardStatus == CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID == Constants.ZERO) ||
                 mCreditCardStatus == CreditCardStatus.Replaced_Lost) && (CardTypeDetails.WithGuarantor))
            {
                Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactCreditCardInfos.Connection, clsContactCreditCardInfos.Transaction);
                txtCreditCardNo.Text = clsERPConfig.get_LastGroupCreditCardNo();
            }
            else if ((mCreditCardStatus == CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID == Constants.ZERO) ||
                     mCreditCardStatus == CreditCardStatus.Replaced_Lost)
            {
                Data.ERPConfig clsERPConfig = new Data.ERPConfig(clsContactCreditCardInfos.Connection, clsContactCreditCardInfos.Transaction);
                txtCreditCardNo.Text = clsERPConfig.get_LastCreditCardNo();
            }
            clsContactCreditCardInfos.CommitAndDispose();

            Data.ContactCreditCardInfoDetails clsDetails = new Data.ContactCreditCardInfoDetails();
            clsDetails.CustomerID      = mContactDetails.ContactID;
            clsDetails.CardTypeDetails = CardTypeDetails;
            clsDetails.CreditCardNo    = txtCreditCardNo.Text;
            clsDetails.CreditAwardDate = DateTime.Now;
            clsDetails.ExpiryDate      = dteExpiryDate;
            clsDetails.CreditLimit     = decCreditLimit;

            clsContactCreditCardInfos       = new Data.ContactCreditCardInfos();
            clsContactCreditCardInfoDetails = clsContactCreditCardInfos.Details(txtCreditCardNo.Text);

            if (clsContactCreditCardInfoDetails.CustomerID != Constants.ZERO)
            {
                if (mCreditCardStatus == CreditCardStatus.New || (mCreditCardStatus != CreditCardStatus.New && clsContactCreditCardInfoDetails.CustomerID != mContactDetails.ContactID))
                {
                    clsContactCreditCardInfos.CommitAndDispose();

                    MessageBox.Show("Credit Card No: " + clsContactCreditCardInfoDetails.CreditCardNo + " was already issued on " + clsContactCreditCardInfoDetails.CreditAwardDate.ToString("MMM dd, yyyy") + " to another customer." +
                                    Environment.NewLine + "Please enter another Credit Card No.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    txtCreditCardNo.Focus();
                    txtCreditCardNo.SelectAll();
                    return(boRetValue);
                }
            }

            clsDetails.GuarantorID     = clsContactCreditCardInfoDetails.GuarantorID;
            clsDetails.CardTypeDetails = clsContactCreditCardInfoDetails.CardTypeDetails;
            if (mCreditCardStatus == CreditCardStatus.New)
            {
                clsDetails.CreditActive = true;
                // override if new
                clsDetails.GuarantorID     = Guarantor.ContactID;
                clsDetails.CardTypeDetails = CardTypeDetails;
            }
            else if (mCreditCardStatus == CreditCardStatus.Lost || mCreditCardStatus == CreditCardStatus.Expired)
            {
                clsDetails.CreditActive = false;
            }
            else if (mCreditCardStatus == CreditCardStatus.Replaced_Lost ||
                     mCreditCardStatus == CreditCardStatus.Replaced_Expired ||
                     mCreditCardStatus == CreditCardStatus.Reactivated_Lost ||
                     mCreditCardStatus == CreditCardStatus.ReNew)
            {
                clsDetails.CreditActive = true;
            }
            clsDetails.CreditCardStatus = mCreditCardStatus;

            boRetValue = clsContactCreditCardInfos.Update(clsDetails);
            mContactDetails.CreditDetails = clsDetails;

            clsContactCreditCardInfos.CommitAndDispose();

            boRetValue = true;

            return(boRetValue);
        }