Exemplo n.º 1
0
        private void updateForm(string invoiceNo)
        {
            invoice = new InvoiceDetails();
            invoicePrinter.Invoice = invoice;
            invoice.InvoiceNumber = invoiceNo.ToUpper();
            bool exist_invoiceNo_DBCK = false;

            if (openMySQLConnection() == true)
            {
                exist_invoiceNo_DBCK = check_invoiceNo_DBCK(invoice.InvoiceNumber);

                if (exist_invoiceNo_DBCK)
                {
                    txtInvalidInv.Visible = false;
                    get_invoiceNo_DBCK(invoice.InvoiceNumber);
                }
                else
                {
                    SendInvoiceNo(invoice.InvoiceNumber);
                    get_invoiceNo_DBCK(invoice.InvoiceNumber);
                    exist_invoiceNo_DBCK = true;
                }
                closeMySQLConnection();
            }

            //bool print_label = SendInvoiceNo(invoiceNo);
            bool printOut = false;

            //if (print_label)
            if (exist_invoiceNo_DBCK)
            {
                try
                {
                    //if (temp_comp_name.Substring(0, 11) == "Bright Life" && brightLifeToolStripMenuItem.Checked)
                    if (string.Compare(invoice.CompanyName.Substring(0, 11), "Bright Life", true) == 0 && brightLifeToolStripMenuItem.Checked)
                    {
                        printOut = true;
                    }
                    //else if (temp_comp_name.Substring(0, 7) == "Fairfax" && fairFaxToolStripMenuItem.Checked)
                    else if (string.Compare(invoice.CompanyName.Substring(0, 7), "Fairfax", true) == 0 && fairFaxToolStripMenuItem.Checked)
                    {
                        printOut = true;
                    }
                    //else if (temp_comp_name.Substring(0, 11) == "Swisstrade" && swissTradeToolStripMenuItem.Checked)
                    else if (string.Compare(invoice.CompanyName.Substring(0, 11), "Swisstrade", true) == 0 && swissTradeToolStripMenuItem.Checked)
                    {
                        printOut = true;
                    }
                }
                catch
                {
                    printOut = false;
                }

                if (printOut)
                {
                    invoicePrinter.print();
                }
            }

            tbInputInvNo.SelectAll();
            tbInputInvNo.Focus();
        }
Exemplo n.º 2
0
        private bool SendInvoiceNo(string invoiceNo)
        {
            LabelPrint ws = new LabelPrint();
            //ws.UseDefaultCredentials = true;
            //ws.Credentials = new NetworkCredential(tbxUsername.Text, tbxPassword.Text, tbxDomain.Text);
            ws.UseDefaultCredentials = false;
            ws.Credentials = new NetworkCredential("labelprinter", "BLL@b3l", "BRIGHTLIFE");
            ws.Url = "http://192.5.10.11:7047/DynamicsNAV/WS/Bright%20Life%20Australia/Codeunit/LabelPrint";

            //string clientID = "";
            string custNo = "";
            string address1 = "";
            string address2 = "";
            //string address3 = "";
            string title = "";
            string surname = "";
            string firstName = "";
            string middleName = "";
            string city = "";//maroubra
            string postcode = "1234";
            string state = "";//nsw
            string countryCode = "";
            DateTime labelPrintedDateTime = new DateTime();
            string companyName = "";
            string companyABN = "";
            string companyAddress = "";
            string phoneNumber = "";
            string emailAddress = "";
            bool successful = false;
            try
            {
                successful = ws.PrintLabelWSv2(invoiceNo, ref custNo, ref title, ref firstName, ref middleName,
                    ref surname, ref address1, ref address2, ref city, ref postcode, ref state, ref countryCode,
                    ref labelPrintedDateTime, ref companyName, ref companyABN, ref companyAddress, ref phoneNumber, ref emailAddress);
            }
            catch(Exception ex)
            {
                MessageBox.Show("Please contact IT Team.\n\n" + ex.ToString(), "Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }

            if (successful)
            {
                txtInvalidInv.Visible = false;

                invoice.CustomerNumber = custNo.ToUpper();
                invoice.Address1 = address1;
                invoice.Address2 = address2;
                invoice.Title = title;
                invoice.Firstname = firstName;
                invoice.Middlename = middleName;
                invoice.Lastname = surname;
                invoice.Town = city;
                invoice.Postcode = postcode;
                invoice.State = state;
                invoice.CountryCode = countryCode;
                invoice.CompanyName = companyName;
                invoice.ABN = companyABN;
                invoice.PhoneNumber = phoneNumber;
                invoice.EmailAddress = emailAddress;
                if (companyName == "Bright Life Australia")
                {
                    invoice.ReturnAddress = "PO Box 6555 Frenchs Forest NSW 2086";
                }
                else if (companyName == "Fairfax")
                {
                    invoice.ReturnAddress = "REPLY PAID 7023 SYDNEY NSW 2001";
                    invoice.ABN = "15 008 663 161";
                }

                else
                {
                    invoice.ReturnAddress = companyAddress;
                }

                DateTime utcNow = DateTime.UtcNow;
                string query = string.Format("INSERT INTO ps_invoice_info_nav (invoiceNo, custNo, address1, address2, title, surName, firstName, middleName, city, postcode, state, countryCode, companyName, companyABN, companyAddress, time_created, phoneNumber, emailAddress) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}')",
                    replace_quote(invoice.InvoiceNumber),
                    replace_quote(invoice.CustomerNumber),
                    replace_quote(invoice.Address1),
                    replace_quote(invoice.Address2),
                    replace_quote(invoice.Title),
                    replace_quote(invoice.Lastname),
                    replace_quote(invoice.Firstname),
                    replace_quote(invoice.Middlename),
                    replace_quote(invoice.Town),
                    replace_quote(invoice.Postcode),
                    replace_quote(invoice.State),
                    replace_quote(invoice.CountryCode),
                    replace_quote(invoice.CompanyName),
                    replace_quote(invoice.ABN),
                    replace_quote(invoice.ReturnAddress),
                    String.Format("{0:yyyy'-'MM'-'dd' 'HH':'mm':'ss}", utcNow),
                    replace_quote(invoice.PhoneNumber),
                    replace_quote(invoice.EmailAddress));

                MySqlCommand cmd = new MySqlCommand(query, SQLConnection);
                cmd.ExecuteNonQuery();
            }
            else
            {
                txtInvalidInv.Visible = true;

                invoice = new InvoiceDetails();
            }
            //setCompanyInfo();

            updateCompanyInfo();

            return successful;
        }