Example #1
0
        public static PURCHASE _SA_Read(PURCHASE TransRecord, bool bOneTime) //  method will read all fields and store the data in a PURCHASE record
        {
            PURCHASE Purch;

            // load it in adjustment mode first
            if (Functions.GoodData(TransRecord))        // load the transaction if specified
            {
                PurchasesJournal._SA_Open(TransRecord, true, bOneTime);
            }

            // set focus from the settings window back to the journal window
            //PurchasesJournal.Instance.Window.SetActive();

            // create the correct object based on the transaction type
            string transType = PurchasesJournal.repo.TransTypeDropDown.SelectedItemText;

            if (transType.ToLower().Contains("invoice"))
            {
                Purch = new PURCHASE_INVOICE();
            }
            else if (transType.ToLower().Contains("order"))
            {
                Purch = new PURCHASE_ORDER();
            }
            else if (transType.ToLower().Contains("quote"))
            {
                Purch = new PURCHASE_QUOTE();
            }
            else
            {
                Purch = new PURCHASE_INVOICE();
                //Functions.Verify(false, true, "Valid value from transaction list");
            }

            if (Purch.GetType() != typeof(PURCHASE_QUOTE))      // i.e. order or invoice
            {
                // Set Paid by and ChequeNumbers
                ((PURCHASE_COMMON_ORDER_INVOICE)Purch).paymentMethod = PurchasesJournal.repo.PaidBy.SelectedItemText;

                if (PurchasesJournal.repo.PaidFromInfo.Exists())
                {
                    {
                        ((PURCHASE_COMMON_ORDER_INVOICE)Purch).PaidFromAccount.acctNumber = PurchasesJournal.repo.PaidFrom.SelectedItemText;
                    }
                }
                if (PurchasesJournal.repo.ChequeNumberInfo.Exists())
                {
                    {
                        ((PURCHASE_COMMON_ORDER_INVOICE)Purch).chequeNumber = PurchasesJournal.repo.ChequeNumber.TextValue;
                    }
                }
            }
            if (Purch.GetType() == typeof(PURCHASE_INVOICE))    // set style for invoice, transaction number,  & Quote Number if present
            {
                {
                    Purch.transNumber = PurchasesJournal.repo.InvoiceNumber.TextValue;

                    if (PurchasesJournal.repo.OrderQuoteNoInfo.Exists())        // doesn't exists for one time
                    {
                        ((PURCHASE_INVOICE)Purch).quoteOrderTransNumber = PurchasesJournal.repo.OrderQuoteNoText.TextValue;
                    }
                }
            }
            else        // set transaction number and shipping date for order/quote
            {
                Purch.transNumber = PurchasesJournal.repo.OrderQuoteNoText.TextValue;
                Purch.shipDate    = PurchasesJournal.repo.ShipDate.TextValue;
            }

            Purch.Vendor.name = PurchasesJournal.repo.VendorNameText.TextValue;
            Purch.transDate   = PurchasesJournal.repo.InvoiceDate.TextValue;
            if (PurchasesJournal.repo.ExchangeRateInfo.Exists())
            {
                Purch.exchangeRate = PurchasesJournal.repo.ExchangeRate.TextValue;
            }
            if (PurchasesJournal.repo.StoreItemsAtInfo.Exists())
            {
                if (PurchasesJournal.repo.StoreItemsAt.Enabled)
                {
                    Purch.shipToLocation = PurchasesJournal.repo.StoreItemsAt.SelectedItemText;
                }
            }

            // prepare the container
            PURCH_TABLE PT = new PURCH_TABLE();
            // InitializeTable(PT);

            //int iNumOfCols = PurchasesJournal.repo.TransContainer.ColumnCount;
            //List<string[]> containerLine = ConvertFunctions.DataGridItemsToListOfString(PurchasesJournal.Instance.TransContainer.Items, iNumOfCols);
            List <List <string> > Contents = PurchasesJournal.repo.TransContainer.GetContents();

            List <ROW> lR = new List <ROW>()
            {
            };

            //for (int x = 0; x < containerLine.Count; x++)
            foreach (List <string> currRow in Contents)
            {
                // it's a blank row if the item number, quantity received, quantity ordered, description, and amount fields are all blank
                if ((currRow[PT.iItem] == "") && (currRow[PT.iQuantity] == "") && (currRow[PT.iOrder] == "") &&
                    (currRow[PT.iDescription] == "") && (currRow[PT.iAmount] == ""))
                {
                    // do not add
                }
                else
                {
                    ROW R = new ROW();

                    // assign recordset
                    R.Item.invOrServNumber = ConvertFunctions.CommaToText(currRow[PT.iItem]);
                    R.quantityReceived     = ConvertFunctions.CommaToText(currRow[PT.iQuantity]);
                    R.quantityOrdered      = ConvertFunctions.CommaToText(currRow[PT.iOrder]);
                    R.quantityBackordered  = ConvertFunctions.CommaToText(currRow[PT.iBackOrder]);
                    R.unit = ConvertFunctions.CommaToText(currRow[PT.iUnit]);
                    //R.Item.invOrServDescription = StrTran(containerLine[5+ iItmColID], "," ,"\comma") // wrong record field
                    R.description        = ConvertFunctions.CommaToText(currRow[PT.iDescription]);
                    R.price              = ConvertFunctions.CommaToText(currRow[PT.iPrice]);
                    R.TaxCode.code       = ConvertFunctions.CommaToText(currRow[PT.iTax]); // blank when no tax
                    R.amount             = ConvertFunctions.CommaToText(currRow[PT.iAmount]);
                    R.Account.acctNumber = ConvertFunctions.CommaToText(currRow[PT.iAccount]);

                    // append to detail list
                    lR.Add(R);
                }

                //// only remove if more than one line is present. NC - no longer needed so commented out
                //if(containerLine.Count >iNumOfCols)
                //{
                //    // remove line already recorded
                //    for ( int i = 0; i < iNumOfCols; i++)
                //    {
                //        containerLine.RemoveAt(1);
                //    }
                //}
                //else
                //{
                //    containerLine.RemoveAt(1);
                //}
            }

            // add rows to the record
            Purch.GridRows = lR;

            // read project allocation data
            if (Functions.GoodData(Purch.GridRows))
            {
                //PurchasesJournal.Instance.VendorName.SetFocus();    // Set focus within the journal first, or else sometimes cannot select the account field.
                for (int x = 0; x < Purch.GridRows.Count; x++)
                {
                    if (Functions.GoodData(Purch.GridRows[x].amount))                  // proceed only if amount is available
                    {
                        PurchasesJournal.repo.TransContainer.SelectCell("Account", x); // select account field
                        PurchasesJournal.repo.TransContainer.PressKeys("{Ctrl Shift}a");

                        if (ProjectAllocationDialog.repo.SelfInfo.Exists())
                        {
                            Purch.GridRows[x].Projects = ProjectAllocationDialog._SA_GetProjectAllocationDetails();   // get dialog content
                            ProjectAllocationDialog.repo.Cancel.Click();
                        }
                    }
                }
            }

            if (PurchasesJournal.repo.PrepayRefNumberInfo.Exists())
            {
                ((PURCHASE_ORDER)Purch).prepayRefNumber  = PurchasesJournal.repo.PrepayRefNumber.TextValue;
                ((PURCHASE_ORDER)Purch).prepaymentAmount = PurchasesJournal.repo.PrepaymentAmount.TextValue;
            }

            Purch.freightAmount       = PurchasesJournal.repo.FreightAmount.TextValue;
            Purch.FreightTaxCode.code = PurchasesJournal.repo.FreightCode.TextValue;
            if (PurchasesJournal.repo.FreightTaxTotalInfo.Exists())     // db has more than 2 taxes defined
            {
                Purch.freightTaxTotal = PurchasesJournal.repo.FreightTaxTotal.TextValue;
            }
            else        // only two taxes and both shown
            {
                Purch.freightTax1 = PurchasesJournal.repo.FreightTax1.TextValue;
                // will not show if only one tax is shown
                if (PurchasesJournal.repo.FreightTax2Info.Exists())
                {
                    Purch.freightTax2 = PurchasesJournal.repo.FreightTax2.TextValue;
                }
            }

            if (PurchasesJournal.repo.TermsPercentInfo.Exists())
            {
                Purch.termsPercent = PurchasesJournal.repo.TermsPercent.TextValue;
                Purch.termsDays    = PurchasesJournal.repo.TermsDay.TextValue;
                Purch.termsNetDays = PurchasesJournal.repo.TermsNetDays.TextValue;
            }
            if (PurchasesJournal.repo.EarlyDiscountInfo.Exists())
            {
                ((PURCHASE_INVOICE)Purch).earlyPaymentDiscountPercent = PurchasesJournal.repo.EarlyDiscount.TextValue;
            }
            if (Purch.GetType() == typeof(PURCHASE_INVOICE))    // set tracking
            {
                if (Functions.GoodData(Purch.shippedBy) || Functions.GoodData(Purch.trackingNumber))
                {
                    PurchasesJournal.repo.Self.PressKeys("{Ctrl}k");
                    Purch.shippedBy      = TrackShipments.repo.Shipper.SelectedItemText;
                    Purch.trackingNumber = TrackShipments.repo.TrackingNumber.TextValue;
                    TrackShipments.repo.OK.Click();
                }
            }
            return(Purch);
        }
Example #2
0
        public static List <string> DataFile_updateListOfStrings(string extension, PROJECT ProjectRecord, int iBudgetLine)
        {
            List <string> listContents = new List <string>();

            switch (extension.ToUpper())
            {
            case EXTENSION_HEADER:
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.action)));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.name)));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.startDate)));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.revenue)));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.expense)));
                listContents.Add(ConvertFunctions.BoolToString(ProjectRecord.inactiveCheckBox));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.endDate)));
                switch (ProjectRecord.status)
                {
                case PROJECT_STATUS.PROJECT_PENDING:
                    listContents.Add("Pending");
                    break;

                case PROJECT_STATUS.PROJECT_IN_PROGRESS:
                    listContents.Add("In Progress");
                    break;

                case PROJECT_STATUS.PROJECT_CANCELLED:
                    listContents.Add("Cancelled");
                    break;

                case PROJECT_STATUS.PROJECT_COMPLETED:
                    listContents.Add("Completed");
                    break;

                default:
                    Functions.Verify(false, true, "Valid value for project status");
                    break;
                }
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.nameEdit)));
                break;

            case EXTENSION_BUDGET:
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.name)));
                listContents.Add(ConvertFunctions.BoolToString(ProjectRecord.budgetCheckBox));
                break;

            case EXTENSION_BUDGET_TABLE:
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.name)));
                listContents.Add(Convert.ToString(iBudgetLine));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.Budgets[iBudgetLine].revenue)));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.Budgets[iBudgetLine].expense)));
                break;

            case EXTENSION_ADDITIONAL_INFO:
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.name)));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.additional1)));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.additional2)));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.additional3)));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.additional4)));
                listContents.Add(ConvertFunctions.CommaToText(ConvertFunctions.NullToBlankString(ProjectRecord.additional5)));
                listContents.Add(ConvertFunctions.BoolToString(ProjectRecord.addCheckBox1));
                listContents.Add(ConvertFunctions.BoolToString(ProjectRecord.addCheckBox2));
                listContents.Add(ConvertFunctions.BoolToString(ProjectRecord.addCheckBox3));
                listContents.Add(ConvertFunctions.BoolToString(ProjectRecord.addCheckBox4));
                listContents.Add(ConvertFunctions.BoolToString(ProjectRecord.addCheckBox5));
                break;

            default:
            {
                break;
            }
            }
            return(listContents);
        }