示例#1
0
        public void AddDeliveryLine(ProjectDeliveryNote qlNewLine, bool bLoad)
        {
            if (!bLoad)
            {
                Array.Resize<Control>(ref aDeliverylines, aDeliverylines.Length + 1);
                aDeliverylines[aDeliverylines.Length - 1] = qlNewLine;
                if (iLineRowIndex < 20)
                    qlNewLine.Top = 22 + ((iLineRowIndex) * 20);
                else
                    qlNewLine.Top = 408; //16 + ((iLineRowIndex) * 18);

                qlNewLine.Left = 1;

                qlNewLine.TabIndex = 50 + aDeliverylines.Length;
                qlNewLine.TabStop = true;

                qlNewLine.iLineIndex = aDeliverylines.Length - 1;
                qlNewLine.Name = "qlNewLine_" + (aDeliverylines.Length - 1).ToString();

                this.pnlDetails.Controls.Add(qlNewLine);
                qlNewLine.BringToFront();
                iLineRowIndex++;
            }
            else
            {
                Array.Resize<Control>(ref aDeliverylines, aDeliverylines.Length + 1);
                aDeliverylines[aDeliverylines.Length - 1] = qlNewLine;

                qlNewLine.Top = 22 + ((iLineRowIndex) * 20);

                qlNewLine.Left = 1;

                qlNewLine.TabIndex = 50 + aDeliverylines.Length;
                qlNewLine.TabStop = true;

                qlNewLine.iLineIndex = aDeliverylines.Length - 1;
                qlNewLine.Name = "qlNewLine_" + (aDeliverylines.Length - 1).ToString();

                this.pnlDetails.Controls.Add(qlNewLine);
                qlNewLine.BringToFront();
                iLineRowIndex++;
            }
        }
示例#2
0
        private void LoadLines(string sItemCode, string sQty,  string sDescription,  string sLinkNum, string sUnit)
        {
            ProjectDeliveryNote qlNewLine = new ProjectDeliveryNote();
            qlNewLine.bDoCalculation = false;
            qlNewLine.txtCode.Text = sItemCode;
            qlNewLine.txtUnit.Text = sUnit;
            qlNewLine.txtDescription.Text = sDescription;
            qlNewLine.txtQuantity.Text = sQty;
            qlNewLine.txtQuantity.ReadOnly = true;
            //calculate available qty
            if (txtProject.Text != "")
            {
                decimal dQuoteQty = 0;
                using (PsqlConnection oConn3 = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
                {
                    oConn3.Open();
                    string sSql2 = "select SUM(SOLQHL.Qty) as Qty from SOLQHH";
                    sSql2 += " inner join SOLQHL on SOLQHH.Docnumber = SOLQHL.Docnumber";
                    sSql2 += " where Project = '" + txtProject.Text.Trim().Replace("'", "''") + "' and ItemCode = '" + sItemCode.Trim() + "'"; ;

                    PsqlDataReader rdReader2 = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql2, oConn3).ExecuteReader();
                    while (rdReader2.Read())
                    {
                        dQuoteQty = Convert.ToDecimal(rdReader2["Qty"].ToString());

                    }
                    rdReader2.Close();
                    oConn3.Dispose();
                }

                decimal dDelNoteQty = 0;
                decimal dRetNoteQty = 0;
                decimal dTotalAvailableQty = 0;
                //get del note Qty
                using (PsqlConnection oConn2 = new PsqlConnection(Connect.sConnStr))
                {
                    string sSql2 = "select SOLPDL.ItemCode,SUM(SOLPDL.Qty) AS Qty from SOLPDH";
                    sSql2 += " left join SOLPDL on SOLPDL.Docnumber = SOLPDH.Docnumber";
                    sSql2 += " where Project = '" + txtProject.Text.Trim().Replace("'", "''") + "' AND ItemCode = '" + sItemCode.Trim() + "'";
                    sSql2 += "group by itemcode";
                    PsqlDataReader rdReader2 = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql2, oConn2).ExecuteReader();
                    while (rdReader2.Read())
                    {
                        dDelNoteQty = Convert.ToDecimal(rdReader2["Qty"].ToString());

                    }
                    rdReader2.Close();
                    //get ret note qty

                    string sSqlRN = "select SOLPRL.ItemCode,SUM(SOLPRL.Qty) AS Qty from SOLPRH";
                    sSqlRN += " left join SOLPRL on SOLPRL.Docnumber = SOLPRH.Docnumber";
                    sSqlRN += " where Project = '" + txtProject.Text.Trim().Replace("'", "''") + "' AND ItemCode = '" + sItemCode.Trim() + "'";
                    sSqlRN += "group by itemcode";
                    PsqlDataReader rdReader3 = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSqlRN, oConn2).ExecuteReader();
                    while (rdReader3.Read())
                    {
                        dRetNoteQty = Convert.ToDecimal(rdReader3["Qty"].ToString());

                    }

                    rdReader2.Close();
                    oConn2.Dispose();
                    dTotalAvailableQty = (Convert.ToDecimal(dQuoteQty - dDelNoteQty) + dRetNoteQty);
                    qlNewLine.txtAvlQty.Text = dTotalAvailableQty.ToString("N2");
                }
            }
            AddDeliveryLine(qlNewLine,true);
            qlNewLine.bDoCalculation = true;
        }
示例#3
0
 private void cmdNewLine_Click(object sender, EventArgs e)
 {
     ProjectDeliveryNote qlNewline = new ProjectDeliveryNote();
     AddDeliveryLine(qlNewline,false);
     qlNewline.bNextLine = true;
     qlNewline.txtCode.Focus();
     qlNewline.bFocusOnNextLine = false;
 }
示例#4
0
 public void focusNextLine(int iLineIndex)
 {
     //LL 17/09/2009 - start
     if ((iLineIndex >= aDeliverylines.Length && txtNumber.Text == "*NEW*") || (iLineIndex >= aDeliverylines.Length && txtNumber.Text == ""))
     {
         if (txtNumber.Text == "")
             txtNumber.Text = "*NEW*";
         //LL 17/09/2009 - end
         ProjectDeliveryNote qlNewline = new ProjectDeliveryNote();
         AddDeliveryLine(qlNewline,false);
     }
     if (iLineIndex < aDeliverylines.Length)
     {
         ProjectDeliveryNote qlNewLine = (ProjectDeliveryNote)aDeliverylines[iLineIndex];
         qlNewLine.txtCode.Focus();
     }
 }
示例#5
0
        public void deleteSalesLine(ProjectDeliveryNote qlDeletedLine, bool bDeleteLastLine)
        {
            bool bDeleteControl = false;
            for (int iLines = 0; iLines < aDeliverylines.Length; iLines++)
            {
                ProjectDeliveryNote qlThisline = (((ProjectDeliveryNote)aDeliverylines[iLines]));

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

            //Check if you want to close the order
            if (aDeliverylines.Length == 0)
            {
                if (MessageBox.Show("There are no more lines in this order. Do you want to close this order?", "Close Order?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Functions.CloseOrder(txtNumber.Text.Trim());
                }
            }
        }
        private bool Populate_Inventory_Fields(ref ProjectDeliveryNote pdnDelivery, bool bFocusDescription)
        {
            bool bExist = false;
            string sProject = ((Forms.Project.DeliveryNote)(Parent.Parent.Parent.Parent)).txtProject.Text;

            if (sProject == "")
            {
                if (pdnDelivery.txtCode.Text == "'")
                {
                    pdnDelivery.txtDescription.ReadOnly = false;
                    pdnDelivery.txtLastInvoiceDate.Text = "";
                    pdnDelivery.txtQuantity.ReadOnly = true;
                    pdnDelivery.txtQuantity.Text = "0.00";
                    pdnDelivery.txtUnit.ReadOnly = true;
                    pdnDelivery.txtDescription.Focus();
                    pdnDelivery.bDoCalculation = false;
                    bAllowDuplicateLines = false;
                    return true;
                }
                else
                {
                    pdnDelivery.txtQuantity.ReadOnly = false;
                    pdnDelivery.txtDescription.ReadOnly = false;

                    pdnDelivery.bDoCalculation = true;
                    using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr))
                    {
                        oConn.Open();
                        string sSql = "SELECT distinct  Inventory.*, MultiStoreTrn.SellExcl01 from Inventory left join MultiStoreTrn on Inventory.ItemCode = MultiStoreTrn.ItemCode";
                        sSql += " where Inventory.ItemCode = '" + pdnDelivery.txtCode.Text.Trim() + "'";
                        sSql += " AND MultiStoreTrn.StoreCode <> ''";

                        PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader();
                        while (rdReader.Read())
                        {
                            if (!bNextLine)
                            {
                                bNextLine = true;
                                ProjectDeliveryNote qlNewline = new ProjectDeliveryNote();
                                ((Forms.Project.DeliveryNote)(Parent.Parent.Parent.Parent)).AddDeliveryLine(qlNewline,false);

                            }
                            pdnDelivery.txtDescription.Text = rdReader["Description"].ToString().Trim();
                            pdnDelivery.sLineType = Functions.getLineInventoryType(pdnDelivery.txtCode.Text.Trim());
                            pdnDelivery.txtUnit.Text = rdReader["UnitSize"].ToString();
                            pdnDelivery.txtDescription.Focus();
                            bExist = true;
                        }//end while
                        rdReader.Close();
                        oConn.Dispose();

                            }

                        }
                        if (!bExist)
                        {
                            MessageBox.Show("Code does not exist.", "Inventory Not Found", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            pdnDelivery.txtDescription.ReadOnly = true;
                            return false;
                        }
                        else
                        {

                        }
                        return true;
                }
                else
                {
                    if (pdnDelivery.txtCode.Text == "'")
                    {
                        pdnDelivery.txtDescription.ReadOnly = false;
                        pdnDelivery.txtLastInvoiceDate.Text = "";
                        pdnDelivery.txtQuantity.ReadOnly = true;
                        pdnDelivery.txtQuantity.Text = "0.00";
                        pdnDelivery.txtUnit.ReadOnly = true;
                        pdnDelivery.txtDescription.Focus();
                        pdnDelivery.bDoCalculation = false;
                        bAllowDuplicateLines = false;
                        return true;
                    }
                    else if (!bNextLine)
                    {
                            bNextLine = true;
                            ProjectDeliveryNote qlNewline = new ProjectDeliveryNote();
                            ((Forms.Project.DeliveryNote)(Parent.Parent.Parent.Parent)).AddDeliveryLine(qlNewline,false);
                    }
                    return true;
                }
        }
        private void cmdCodeSearch_Click(object sender, EventArgs e)
        {
            Cursor = System.Windows.Forms.Cursors.WaitCursor;
            string sProject = ((Forms.Project.DeliveryNote)(Parent.Parent.Parent.Parent)).txtProject.Text;
            if (sProject == "")
            {
                using (Finder.Inventory frmInventory = new Solsage_Process_Management_System.Finder.Inventory())
                {
                    sQuoteNumber = "";

                    //Sending "None" to inventory ShowDialog to identify that no workshop action should be taken

                    if (frmInventory.ShowDialog("", "", sProject) == DialogResult.OK)
                    {
                        if (frmInventory.sResult != "")
                        {
                            //check if this item has been selected...
                            if (((Forms.Project.DeliveryNote)(Parent.Parent.Parent.Parent)).CheckDuplicateSalesLine(frmInventory.sResult))
                            {
                                MessageBox.Show("No duplicate items are allowed in a sales order. Please select another inventory item.", "Duplicates", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                txtCode.Text = frmInventory.sResult.Trim();
                                txtDescription.Text = frmInventory.sDescription.Trim();
                                sQuoteNumber = frmInventory.sQuoteNumber.Trim();
                                ProjectDeliveryNote pdlDeliveryNote = this;
                                ProjectDeliveryNote pdlLastControl = this;
                                bool bValid = Populate_Inventory_Fields(ref pdlDeliveryNote, true);
                                txtCode.Focus();
                                txtCode.SelectionStart = 0;
                                txtCode.SelectionLength = txtCode.Text.Length;
                            }
                        }
                    }
                }
            }
            else
            {
                using (Finder.DeliverynoteItemZoom frmDelNoteItemZoom = new Finder.DeliverynoteItemZoom())
                {
                    sQuoteNumber = "";

                    //Sending "None" to inventory ShowDialog to identify that no workshop action should be taken

                    if (frmDelNoteItemZoom.ShowDialog(sProject) == DialogResult.OK)
                    {
                        if (frmDelNoteItemZoom.ItemList.Count != 0)
                        {
                            ItemList = frmDelNoteItemZoom.ItemList;
                            if (ItemList.Count == 1)
                            {

                                foreach (string sItem in ItemList)
                                {
                                    string[] aItemDetails = sItem.Split("|".ToCharArray());
                                    txtCode.Text = aItemDetails[0].ToString();
                                    txtDescription.Text = aItemDetails[1].ToString();
                                    //txtAvlQty.Text = aItemDetails[2].ToString();
                                      //calculate available qty
                                            if (sProject != "")
                                            {
                                                decimal dQuoteQty = 0;
                                                using (PsqlConnection oConn3 = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
                                                {
                                                    oConn3.Open();
                                                    string sSql2 = "select SUM(SOLQHL.Qty) as Qty from SOLQHH";
                                                    sSql2 += " inner join SOLQHL on SOLQHH.Docnumber = SOLQHL.Docnumber";
                                                    sSql2 += " where Project = '" + sProject.Trim() + "' and ItemCode = '" + txtCode.Text.Trim() + "'";

                                                    PsqlDataReader rdReader2 = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql2, oConn3).ExecuteReader();
                                                    while (rdReader2.Read())
                                                    {
                                                        dQuoteQty = Convert.ToDecimal(rdReader2["Qty"].ToString());

                                                    }
                                                    rdReader2.Close();
                                                    oConn3.Dispose();
                                                }

                                                decimal dDelNoteQty = 0;
                                                decimal dRetNoteQty = 0;
                                                decimal dTotalAvailableQty = 0;
                                                        //get del note Qty
                                                        using (PsqlConnection oConn2 = new PsqlConnection(Connect.sConnStr))
                                                        {
                                                            string sSql2 = "select SOLPDL.ItemCode,SUM(SOLPDL.Qty) AS Qty from SOLPDH";
                                                            sSql2 += " left join SOLPDL on SOLPDL.Docnumber = SOLPDH.Docnumber";
                                                            sSql2 += " where Project = '" + sProject.Trim().Replace("'", "''") + "' AND ItemCode = '" + txtCode.Text.Trim() + "'";
                                                            sSql2 += "group by itemcode";
                                                            PsqlDataReader rdReader2 = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql2, oConn2).ExecuteReader();
                                                            while (rdReader2.Read())
                                                            {
                                                                dDelNoteQty = Convert.ToDecimal(rdReader2["Qty"].ToString());

                                                            }
                                                            rdReader2.Close();
                                                            //get ret note qty

                                                            string sSqlRN = "select SOLPRL.ItemCode,SUM(SOLPRL.Qty) AS Qty from SOLPRH";
                                                            sSqlRN += " left join SOLPRL on SOLPRL.Docnumber = SOLPRH.Docnumber";
                                                            sSqlRN += " where Project = '" + sProject.Trim().Replace("'", "''") + "' AND ItemCode = '" + txtCode.Text.Trim() + "'";
                                                            sSqlRN += "group by itemcode";
                                                            PsqlDataReader rdReader3 = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSqlRN, oConn2).ExecuteReader();
                                                            while (rdReader3.Read())
                                                            {
                                                                dRetNoteQty = Convert.ToDecimal(rdReader3["Qty"].ToString());

                                                            }

                                                            rdReader2.Close();
                                                            oConn2.Dispose();
                                                            dTotalAvailableQty = (Convert.ToDecimal(dQuoteQty - dDelNoteQty) + dRetNoteQty);
                                                            txtAvlQty.Text = dTotalAvailableQty.ToString("N2");
                                                            txtQuantity.Text = dTotalAvailableQty.ToString("N2");
                                                        }

                                                    }

                                    txtUnit.Text = aItemDetails[3].ToString();
                                    ProjectDeliveryNote pdlDeliveryNote = this;
                                    ProjectDeliveryNote pdlLastControl = this;
                                    bool bValid = Populate_Inventory_Fields(ref pdlDeliveryNote, true);
                                }
                            }
                            else
                            {

                                foreach (string sItem in ItemList)
                                {
                                    string[] aItemDetails = sItem.Split("|".ToCharArray());
                                    this.removeLine(null, null);
                                    //txtCode.Text = aItemDetails[0].ToString();
                                    //txtDescription.Text = aItemDetails[1].ToString();
                                    //txtQuoteQty.Text = aItemDetails[2].ToString();
                                    //txtUnit.Text = aItemDetails[3].ToString();
                                    //ProjectDeliveryNote pdlDeliveryNote = this;
                                    ProjectDeliveryNote pdlDelNote = new ProjectDeliveryNote();
                                    pdlDelNote.txtCode.Text = aItemDetails[0].ToString();
                                    pdlDelNote.txtDescription.Text = aItemDetails[1].ToString();
                                    //pdlDelNote.txtAvlQty.Text = aItemDetails[2].ToString();
                                            //calculate available qty
                                            if (sProject != "")
                                            {
                                                decimal dQuoteQty = 0;
                                                using (PsqlConnection oConn3 = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
                                                {
                                                    oConn3.Open();
                                                    string sSql2 = "select SUM(SOLQHL.Qty) as Qty from SOLQHH";
                                                    sSql2 += " inner join SOLQHL on SOLQHH.Docnumber = SOLQHL.Docnumber";
                                                    sSql2 += " where Project = '" + sProject.Trim() + "' and ItemCode = '" + pdlDelNote.txtCode.Text.Trim() + "'";

                                                    PsqlDataReader rdReader2 = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql2, oConn3).ExecuteReader();
                                                    while (rdReader2.Read())
                                                    {
                                                        dQuoteQty = Convert.ToDecimal(rdReader2["Qty"].ToString());

                                                    }
                                                    rdReader2.Close();
                                                    oConn3.Dispose();
                                                }

                                                decimal dDelNoteQty = 0;
                                                decimal dRetNoteQty = 0;
                                                decimal dTotalAvailableQty = 0;
                                                //get del note Qty
                                                using (PsqlConnection oConn2 = new PsqlConnection(Connect.sConnStr))
                                                {
                                                    string sSql2 = "select SOLPDL.ItemCode,SUM(SOLPDL.Qty) AS Qty from SOLPDH";
                                                    sSql2 += " left join SOLPDL on SOLPDL.Docnumber = SOLPDH.Docnumber";
                                                    sSql2 += " where Project = '" + sProject.Trim().Replace("'", "''") + "' AND ItemCode = '" + pdlDelNote.txtCode.Text.Trim() + "'";
                                                    sSql2 += "group by itemcode";
                                                    PsqlDataReader rdReader2 = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql2, oConn2).ExecuteReader();
                                                    while (rdReader2.Read())
                                                    {
                                                        dDelNoteQty = Convert.ToDecimal(rdReader2["Qty"].ToString());

                                                    }
                                                    rdReader2.Close();
                                                    //get ret note qty

                                                    string sSqlRN = "select SOLPRL.ItemCode,SUM(SOLPRL.Qty) AS Qty from SOLPRH";
                                                    sSqlRN += " left join SOLPRL on SOLPRL.Docnumber = SOLPRH.Docnumber";
                                                    sSqlRN += " where Project = '" + sProject.Trim().Replace("'", "''") + "' AND ItemCode = '" + pdlDelNote.txtCode.Text.Trim() + "'";
                                                    sSqlRN += "group by itemcode";
                                                    PsqlDataReader rdReader3 = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSqlRN, oConn2).ExecuteReader();
                                                    while (rdReader3.Read())
                                                    {
                                                        dRetNoteQty = Convert.ToDecimal(rdReader3["Qty"].ToString());

                                                    }

                                                    rdReader2.Close();
                                                    oConn2.Dispose();
                                                    dTotalAvailableQty = (Convert.ToDecimal(dQuoteQty - dDelNoteQty) + dRetNoteQty);
                                                    pdlDelNote.txtAvlQty.Text = dTotalAvailableQty.ToString("N2");
                                                    pdlDelNote.txtQuantity.Text = dTotalAvailableQty.ToString("N2");
                                                }

                                            }

                                    pdlDelNote.txtUnit.Text = aItemDetails[3].ToString();
                                    //ProjectDeliveryNote pdlLastControl = this;
                                    //bool bValid = Populate_Inventory_Fields(ref pdlDeliveryNote, false, iLineIndex);
                                    ((Forms.Project.DeliveryNote)(Parent.Parent.Parent.Parent)).AddDeliveryLine(pdlDelNote,true);

                                }
                                ProjectDeliveryNote pdlDelNoteNew = new ProjectDeliveryNote();
                                ((Forms.Project.DeliveryNote)(Parent.Parent.Parent.Parent)).AddDeliveryLine(pdlDelNoteNew,true);
                                ((Forms.Project.DeliveryNote)(Parent.Parent.Parent.Parent)).deleteSalesLine(this, true);

                            }

                                //txtCode.Text = frmDelNoteItemZoom.sItemCode.Trim();
                                //txtDescription.Text = frmDelNoteItemZoom.sDescription.Trim();
                                //sQuoteNumber = frmDelNoteItemZoom.sQuoteNumber.Trim();
                                //ProjectDeliveryNote pdlDeliveryNote = this;
                                //ProjectDeliveryNote pdlLastControl = this;
                                //bool bValid = Populate_Inventory_Fields(ref pdlDeliveryNote, true);
                                //txtCode.Focus();
                                //txtCode.SelectionStart = 0;
                                //txtCode.SelectionLength = txtCode.Text.Length;

                        }
                    }

                }

            }
            Cursor = System.Windows.Forms.Cursors.Default;
        }