Exemplo n.º 1
0
        public void AddInvoiceLine(InvoiceLine slNewLine)
        {
            Array.Resize<Control>(ref aInvoicelines, aInvoicelines.Length + 1);
            aInvoicelines[aInvoicelines.Length - 1] = slNewLine;
            slNewLine.Top = 17 + ((iInvoiceLineRowIndex) * 20);
            slNewLine.Left = 4;
            //if (slNewLine.txtStore.Text == "")
            //{
            //    slNewLine.txtStore.Text = Global.sDefaultStore;
            //}
            slNewLine.TabIndex = 50 + aInvoicelines.Length;
            slNewLine.TabStop = true;
            if (slNewLine.txtCode.Text != "'")
            {
                //	slNewLine.cmdCredit.Visible = true;

            }
            else//only a note line
            {
               // slNewLine.txtStore.Visible = false;
                slNewLine.txtCode.Visible = false;
                slNewLine.lblDeliveryDate.Visible = false;
                slNewLine.lblReturnDate.Visible = false;
                slNewLine.txtQuantity.Visible = false;
                slNewLine.txtDiscount.Visible = false;
                slNewLine.txtExcPrice.Visible = false;
                slNewLine.txtNet.Visible = false;
                if (Global.iCreditInvoice == 0)
                {
                    slNewLine.cmdCredit.Visible = false;
                }
            }
            if (Global.iCreditInvoice == 0)
            {
                slNewLine.cmdCredit.Visible = false;
            }
            slNewLine.iLineIndex = aInvoicelines.Length - 1;
            slNewLine.Name = "slNewLine_" + (aInvoicelines.Length - 1).ToString();

            this.pnlDetails.Controls.Add(slNewLine);
            slNewLine.BringToFront();
            iInvoiceLineRowIndex++;
        }
Exemplo n.º 2
0
        public void loadInvoiceLines(string sStore, string sCode, string sDescription, string sUnit, string sQty, string sExcPrice, string sDiscount, string sMultiplier, string sFromDate, string sToDate, string sPeriod, string sParentLinkNum)
        {
            //LL 18/09/2009 discount displaying incorrectly
            try
            {
                double dDiscount = Convert.ToDouble(sDiscount.Trim()) / 100;
                InvoiceLine slNewLine = new InvoiceLine();
                if (sDescription.Trim().ToUpper() == "ROUNDING")
                {
                    lblInvDiscountTotal.Text = sExcPrice;
                }

                using (PsqlConnection oConn1 = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr))
                {
                    //get discountperc,taxtype,Discounttype
                    if (sCode.Trim().Replace("'", "") != "")
                    {
                        string sSqlDisc = "Select TaxType,DiscountType,DiscountPercentage FROM HistoryLines where DocumentNumber = '" + txtInvoiceNumber.Text + "' AND ItemCode = '" + sCode + "'";
                        PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSqlDisc, oConn1).ExecuteReader();
                        rdReader.Read();
                        slNewLine.txtTaxType.Text = rdReader["TaxType"].ToString();
                        slNewLine.txtDiscountType.Text = rdReader["DiscountType"].ToString();

                        rdReader.Close();
                    }
                }
                slNewLine.sPastelLineLink = sParentLinkNum;
                slNewLine.bDoCalculation = false; //Do totals only after the control has been loaded.
                //slNewLine.txtStore.Text = sStore.Trim();
                slNewLine.txtCode.Text = sCode.Trim();
                slNewLine.txtDescription.Text = sDescription.Trim();
                slNewLine.sOldDescription = sDescription;

                slNewLine.txtUnit.Text = sUnit.Trim();
                if (sFromDate.Trim() != "")
                {
                    slNewLine.dtDelivery.Text = sFromDate;
                    slNewLine.dtDelivery.Visible = true;
                }
                else
                    slNewLine.dtDelivery.Visible = false;
                if (sToDate.Trim() != "")
                {
                    slNewLine.dtReturnDate.Text = sToDate;
                    slNewLine.dtReturnDate.Visible = true;
                }
                else
                {
                    slNewLine.dtReturnDate.Visible = false;
                }

                slNewLine.cmdCodeSearch.Enabled = false;
                //slNewLine.lblDeliveryDate.Text = sFromDate;
                //slNewLine.lblReturnDate.Text = sToDate;
                slNewLine.lblReturnDate.Visible = false;
                slNewLine.lblDeliveryDate.Visible = false;
                slNewLine.txtQuantity.Text = sPeriod.Trim();
                slNewLine.txtMultiplier.Text = sMultiplier.Trim();
                slNewLine.txtMultiplier.Visible = true;
                slNewLine.txtExcPrice.Text = (Convert.ToDouble(sExcPrice.Trim())).ToString("N2");
                slNewLine.txtDiscount.Text = dDiscount.ToString("N2");
                slNewLine.txtDiscount.ReadOnly = true;

                if (slNewLine.txtQuantity.Text != "")
                {
                    double dTotalExDiscount = Convert.ToDouble(slNewLine.txtQuantity.Text.Replace(",", "")) * Convert.ToDouble(slNewLine.txtMultiplier.Text.Replace(",", "")) * Convert.ToDouble(slNewLine.txtExcPrice.Text.Replace(",", ""));
                    slNewLine.txtNet.Text = (dTotalExDiscount - (dTotalExDiscount * (Convert.ToDouble(slNewLine.txtDiscount.Text.Replace(",", "")) / 100))).ToString("N2");
                }
                else
                {
                    slNewLine.txtNet.Text = slNewLine.txtExcPrice.Text;
                }
                dLineNett = 0;
                dLineNett = Convert.ToDouble(slNewLine.txtNet.Text);
                slNewLine.bDoCalculation = true;

                AddInvoiceLine(slNewLine);
                slNewLine.picDelete.Visible = false;
               //txtDelivery.Text = slNewLine.dtDelivery.ToString();
                dtDelivery.Text = slNewLine.dtDelivery.Value.ToString();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        private bool Populate_Inventory_Fields(ref InvoiceLine slSalesLine, bool bFocusDescription)
        {
            bool bExist = false;
            if (slSalesLine.txtCode.Text == "'")
            {
                slSalesLine.txtDiscount.ReadOnly = true;
                slSalesLine.txtExcPrice.ReadOnly = true;
                slSalesLine.txtLastInvoiceDate.Text = "";
                slSalesLine.txtNet.ReadOnly = true;
                slSalesLine.txtQuantity.ReadOnly = true;
                slSalesLine.txtQuantity.Text = "0";
                slSalesLine.txtUnit.ReadOnly = true;
                slSalesLine.txtStore.ReadOnly = true;
                slSalesLine.txtDescription.Focus();
                slSalesLine.bDoCalculation = false;
                return true;
            }
            else
            {
                using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr))
                {
                    oConn.Open();
                    string sSql = "SELECT distinct  Inventory.*, MultiStoreTrn.SellExcl01 from Inventory ";
                    sSql += " left join MultiStoreTrn on Inventory.ItemCode = MultiStoreTrn.ItemCode ";
                    sSql += " where (MultiStoreTrn.StoreCode = '" + slSalesLine.txtStore.Text.Trim() + "')and (Inventory.ItemCode = '" + slSalesLine.txtCode.Text.Trim() + "')";

                    PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader();
                    while (rdReader.Read())
                    {
                        //check if inventory is available
                        bExist = true;
                        if ((rdReader["UserDefText01"].ToString().Trim().ToUpper() == "ORDER" || rdReader["UserDefText01"].ToString().Trim().ToUpper() == "RESERVED" || rdReader["UserDefText01"].ToString().Trim().ToUpper() == "WORKSHOP") && (rdReader["UserDefNum02"].ToString() != "1")) //UserDefNum02 = Allow duplicates
                        {
                            //inventory is not available
                            MessageBox.Show("Inventory is currently not available.\r\n\r\nStatus:			" + rdReader["UserDefText01"].ToString().Trim() + "\r\nExpected date back:		" + rdReader["UserDefText03"].ToString().Trim() + "\r\nReference number:		" + rdReader["UserDefText02"].ToString().Trim(), "Item Not Available", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            clearLine();
                            slSalesLine.txtCode.Focus();
                            slSalesLine.bNextLine = false;
                            return false;
                        }

                        string sInventoryGroup = rdReader["UserDefNum01"].ToString(); // 0 = Consumable;   1 = Lease Item;   2 = Returable Consumable

                        if (sInventoryGroup == "1")
                        {
                            slSalesLine.lblDeliveryDate.Visible = false;
                            slSalesLine.lblReturnDate.Visible = false;
                            slSalesLine.dtDelivery.Visible = true;
                            slSalesLine.dtReturnDate.Visible = true;
                            slSalesLine.dtDelivery.Value = ((Documents.SalesOrder)(Parent.Parent.Parent.Parent)).dtDeliveryDate.Value;
                            slSalesLine.dtReturnDate.Value = dtDelivery.Value;
                        }
                        //LL Phalaborwa Trim()
                        slSalesLine.txtDescription.Text = rdReader["Description"].ToString().Trim();
                        slSalesLine.txtUnit.Text = rdReader["UnitSize"].ToString();
                        try
                        {
                            slSalesLine.txtExcPrice.Text = Convert.ToDouble(rdReader["SellExcl01"].ToString()).ToString("N2");
                        }
                        catch
                        {
                            slSalesLine.txtExcPrice.Text = "0.00";
                        }

                        slSalesLine.txtTaxType.Text = rdReader["SalesTaxType"].ToString().Trim();
                        slSalesLine.txtDiscountType.Text = rdReader["DiscountType"].ToString().Trim();

                        if (slSalesLine.txtTaxType.Text == "0")
                        {
                            slSalesLine.txtNet.BackColor = Color.Yellow;
                        }
                        else
                        {
                            slSalesLine.txtNet.BackColor = Color.White;
                        }
                        if (bFocusDescription)
                        {
                            slSalesLine.txtDescription.Focus();
                        }
                        if (rdReader["UserDefNum02"].ToString() == "1")  //AJD 12-08-2009
                        {
                            bAllowDuplicateLines = true;
                        }
                        if (rdReader["DiscountType"].ToString() == "0" || rdReader["DiscountType"].ToString() == "1")//AJD 20-08-2009
                        {
                            slSalesLine.txtDiscount.ReadOnly = true;
                        }
                    }//end while
                    rdReader.Close();
                    oConn.Dispose();
                    if (!bExist)
                    {

                        MessageBox.Show("Code does not exist.", "Inventory Not Found", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return false;
                    }
                    return true;
                }
            }
        }