Exemplo n.º 1
0
        private void cmdPrintDepotInvoice_Click(object sender, EventArgs e)
        {
            if (rptInvoice == null)
            {
                MessageBox.Show("Please select an invoice first.");
                return;
            }
            else
            {
                Cursor = System.Windows.Forms.Cursors.WaitCursor;
                string sInvoiceNumber = selInvoices.Text.Substring(0, selInvoices.Text.IndexOf("-")).Trim();
                //Send file to workstation
                if (!Directory.Exists(Application.StartupPath + "\\Temp"))
                {
                    Directory.CreateDirectory(Application.StartupPath + "\\Temp");
                }
                string sFilename = sInvoiceNumber + ".rpt";
                if (File.Exists(Application.StartupPath + "\\Temp\\" + sFilename))
                {
                    File.Delete(Application.StartupPath + "\\Temp\\" + sFilename);
                }
                //                            reportDelivery.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Application.StartupPath + "\\Temp\\" + sFilename);
                rptInvoice.SaveAs(Application.StartupPath + "\\Temp\\" + sFilename, true);

                Solsage_Process_Management_System.Forms.SendToDepot frmDepot = new Solsage_Process_Management_System.Forms.SendToDepot();
                frmDepot.sFilename = Application.StartupPath + "\\Temp\\" + sFilename;
                frmDepot.sHostAddress = ConfigurationSettings.AppSettings.Get("PrintToDepotAddress").ToString();
                frmDepot.sFtpUsername = ConfigurationSettings.AppSettings.Get("ftpUsername").ToString();
                frmDepot.sFtpPassword = ConfigurationSettings.AppSettings.Get("ftpPassword").ToString();

                frmDepot.ShowDialog();
                Cursor = System.Windows.Forms.Cursors.Default;

            }
        }
Exemplo n.º 2
0
        private void cmdPrintToDepot_Click(object sender, EventArgs e)
        {
            Cursor = System.Windows.Forms.Cursors.WaitCursor;
            string sCollected = "DELIVERED";
            if (chkCollected.Checked)
                sCollected = "COLLECTED";
            else
                sCollected = "DELIVERED";

            PrintDialog pdPrint = new PrintDialog();

            Solsage_Process_Management_System.Classes.Generate.printDeliveryNote(((Main)this.MdiParent), txtNumber.Text, "", "", txtCoordinates.Text, sCollected, false, true, pdPrint);
            string sFilename = Solsage_Process_Management_System.Classes.Generate.sDepotFilename;
            Solsage_Process_Management_System.Forms.SendToDepot frmDepot = new Solsage_Process_Management_System.Forms.SendToDepot();
            frmDepot.sFilename = sFilename;
            frmDepot.sHostAddress = ConfigurationSettings.AppSettings.Get("PrintToDepotAddress").ToString();
            frmDepot.sFtpUsername = ConfigurationSettings.AppSettings.Get("ftpUsername").ToString();
            frmDepot.sFtpPassword = ConfigurationSettings.AppSettings.Get("ftpPassword").ToString();

            frmDepot.ShowDialog();
            Cursor = System.Windows.Forms.Cursors.Default;
        }
Exemplo n.º 3
0
        public void cmdCreateInvoice_Click(object sender, EventArgs e)
        {
            string[] aInvoiceLines = new string[0];
            ArrayList alLinesdata = new ArrayList();
            string[] aGetnewlinedata = new string[8];
            if (Global.bAutoInvoiceOnReturn || MessageBox.Show("This will create a Tax Invoice. Are You Sure?", "Create Invoice", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)//don't ask are you sure if global invoicing is on
            {
                foreach (DataGridViewRow dgRow in dgInvoiceItems.Rows)
                {
                    if (dgRow.Cells["clInvoice"] != null && dgRow.Cells["clInvoice"].Value.ToString() == "True")
                    {
                        addInvoiceLine(sDocNumber, dgRow.Cells["clItemCode"].Value.ToString(), dgRow.Cells["clNumber"].Value.ToString(),ref aInvoiceLines, dgRow.Cells["clTypeCode"].Value.ToString(), dgRow.Cells["clDeliveryDate"].Value.ToString(), dgRow.Cells["clReturnDate"].Value.ToString());
                    }
                }
            }
            else
            {
                if (dgInvoiceItems.RowCount > 0)
                {
                    dgInvoiceItems.CurrentCell = dgInvoiceItems.Rows[0].Cells["clInvoice"];
                    this.ActiveControl = dgInvoiceItems;
                }
            }

            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Do Invoicing !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            if (aInvoiceLines.Length > 0)
            {
                Solsage_Process_Management_System.Classes.Generate clsGenerate = new Solsage_Process_Management_System.Classes.Generate();
                string sNewCustomer = ""; //Empty sNewCustomer varaible states that no change has been made
                if (sCustomerCode.Trim() != txtCustomerCode.Text.Trim())
                {
                    sNewCustomer = txtCustomerCode.Text.Trim(); //customer has changed
                }

                string sNewSalesmanCode = "";//Empty sNewSalesmanCode varaible states that no change has been made
                if (Global.sLogedInUserCode.Trim() != txtSalesCode.Text.Trim())
                {
                    sNewSalesmanCode = txtSalesCode.Text.Trim();//Salesman has changed
                }

                string sNewOrderNumber = "";//Empty sNewOrderNumber varaible states that no change has been made
                if (sOrderNumber.Trim() != txtOrderNumber.Text.Trim())
                {
                    sNewOrderNumber = txtOrderNumber.Text.Trim();//Ordernumber has changed
                }
                using (PsqlConnection oPasConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr))
                {
                    oPasConn.Open();

                    string[] aReturn = clsGenerate.CreateCustomerDocument(sDocNumber, 3, aInvoiceLines, sNewCustomer, sNewSalesmanCode, sNewOrderNumber, "", DateTime.Now, oPasConn, "", alLinesdata, sSiteName);
                    if (aReturn[0] == "0")
                    {
                        Cursor = System.Windows.Forms.Cursors.WaitCursor;
                        if (Global.sInvoiceTemplate == "Kings Hire")
                        {
                            if (printDialog1.ShowDialog() == DialogResult.OK)
                            {
                                Solsage_Process_Management_System.Classes.Functions.printInvoice(aReturn[1], true, bPrintToDepot, Global.sLogedInUserCode, printDialog1);
                            }

                        }
                        else
                        {
                            PrintDialog pdPrint = new PrintDialog();
                            Solsage_Process_Management_System.Classes.Functions.printInvoice(aReturn[1], true, bPrintToDepot, Global.sLogedInUserCode, pdPrint);
                        }

                        sInvoiceNumber = aReturn[1];
                        if (bPrintToDepot)
                        {
                            string sFilename = Solsage_Process_Management_System.Classes.Functions .sDepotFilename;
                            Solsage_Process_Management_System.Forms.SendToDepot frmDepot = new Solsage_Process_Management_System.Forms.SendToDepot();
                            frmDepot.sFilename = sFilename;
                            frmDepot.sHostAddress = ConfigurationSettings.AppSettings.Get("PrintToDepotAddress").ToString();
                            frmDepot.sFtpUsername = ConfigurationSettings.AppSettings.Get("ftpUsername").ToString();
                            frmDepot.sFtpPassword = ConfigurationSettings.AppSettings.Get("ftpPassword").ToString();

                            frmDepot.ShowDialog();
                        }
                        Cursor = System.Windows.Forms.Cursors.Default;
                    }
                    else
                    {
                        MessageBox.Show("Error: " + aReturn[1] + "\r\n\r\n Error Number: " + aReturn[0], "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    //Should not be deleted, already happens on Generate
                    //for (int iLines = 0; iLines < aInvoiceLines.Length; iLines++) //only remove from salesorder if invoiced
                    //{
                    //    string sMyLine = aInvoiceLines[iLines];
                    //    sMyLine = sMyLine.Remove(sMyLine.IndexOf("^"), sMyLine.Length - sMyLine.IndexOf("^"));
                    //    if (sMyLine != null && sMyLine.Trim() != "")
                    //    {
                    //        aReturn = clsSDK.EditPastelDocument(sMyLine, 102, sDocNumber, "D", Global.sDataPath).Split("|".ToCharArray());
                    //    }
                    //}
                }
            }

            int iRemainingRows = Functions.GetLiquidSalesLinesQty(sDocNumber);
            if (iRemainingRows == 0)
            {
                using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr))
                {
                    oConn.Open();
                    string sSql = "";
                    int iRet = 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)
                    {
                         sSql = "UPDATE SOLHH SET ";
                        sSql += " Status = 3";
                        sSql += " WHERE DocNumber = '" + sDocNumber + "' ";
                         iRet = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteNonQuery();
                        frmSalesOrder.setSalesOrderStatus(3);
                    }
                    else
                    {
                         sSql = "UPDATE SOLHH SET ";
                        sSql += " Status = 2 ";
                        sSql += " WHERE DocNumber = '" + sDocNumber + "' ";
                        iRet = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteNonQuery();
                        frmSalesOrder.setSalesOrderStatus(2);

                    }
                    oConn.Dispose();
                }
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        }