Пример #1
0
        private void SetDataSource(ReportDocument Report)
        {
            DateTime      dteRetValue = Constants.C_DATE_MIN_VALUE;
            ReportDataset rptds       = new ReportDataset();

            Data.Contacts         clsContacts;
            System.Data.DataTable dt;

            switch (cboReportType.SelectedItem.Value)
            {
            case ReportTypes.CREDITS_Purchases:
                #region purchases

                CreditPaymentDetails clsCreditPaymentDetails = new CreditPaymentDetails();
                clsCreditPaymentDetails.BranchDetails = new BranchDetails()
                {
                    BranchID = Int32.Parse(cboBranch.SelectedItem.Value)
                };
                clsCreditPaymentDetails.TerminalNo           = txtTerminalNo.Text.Trim();
                clsCreditPaymentDetails.PurchaseDateFrom     = DateTime.TryParse(txtTrxStartDate.Text + " 00:00:00", out dteRetValue) ? dteRetValue : Constants.C_DATE_MIN_VALUE;
                clsCreditPaymentDetails.PurchaseDateTo       = DateTime.TryParse(txtTrxEndDate.Text + " 23:59:59", out dteRetValue) ? dteRetValue : Constants.C_DATE_MIN_VALUE;
                clsCreditPaymentDetails.CreditType           = CreditType.Individual;
                clsCreditPaymentDetails.CreditCardTypeID     = Int16.Parse(cboCreditType.SelectedItem.Value);
                clsCreditPaymentDetails.CreditorLastnameFrom = txtLastNameFrom.Text;
                clsCreditPaymentDetails.CreditorLastnameTo   = txtLastNameTo.Text;

                clsContacts = new Data.Contacts();
                dt          = clsContacts.CreditPurchasesAsDataTable(clsCreditPaymentDetails, "cci.CreditCardNo");
                clsContacts.CommitAndDispose();

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    DataRow drNew = rptds.ContactCreditPurchases.NewRow();

                    foreach (DataColumn dc in rptds.ContactCreditPurchases.Columns)
                    {
                        drNew[dc] = "" + dr[dc.ColumnName];
                    }

                    rptds.ContactCreditPurchases.Rows.Add(drNew);
                }
                #endregion
                break;

            case ReportTypes.CREDITS_Payments:
                #region payments

                CreditPaymentCashDetails clsCreditPaymentCashDetails = new CreditPaymentCashDetails();
                clsCreditPaymentCashDetails.BranchDetails = new BranchDetails()
                {
                    BranchID = Int32.Parse(cboBranch.SelectedItem.Value)
                };
                clsCreditPaymentCashDetails.TerminalNo           = txtTerminalNo.Text.Trim();
                clsCreditPaymentCashDetails.PaymentDateFrom      = DateTime.TryParse(txtTrxStartDate.Text + " 00:00:00", out dteRetValue) ? dteRetValue : Constants.C_DATE_MIN_VALUE;
                clsCreditPaymentCashDetails.PaymentDateTo        = DateTime.TryParse(txtTrxEndDate.Text + " 23:59:59", out dteRetValue) ? dteRetValue : Constants.C_DATE_MIN_VALUE;
                clsCreditPaymentCashDetails.CreditType           = CreditType.Individual;
                clsCreditPaymentCashDetails.CreditCardTypeID     = Int16.Parse(cboCreditType.SelectedItem.Value);
                clsCreditPaymentCashDetails.CreditorLastnameFrom = txtLastNameFrom.Text;
                clsCreditPaymentCashDetails.CreditorLastnameTo   = txtLastNameTo.Text;

                clsContacts = new Data.Contacts();
                dt          = clsContacts.CreditPaymentCashDetailedAsDataTable(clsCreditPaymentCashDetails, "cci.CreditCardNo");
                clsContacts.CommitAndDispose();

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    DataRow drNew = rptds.ContactCreditPaymentCash.NewRow();

                    foreach (DataColumn dc in rptds.ContactCreditPaymentCash.Columns)
                    {
                        drNew[dc] = "" + dr[dc.ColumnName];
                    }

                    rptds.ContactCreditPaymentCash.Rows.Add(drNew);
                }
                #endregion
                break;

            case ReportTypes.CREDITS_CreditorsLedgerSummary:
                #region ledger summary
                Data.Billing clsBilling = new Data.Billing();
                dt = clsBilling.ListAsDataTable(GuarantorID: 0, CreditCardTypeID: Int16.Parse(cboCreditType.SelectedItem.Value), CreditType: CreditType.Individual, BillingDate: DateTime.Parse(cboBillingDate.SelectedItem.Value), CheckIsBillPrinted: false, SortField: "GUA.ContactName, CUS.ContactName", SortOrder: System.Data.SqlClient.SortOrder.Descending);
                clsBilling.CommitAndDispose();

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    System.Data.DataRow drNew = rptds.CreditBillHeader.NewRow();

                    foreach (System.Data.DataColumn dc in rptds.CreditBillHeader.Columns)
                    {
                        drNew[dc] = dr[dc.ColumnName];
                    }

                    rptds.CreditBillHeader.Rows.Add(drNew);
                }
                #endregion
                break;

            case ReportTypes.CustomerCreditSummarizedStatistics:
                #region  CustomerCreditSummarizedStatistics

                Data.ContactCreditCardInfos clsContactCreditCardInfos = new Data.ContactCreditCardInfos();
                dt = clsContactCreditCardInfos.IHCreditCardSummarizedStatistics(false);
                clsContactCreditCardInfos.CommitAndDispose();

                foreach (DataRow dr in dt.Rows)
                {
                    DataRow drNew = rptds.CCISummary.NewRow();

                    foreach (DataColumn dc in rptds.CCISummary.Columns)
                    {
                        drNew[dc] = dr[dc.ColumnName];
                    }

                    rptds.CCISummary.Rows.Add(drNew);
                }

                break;
                #endregion

            default:
                break;
            }


            Report.SetDataSource(rptds);
            SetParameters(Report);
        }
Пример #2
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();
            }
        }
Пример #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;
		}
Пример #4
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();
            }
        }
Пример #5
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);
        }
Пример #6
0
		private void SetDataSource(ReportDocument Report)
		{
            DateTime dteRetValue = Constants.C_DATE_MIN_VALUE;
            ReportDataset rptds = new ReportDataset();
            Data.Contacts clsContacts;
            System.Data.DataTable dt;

            switch (cboReportType.SelectedItem.Value)
            {
                case ReportTypes.CREDITS_Purchases:
                    #region purchases

                    CreditPaymentDetails clsCreditPaymentDetails = new CreditPaymentDetails();
                    clsCreditPaymentDetails.BranchDetails = new BranchDetails() { BranchID = Int32.Parse(cboBranch.SelectedItem.Value) };
                    clsCreditPaymentDetails.TerminalNo = txtTerminalNo.Text.Trim();
                    clsCreditPaymentDetails.PurchaseDateFrom = DateTime.TryParse(txtTrxStartDate.Text + " 00:00:00", out dteRetValue) ? dteRetValue : Constants.C_DATE_MIN_VALUE;
                    clsCreditPaymentDetails.PurchaseDateTo = DateTime.TryParse(txtTrxEndDate.Text + " 23:59:59", out dteRetValue) ? dteRetValue : Constants.C_DATE_MIN_VALUE;
                    clsCreditPaymentDetails.CreditType = CreditType.Individual;
                    clsCreditPaymentDetails.CreditCardTypeID = Int16.Parse(cboCreditType.SelectedItem.Value);
                    clsCreditPaymentDetails.CreditorLastnameFrom = txtLastNameFrom.Text;
                    clsCreditPaymentDetails.CreditorLastnameTo = txtLastNameTo.Text;

                    clsContacts = new Data.Contacts();
                    dt = clsContacts.CreditPurchasesAsDataTable(clsCreditPaymentDetails, "cci.CreditCardNo");
                    clsContacts.CommitAndDispose();

			        foreach(System.Data.DataRow dr in dt.Rows)
			        {
				        DataRow drNew = rptds.ContactCreditPurchases.NewRow();

                        foreach (DataColumn dc in rptds.ContactCreditPurchases.Columns)
					        drNew[dc] = "" + dr[dc.ColumnName];

                        rptds.ContactCreditPurchases.Rows.Add(drNew);
			        }
                    #endregion
                    break;

                case ReportTypes.CREDITS_Payments:
                    #region payments

                    CreditPaymentCashDetails clsCreditPaymentCashDetails = new CreditPaymentCashDetails();
                    clsCreditPaymentCashDetails.BranchDetails = new BranchDetails() { BranchID = Int32.Parse(cboBranch.SelectedItem.Value) };
                    clsCreditPaymentCashDetails.TerminalNo = txtTerminalNo.Text.Trim();
                    clsCreditPaymentCashDetails.PaymentDateFrom = DateTime.TryParse(txtTrxStartDate.Text + " 00:00:00", out dteRetValue) ? dteRetValue : Constants.C_DATE_MIN_VALUE;
                    clsCreditPaymentCashDetails.PaymentDateTo = DateTime.TryParse(txtTrxEndDate.Text + " 23:59:59", out dteRetValue) ? dteRetValue : Constants.C_DATE_MIN_VALUE;
                    clsCreditPaymentCashDetails.CreditType = CreditType.Individual;
                    clsCreditPaymentCashDetails.CreditCardTypeID = Int16.Parse(cboCreditType.SelectedItem.Value);
                    clsCreditPaymentCashDetails.CreditorLastnameFrom = txtLastNameFrom.Text;
                    clsCreditPaymentCashDetails.CreditorLastnameTo = txtLastNameTo.Text;

                    clsContacts = new Data.Contacts();
                    dt = clsContacts.CreditPaymentCashDetailedAsDataTable(clsCreditPaymentCashDetails, "cci.CreditCardNo");
                    clsContacts.CommitAndDispose();

                    foreach (System.Data.DataRow dr in dt.Rows)
                    {
                        DataRow drNew = rptds.ContactCreditPaymentCash.NewRow();

                        foreach (DataColumn dc in rptds.ContactCreditPaymentCash.Columns)
                            drNew[dc] = "" + dr[dc.ColumnName];

                        rptds.ContactCreditPaymentCash.Rows.Add(drNew);
                    }
                    #endregion
                    break;

                case ReportTypes.CREDITS_CreditorsLedgerSummary:
                    #region ledger summary
                    Data.Billing clsBilling = new Data.Billing();
                    dt = clsBilling.ListAsDataTable(GuarantorID: 0, CreditCardTypeID: Int16.Parse(cboCreditType.SelectedItem.Value), CreditType: CreditType.Individual, BillingDate: DateTime.Parse(cboBillingDate.SelectedItem.Value), CheckIsBillPrinted: false,  SortField: "GUA.ContactName, CUS.ContactName", SortOrder: System.Data.SqlClient.SortOrder.Descending);
                    clsBilling.CommitAndDispose();

                    foreach (System.Data.DataRow dr in dt.Rows)
                    {
                        System.Data.DataRow drNew = rptds.CreditBillHeader.NewRow();

                        foreach (System.Data.DataColumn dc in rptds.CreditBillHeader.Columns)
                            drNew[dc] = dr[dc.ColumnName];

                        rptds.CreditBillHeader.Rows.Add(drNew);
                    }
                    #endregion
                    break;

                case ReportTypes.CustomerCreditSummarizedStatistics:
                    #region  CustomerCreditSummarizedStatistics

                    Data.ContactCreditCardInfos clsContactCreditCardInfos = new Data.ContactCreditCardInfos();
                    dt = clsContactCreditCardInfos.IHCreditCardSummarizedStatistics(false);
                    clsContactCreditCardInfos.CommitAndDispose();

                    foreach (DataRow dr in dt.Rows)
                    {
                        DataRow drNew = rptds.CCISummary.NewRow();

                        foreach (DataColumn dc in rptds.CCISummary.Columns)
                            drNew[dc] = dr[dc.ColumnName];

                        rptds.CCISummary.Rows.Add(drNew);
                    }

                    break;
                    #endregion

                default:
                    break;
            }
            

			Report.SetDataSource(rptds); 
			SetParameters(Report);
		}