예제 #1
0
        public void AddSupplDocLine(SupplDocLine slNewLine)
        {
            Array.Resize<Control>(ref aSupplDoclines, aSupplDoclines.Length + 1);
            aSupplDoclines[aSupplDoclines.Length - 1] = slNewLine;
            slNewLine.Top = 17 + ((iLineRowIndex) * 20);
            slNewLine.Left = 4;
            if (slNewLine.txtStore.Text == "")
            {
                slNewLine.txtStore.Text = Global.sDefaultStore;
            }
            slNewLine.TabIndex = 50 + aSupplDoclines.Length;
            slNewLine.TabStop = true;

            slNewLine.iLineIndex = aSupplDoclines.Length - 1;
            slNewLine.Name = "slNewLine_" + (aSupplDoclines.Length - 1).ToString();

            this.pnlDetails.Controls.Add(slNewLine);
            slNewLine.BringToFront();
            iLineRowIndex++;
        }
예제 #2
0
        private bool Populate_Inventory_Fields(ref SupplDocLine slSupplDocLine, bool bFocusDescription)
        {
            bool bExist = false;
            if (slSupplDocLine.txtCode.Text == "'")
            {
                slSupplDocLine.txtDiscount.ReadOnly = true;
                slSupplDocLine.txtExcPrice.ReadOnly = true;
                slSupplDocLine.txtNet.ReadOnly = true;
                slSupplDocLine.txtQuantity.ReadOnly = true;
                slSupplDocLine.txtQuantity.Text = "0";
                slSupplDocLine.txtUnit.ReadOnly = true;
                slSupplDocLine.txtStore.ReadOnly = true;
                slSupplDocLine.txtDescription.Focus();
                //slSupplDocLine.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 = '" + slSupplDocLine.txtStore.Text.Trim() + "')and (Inventory.ItemCode = '" + slSupplDocLine.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")
                        {
                            //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(true);
                            slSupplDocLine.txtCode.Focus();
                            slSupplDocLine.bNextLine = false;
                            return false;
                        }
                        if (!bNextLine)
                        {
                            bNextLine = true;
                            SupplDocLine slNewline = new SupplDocLine();
                            ((Documents.SupplierDocuments)(Parent.Parent)).AddSupplDocLine(slNewline);

                        }

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

                        slSupplDocLine.txtDescription.Text = rdReader["Description"].ToString();
                        slSupplDocLine.txtUnit.Text = rdReader["UnitSize"].ToString();
                        try
                        {
                            slSupplDocLine.txtExcPrice.Text = Convert.ToDouble(rdReader["SellExcl01"].ToString()).ToString("N2");
                        }
                        catch
                        {
                            slSupplDocLine.txtExcPrice.Text = "0.00";
                        }

                        slSupplDocLine.txtTaxType.Text = rdReader["SalesTaxType"].ToString();
                        if (slSupplDocLine.txtTaxType.Text == "0")
                        {
                            slSupplDocLine.txtNet.BackColor = Color.Yellow;
                        }
                        else
                        {
                            slSupplDocLine.txtNet.BackColor = Color.White;
                        }
                        if (bFocusDescription)
                        {
                            slSupplDocLine.txtDescription.Focus();
                        }
                    }//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;
                }
            }
        }
예제 #3
0
        private void cmdCodeSearch_Click(object sender, EventArgs e)
        {
            Cursor = System.Windows.Forms.Cursors.WaitCursor;
            using (Finder.Inventory frmInventory = new Solsage_Process_Management_System.Finder.Inventory())
            {
                //Sending "None" to inventory ShowDialog to identify that no workshop action should be taken
                if (frmInventory.ShowDialog(txtStore.Text,"","") == DialogResult.OK)
                {
                    if (frmInventory.sResult != "")
                    {
                        //check if this item has been selected...
                        if (((Documents.SupplierDocuments)(Parent.Parent)).CheckDuplicateSupplDocLines(frmInventory.sResult.Trim() + txtBatchNum.Text.Trim()))
                        {
                            MessageBox.Show("No duplicate items are allowed in a supplier document. Please select another inventory item.", "Duplicates", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                                txtCode.Text = frmInventory.sResult.Trim();
                                SupplDocLine slDocLine = this;
                                SupplDocLine slLastControl = this;

                                if (frmInventory.bLinkItem && MessageBox.Show("This item is part of a KIT. Do you want to load all the items linked to this item? ", "Kit Item", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) //Kit Item
                                {
                                    bNextLine = true;
                                    bool bContinue = Populate_Inventory_Fields(ref slDocLine,false);
                                    txtCode.Focus();
                                    txtCode.SelectionStart = 0;
                                    txtCode.SelectionLength = txtCode.Text.Length;
                                    if (bContinue)
                                    {
                                        PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr);
                                        oConn.Open();

                                        string sSql = "select RMStore, ItemCode, RMQty, Remarks from  LinkLines ";
                                        sSql += " where ItemCode <> '" + frmInventory.sResult + "' and LnkCode = '" + frmInventory.sResult + "'";
                                        PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader();
                                        while (rdReader.Read())
                                        {
                                            SupplDocLine slKitLine = new SupplDocLine();
                                            slKitLine.txtStore.Text = rdReader["RMStore"].ToString().Trim();
                                            slKitLine.txtCode.Text = rdReader["ItemCode"].ToString().Trim();
                                            if (slKitLine.txtCode.Text == "'")
                                            {
                                                slKitLine.txtDescription.Text = rdReader["Remarks"].ToString().Trim();
                                            }
                                            slKitLine.bDoCalculation = false;
                                            slKitLine.bNextLine = true;
                                            slKitLine.txtQuantity.Text = rdReader["RMQty"].ToString().Trim();
                                            ((Documents.SupplierDocuments)(Parent.Parent.Parent.Parent)).InsertSalesLine(slLastControl.iLineIndex, slKitLine);
                                            slLastControl = slKitLine;
                                            slKitLine.bDoCalculation = true;
                                            Populate_Inventory_Fields(ref slKitLine, false);
                                        }
                                        SupplDocLine slLastLine = (SupplDocLine)((Documents.SupplierDocuments)(Parent.Parent.Parent.Parent)).aSupplDoclines[((Documents.SupplierDocuments)(Parent.Parent.Parent.Parent)).aSupplDoclines.Length - 1];
                                          if (slLastLine.txtCode.Text != "")
                                        {
                                            SupplDocLine slNewline = new SupplDocLine();//add empty line at the end
                                            ((Documents.SupplierDocuments)(Parent.Parent.Parent.Parent)).AddSupplDocLine(slNewline);
                                        }
                                        rdReader.Close();
                                        oConn.Dispose();
                                        ((Documents.SupplierDocuments)(Parent.Parent)).addTotals();
                                    }
                                }
                                else
                                {
                                    bool bValid = Populate_Inventory_Fields(ref slDocLine,true);
                                    ((Documents.SupplierDocuments)(Parent.Parent)).addTotals();
                                    txtCode.Focus();
                                    txtCode.SelectionStart = 0;
                                    txtCode.SelectionLength = txtCode.Text.Length;
                                }
                        }
                    }
                }
            }
            Cursor = System.Windows.Forms.Cursors.Default;
        }
예제 #4
0
        private string getPastelLine(SupplDocLine slThisLine)
        {
            string sLine = "";
            string sLineType = "4";
            if (slThisLine.txtCode.Text == "'")
            {
                sLine += "|"; //Cost Price
                sLine += "|"; //Line Quantity
                sLine += "|"; //Exclusive Price Per Unit
                sLine += "|"; //Inclusive Price Per Unit
                sLine += "|"; //Unit
                sLine += "|"; //Tax Type
                sLine += "|"; //Discount Type
                sLine += "|"; //Discount %
                sLine += "|"; //Code
                sLine += slThisLine.txtDescription.Text.Trim() + "|"; //Description
                sLine += "7|"; //Line Type
                sLine += "|"; //Store Code
                sLine += "|"; //CostCode
            }
            else if (slThisLine.txtCode.Text != "")//line defined by Code
            {
                sLine += "|"; //Cost Price
                sLine += slThisLine.txtQuantity.Text.Replace(",", "").Trim() + "|"; //Line Quantity
                sLine += slThisLine.txtExcPrice.Text.Replace(",", "").Trim() + "|"; //Exclusive Price Per Unit
                if (slThisLine.txtTaxType.Text == "0" || slThisLine.txtTaxType.Text == "2")
                    sLine += Convert.ToDouble(slThisLine.txtExcPrice.Text).ToString().Replace(",", "") + "|"; //Inclusive Price Per Unit
                else
                    sLine += (Convert.ToDouble(slThisLine.txtExcPrice.Text) * 1.14).ToString().Replace(",", "") + "|"; //Inclusive Price Per Unit
                sLine += slThisLine.txtUnit.Text.Trim() + "|"; //Unit
                sLine += slThisLine.txtTaxType.Text.PadLeft(2, "0".ToCharArray()[0]) + "|"; //Tax Type
                sLine += "0|"; //Discount Type
                sLine += slThisLine.txtDiscount.Text.Replace(".", "").Replace(",", "") + "|"; //Discount %
                sLine += slThisLine.txtCode.Text.Trim() + "|"; //Code
                sLine += slThisLine.txtDescription.Text.Trim() + "|"; //Description
                sLine += sLineType + "|"; //Line Type
                sLine += slThisLine.txtStore.Text.Trim() + "|"; //Store Code
                sLine += "|"; //CostCode

                if (slThisLine.txtLinkNum.Text != "")
                {
                    for( int i = 0; i < aLinkedLines.Length; i++)
                    {
                        string[] aLinkedLinesComparison = aLinkedLines[i].Split("|".ToCharArray());
                        if (aLinkedLinesComparison[0].ToString().Trim() == slThisLine.txtCode.Text.Trim() && aLinkedLinesComparison[3].ToString().Trim() == slThisLine.txtLinkNum.Text)
                        {
                            Array.Resize<string>(ref aActualLinkedLines, aActualLinkedLines.Length + 1);
                            aActualLinkedLines[aActualLinkedLines.Length - 1] = aLinkedLines[i];
                        }
                    }
                }
            }
            return (sLine);
        }
예제 #5
0
        public void makeReadOnly(bool bUpdateInventory)
        {
            if ((aLinkedLines.Length == 0 && txtNumber.Text != "*NEW*") || (txtNumber.Text != "*NEW*" && txtNumber.Text != ""))
            {

                txtSupplierCode.ReadOnly = true;
                cmdSearchSupplier.Visible = false;
                cmdSalesPerson.Visible = false;

                txtSalesCode.ReadOnly = true;
                txtSalesCode.BackColor = Color.White;

                txtDiscount.ReadOnly = true;
                dtDate.Enabled = false;

                txtOrderNumber.ReadOnly = true;
                txtOrderNumber.BackColor = Color.White;

                txtDiscount.ReadOnly = true;
                dtDeliveryDate.Enabled = false;
                txtRounding.Text = "0.00";
                txtRounding.ReadOnly = true;
                txtRounding.BackColor = cBackColor;
                pnlRoundingValue.BackColor = cBackColor;

                //Readonly Line Items
                for (int iLines = 0; iLines < aSupplDoclines.Length; iLines++)
                {
                    SupplDocLine slThisline = (((SupplDocLine)aSupplDoclines[iLines]));
                    if (slThisline.txtCode.Text != "")
                    {
                        slThisline.makeLineReadOnly();
                    }
                    else
                    {
                        this.Controls.Remove(slThisline);
                    }
                }
            }
            else
            {
                //Readonly Line Items
                for (int iLines = 0; iLines < aSupplDoclines.Length; iLines++)
                {
                    SupplDocLine slThisline = (((SupplDocLine)aSupplDoclines[iLines]));
                    if (slThisline.txtCode.Text != "")
                    {
                        slThisline.makeLineReadOnly();
                    }
                    else
                    {
                        this.Controls.Remove(slThisline);
                    }
                }
                //txtOrderNumber.ReadOnly = true;
                SupplDocLine slNewLine = new SupplDocLine();
                AddSupplDocLine(slNewLine);

            }
        }
예제 #6
0
        public void loadLines(string sDocNumber, string sStore, string sCode, string sDescription, string sUnit, string sQty, string sExcPrice, string sDiscount, string sTaxType,string sLinkNum, string sBatchNumber)
        {
            bool bLeaseItem = false;

            SupplDocLine slNewLine = new SupplDocLine();

            slNewLine.bDoCalculation = false; //Do totals only after the control has been loaded.
            slNewLine.txtStore.Text = sStore.Trim();

            slNewLine.txtBatchNum.Text = sBatchNumber;
            slNewLine.txtCode.Text = sCode.Trim();
            slNewLine.txtDescription.Text = sDescription.Trim();
            slNewLine.txtUnit.Text = sUnit.Trim();
            slNewLine.txtQuantity.Text = sQty.Trim();
            slNewLine.txtExcPrice.Text = (Convert.ToDouble(sExcPrice.Trim())).ToString("N2");
            slNewLine.txtDiscount.Text = sDiscount.Trim();
            slNewLine.txtTaxType.Text = sTaxType.Trim();

            slNewLine.txtLinkNum.Text = sLinkNum.Trim();

            if (sTaxType == "0")
            {
                slNewLine.txtNet.BackColor = Color.Yellow;
            }

            double dTotalExDiscount = Convert.ToDouble(slNewLine.txtQuantity.Text.Replace(",", "")) * Convert.ToDouble(slNewLine.txtExcPrice.Text.Replace(",", ""));

            slNewLine.txtNet.Text = (dTotalExDiscount - (dTotalExDiscount * (Convert.ToDouble(slNewLine.txtDiscount.Text.Replace(",", "")) / 100))).ToString("N2");

            slNewLine.bDoCalculation = true;
            AddSupplDocLine(slNewLine);
        }
예제 #7
0
        public void InsertSalesLine(int iLineIndex, SupplDocLine slNewLine)
        {
            for (int iLines = 0; iLines < aSupplDoclines.Length; iLines++)
            {
                SupplDocLine slThisline = (((SupplDocLine)aSupplDoclines[iLines]));

                if (slThisline.iLineIndex == iLineIndex)//start line
                {
                    Array.Resize<Control>(ref aSupplDoclines, aSupplDoclines.Length + 1);//Add new row
                    iLineRowIndex++;
                    for (int iShiftLines = aSupplDoclines.Length - 1; iShiftLines > iLines + 1; iShiftLines--)
                    {
                        aSupplDoclines[iShiftLines] = aSupplDoclines[iShiftLines - 1];
                        (((SupplDocLine)aSupplDoclines[iShiftLines])).Location = new Point((((SupplDocLine)aSupplDoclines[iShiftLines - 1])).Location.X, (((SupplDocLine)aSupplDoclines[iShiftLines - 1])).Location.Y + 20); // move location of control to new position
                        (((SupplDocLine)aSupplDoclines[iShiftLines])).iLineIndex++;//sync the lineindex of the control array
                    }
                    aSupplDoclines[iLines + 1] = slNewLine;
                    slNewLine.Top = 17 + ((iLineIndex + 1) * 20);
                    slNewLine.Left = 4;
                    if (slNewLine.txtStore.Text == "")
                    {
                        slNewLine.txtStore.Text = Global.sDefaultStore;
                    }
                    slNewLine.TabIndex = 50 + aSupplDoclines.Length;
                    slNewLine.TabStop = true;
                    slNewLine.iLineIndex = iLines + 1;
                    slNewLine.Name = "slNewLine_" + (aSupplDoclines.Length - 1).ToString();
                    this.pnlDetails.Controls.Add(slNewLine);
                    slNewLine.BringToFront();
                    return;
                }
            }
        }
예제 #8
0
        public void focusNextLine(int iLineIndex)
        {
            if (iLineIndex >= aSupplDoclines.Length && txtNumber.Text == "*NEW*")
            {
                SupplDocLine slNewline = new SupplDocLine();
                AddSupplDocLine(slNewline);
            }

            SupplDocLine slNewLine = (SupplDocLine)aSupplDoclines[iLineIndex];
            slNewLine.txtBatchNum.Focus(); //JR13 6/8/2011
        }
예제 #9
0
        private void manageFrontEnd()
        {
            Control cntSelectedControl = this.ActiveControl;

            switch (cntSelectedControl.Name)
            {
                case "selDocumentType":
                    txtNumber.Focus();
                    break;
                case "txtNumber":
                    if (txtNumber.Text == "")
                    {
                        cmdSearchNumber_Click(null, null);
                        txtNumber.Focus();

                    }
                    else if (txtNumber.Text != "*NEW*")
                    {
                        loadDocumentDetail(txtNumber.Text);
                        txtSupplierCode.Focus();

                    }
                    else
                    {
                        txtSupplierCode.Focus();
                        lblOpen.Visible = true;
                    }
                    break;
                case "txtSupplierCode":
                    if (txtSupplierCode.Text == "")
                    {
                        findSupplier();
                    }
                    else
                    {
                        loadSupplier(false, false);
                        if (aSupplDoclines.Length == 0)
                        {
                            SupplDocLine slNewLine = new SupplDocLine();
                            AddSupplDocLine(slNewLine);
                        }
                        dtDate.Focus();
                    }
                    break;
                case "dtDate":
                    txtSalesCode.Focus();
                    break;
                case "txtSalesCode":
                    if (txtSalesCode.Text == "")
                    {
                        cmdSalesPerson_Click(null, null);
                        txtDiscount.Focus();
                    }
                    else
                    {
                        txtDiscount.Focus();
                    }
                    txtDiscount.Focus();
                    break;
                case "txtDiscount":
                    dtDeliveryDate.Focus();
                    break;
                case "dtDeliveryDate":
                    txtOrderNumber.Focus();
                    break;
                case "txtOrderNumber":
                    focusNextLine(0);
                    break;
                case "txtRounding":
                    cmdSaveOrder.Focus();
                    break;

            }
        }
예제 #10
0
        public void deleteSupplDocLine(SupplDocLine slDeletedLine, bool bDeleteLastLine)
        {
            bool bDeleteControl = false;
            for (int iLines = 0; iLines < aSupplDoclines.Length; iLines++)
            {
                SupplDocLine slThisline = (((SupplDocLine)aSupplDoclines[iLines]));

                if (iLines != aSupplDoclines.Length - 1 || bDeleteLastLine) //Never delete the last row
                {
                    if (slDeletedLine.Name == slThisline.Name)
                    {
                        bDeleteControl = true;
                        this.pnlDetails.Controls.Remove(slDeletedLine);
                        if (iLines != aSupplDoclines.Length - 1)
                        {
                            (((SupplDocLine)aSupplDoclines[iLines + 1])).txtCode.Focus(); // focus on the next line
                        }
                    }
                    if (bDeleteControl && iLines != aSupplDoclines.Length - 1) //resize the line array
                    {
                        aSupplDoclines[iLines] = aSupplDoclines[iLines + 1]; //Move all the controls one up in the list
                        (((SupplDocLine)aSupplDoclines[iLines + 1])).Location = new Point((((SupplDocLine)aSupplDoclines[iLines + 1])).Location.X, (((SupplDocLine)aSupplDoclines[iLines + 1])).Location.Y - 20); // move location of control to new position
                        (((SupplDocLine)aSupplDoclines[iLines + 1])).iLineIndex--;//sync the lineindex of the control array
                    }
                }
            }
            addTotals();
            if (bDeleteControl)//update the line array
            {
                Array.Resize<Control>(ref aSupplDoclines, aSupplDoclines.Length - 1);
                iLineRowIndex--;
            }
        }