Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (Tabs_cbx.Text == "")
            {
                MessageBox.Show("Please Select a Tab", "Select a Tab", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Tabs_cbx.Focus();
                return;
            }
            //Excel.Application oExcel;
            //Excel._Workbook oWBook;
            //Excel._Worksheet oSheet;
            //PlanSwift.Tab CurrentTab;
            int i = 0;

            // Start Excel and get Application object
            oExcel = new Excel.Application();

            // Create new Workbook
            oWBook = (Excel._Workbook)(oExcel.Workbooks.Add(Missing.Value));
            oSheet = (Excel._Worksheet)oWBook.ActiveSheet;
            // Add Header Information
            oSheet.Cells[1, 1] = "Tab";
            oSheet.Cells[1, 2] = "Name";
            oSheet.Cells[1, 3] = "Item Number";
            oSheet.Cells[1, 4] = "Qty";
            oSheet.Cells[1, 5] = "Price Each";
            oSheet.Cells[1, 6] = "Price Total";
            oSheet.Cells[1, 7] = "Item Type";
            // Apply Header Formating
            oSheet.get_Range("A1", "G1").Font.Bold         = true;
            oSheet.get_Range("A1", "G1").VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;

            //Get Selected Planswift Tab
            CurrentTab = TGlobal.pc.Tabs.ByName(Tabs_cbx.Text);
            CurrentTab.MakeActive();
            for (int ItemIndex = 0; ItemIndex <= CurrentTab.Count - 1; ItemIndex++)
            {
                GetItems(CurrentTab[ItemIndex]);
                i = ItemIndex;
            }
            oSheet.get_Range("A1", "G1").EntireColumn.AutoFit();
            oExcel.Visible = true;
            oExcel         = null;
            oWBook         = null;
            oSheet         = null;
        }
Example #2
0
        private void send_btn_Click(object sender, EventArgs e)
        {
            if (Tabs_cbx.Text == "")
            {
                MessageBox.Show("Please Select a Tab", "Select a Tab", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Tabs_cbx.Focus();
                return;
            }
            OLook = new OutLook.Application();

            OMail = (OutLook.MailItem)OLook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            OMail.Display(OMail);
            OMail.To      = to_txt.Text;
            OMail.CC      = CC_txt.Text;
            OMail.Subject = Subject_txt.Text;
            CurrentTab    = TGlobal.pc.Tabs.ByName(Tabs_cbx.Text);
            CurrentTab.MakeActive();
            for (int ItemIndex = 0; ItemIndex <= CurrentTab.Count - 1; ItemIndex++)
            {
                GetItems(CurrentTab[ItemIndex]);
            }
            OMail.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
            OMail.HTMLBody   = "<HTML><body><b>Job Name: </b>" + TGlobal.pc.JobNumber +
                               "<br><b>Description: </b>" + TGlobal.pc.JobName + "<br><br><i><b>Item Types</b></i><br>";
            OMail.HTMLBody = OMail.HTMLBody + "<Table width=" + chr + "400" +
                             chr + "Height=" + chr + "9" + chr + ">";
            for (int HtmLoop = 0; HtmLoop <= 1; HtmLoop++)
            {
                if (HtmLoop > 0)
                {
                    OMail.HTMLBody = OMail.HTMLBody + "</Table><br><i><b>Total Quantity’s</b></i>";
                    OMail.HTMLBody = OMail.HTMLBody + "<Table width=" + chr + "400" + chr + "Height=" + chr + "9" + chr + ">";
                }
                String ArrCount;
                if (Folders_ck.Checked)
                {
                    if (HtmLoop == 0)
                    {
                        ArrCount = System.Convert.ToString(FolderArry.Count);
                        AddHtml("Folders", ArrCount);
                    }
                }
                if (Assem_ck.Checked)
                {
                    if (HtmLoop > 0)
                    {
                        ArrCount = GetSum(AssemblyQArry);
                    }
                    else
                    {
                        ArrCount = System.Convert.ToString(AssemblyQArry.Count);
                    }
                    AddHtml("Assemblies", ArrCount);
                }
                if (Parts_ck.Checked)
                {
                    if (HtmLoop > 0)
                    {
                        ArrCount = GetSum(PartQArry);
                    }
                    else
                    {
                        ArrCount = System.Convert.ToString(PartQArry.Count);
                    }
                    AddHtml("Parts", ArrCount);
                }
                if (Area_ck.Checked)
                {
                    if (HtmLoop > 0)
                    {
                        ArrCount = GetSum(AreaQArry);
                    }
                    else
                    {
                        ArrCount = System.Convert.ToString(AreaQArry.Count);
                    }
                    AddHtml("Areas", ArrCount);
                }
                if (Linear_ck.Checked)
                {
                    if (HtmLoop > 0)
                    {
                        ArrCount = GetSum(LinearQArry);
                    }
                    else
                    {
                        ArrCount = System.Convert.ToString(LinearQArry.Count);
                    }
                    AddHtml("Linears", ArrCount);
                }
                if (Segment_ck.Checked)
                {
                    if (HtmLoop > 0)
                    {
                        ArrCount = GetSum(SegmentQArry);
                    }
                    else
                    {
                        ArrCount = System.Convert.ToString(SegmentQArry.Count);
                    }
                    AddHtml("Segments", ArrCount);
                }
                if (Count_ck.Checked)
                {
                    if (HtmLoop > 0)
                    {
                        ArrCount = GetSum(CountQArry);
                    }
                    else
                    {
                        ArrCount = System.Convert.ToString(CountQArry.Count);
                    }
                    AddHtml("Counts", ArrCount);
                }
            }
            OMail.HTMLBody = OMail.HTMLBody + "</Table></body></HTML>";
            OLook          = null;
            OMail          = null;
            this.Close();
        }