Beispiel #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);
        }
Beispiel #2
0
        public static GENERAL_JOURNAL _SA_Read(string sIDToRead) //  method will read all fields and store the data in a RECEIPT record
        {
            GENERAL_JOURNAL GJE = new GENERAL_JOURNAL();

            if (Functions.GoodData(sIDToRead))
            {
                GJE.source = sIDToRead;
                if (GeneralJournal.repo.Source.TextValue != GJE.source)
                {
                    GeneralJournal._SA_Open(GJE);
                }
            }

            GJE.journalDate = GeneralJournal.repo.JournalDate.TextValue;
            GJE.comment     = GeneralJournal.repo.Comment.TextValue;
            if (GeneralJournal.repo.SelfInfo.Exists())
            {
                GJE.currCode = GeneralJournal.repo.CurrencyCode.SelectedItem.Text;
            }

            GJE.GridRows.Clear();
            List <List <string> > lsContents = GeneralJournal.repo.DetailsContainer.GetContents();

            //if (Functions.GoodData (lsContents))   NC - no longer need to check since the lsContents.Count sort of does the same thing
            //{
            for (int x = 0; x < lsContents.Count; x++)
            {
                // check for blank line
                if (lsContents[x][0] != "")
                {
                    GJ_ROW GR = new GJ_ROW();

                    GR.Account.acctNumber = lsContents[x][0];

                    if (lsContents[x][1].Trim() == "--")
                    {
                        GR.debitAmt = "0";
                    }
                    else
                    {
                        GR.debitAmt = lsContents[x][1];
                    }

                    if (lsContents[x][2].Trim() == "--")
                    {
                        GR.creditAmt = "0";
                    }
                    else
                    {
                        GR.creditAmt = lsContents[x][2];
                    }

                    GR.lineComment = lsContents[x][3];

                    GJE.GridRows.Add(GR);
                }
            }
            //}


            // Get project allocations
            // Move to first cell
            GeneralJournal.repo.DetailsContainer.ClickFirstCell();

            if (Functions.GoodData(GJE.GridRows))
            {
                for (int x = 0; x < GJE.GridRows.Count; x++)
                {
                    if (GeneralJournal.repo.AllocateToProject.Enabled)
                    {
                        GJE.GridRows[x].Projects.Clear();
                        GeneralJournal.repo.AllocateToProject.Click();

                        if (ProjectAllocationDialog.repo.SelfInfo.Exists())
                        {
                            //List<List<string>> lsContents = ProjectAllocationDialog.repo.DataGrid.GetContents();

                            //if (Functions.GoodData (lsContents))
                            //{
                            //    for (int y = 0; y < lsContents.Count; y++)
                            //    {
                            //        if (Functions.GetField.Trim(' '), 1)) == "")
                            //        {
                            //            break;
                            //        }
                            //        else
                            //        {
                            //            PROJECT_ALLOCATION PA = new PROJECT_ALLOCATION();
                            //            PA.Project.name = Functions.Functions.GetField (lsContents[y], "	", 1);
                            //            if(Functions.GetField.Trim(' '), 2)) == "--")
                            //            {
                            //                PA.Amount = "0";
                            //            }
                            //            else
                            //            {
                            //                PA.Amount = Functions.Functions.GetField (lsContents[y], "	", 2);
                            //            }
                            //            if(Functions.GetField.Trim(' '), 3)) == "--")
                            //            {
                            //                PA.Percent = "0";
                            //            }
                            //            else
                            //            {
                            //                PA.Percent = Functions.Functions.GetField (lsContents[y], "	", 3);
                            //            }
                            //            GJE.GridRows[x].Projects.Add(PA);
                            //        }
                            //    }

                            GJE.GridRows[x].Projects = ProjectAllocationDialog._SA_GetProjectAllocationDetails();
                        }
                        ProjectAllocationDialog.repo.Cancel.Click();
                    }
                    GeneralJournal.repo.DetailsContainer.PressKeys("<Down>");
                }
            }

            return(GJE);
        }