コード例 #1
0
ファイル: FormNMBS.cs プロジェクト: NMBS-FALLON/DESign
        private void btnQuickTCWidth_Click(object sender, EventArgs e)
        {
            ExtractJoistDetails extractJoistDetails = new ExtractJoistDetails();
            Job job = new Job();
            job = extractJoistDetails.JobFromShoporderJoistDetails();

            Excel.Application oXL;
            Excel._Workbook oWB;
            Excel._Worksheet oSheet;
            Excel.Range oRng;

            //Start Excel and get Application object.
            oXL = new Excel.Application();
            oXL.Visible = true;

            //Get a new workbook.

            string excelPath = System.IO.Path.GetTempFileName();

            System.IO.File.WriteAllBytes(excelPath, Properties.Resources.DesignTCWidths);

            oWB = oXL.Workbooks.Open(excelPath);

            oSheet = (Excel._Worksheet)oWB.ActiveSheet;

            int joistcount = 0;
            foreach (Joist joist in job.Joists)
            {
                joistcount++;
                string excelRow = Convert.ToString(joistcount + 6);
                oSheet.get_Range("A" + excelRow, Missing.Value).Value = joist.Mark;
                oSheet.get_Range("B" + excelRow, Missing.Value).Value = joist.Quantity;
                oSheet.get_Range("C" + excelRow, Missing.Value).Value = joist.Description;
                oSheet.get_Range("D" + excelRow, Missing.Value).Value = stringManipulation.DecimilLengthToHyphen(joist.BaseLength);
                oSheet.get_Range("E" + excelRow, Missing.Value).Value = joist.TCWidth;
            }
        }
コード例 #2
0
ファイル: FormNMBS.cs プロジェクト: NMBS-FALLON/DESign
        private void btnWoodReqFromJoistDetails_Click(object sender, EventArgs e)
        {
            ExtractJoistDetails extractJoistDetails = new ExtractJoistDetails();
            Job job = new Job();
            job = extractJoistDetails.JobFromShoporderJoistDetails();

            double dblFiveInch = 0.0;
            double dblSevenInch = 0.0;
            double dblEightInch = 0.0;
            double dblNineInch = 0.0;
            double dblElevenInch = 0.0;
            double dblThirteenInch = 0.0;

            foreach(Joist joist in job.Joists)
            {
                double qty = Convert.ToDouble(joist.Quantity);
                if (joist.TCWidth == "5") { dblFiveInch = dblFiveInch + qty*joist.BaseLength; }
                if (joist.TCWidth == "7") { dblSevenInch = dblSevenInch + qty*joist.BaseLength; }
                if (joist.TCWidth == "8") { dblEightInch = dblEightInch + qty*joist.BaseLength; }
                if (joist.TCWidth == "9") { dblNineInch = dblNineInch + qty*joist.BaseLength; }
                if (joist.TCWidth == "11") { dblElevenInch = dblElevenInch + qty*joist.BaseLength; }
                if (joist.TCWidth == "13") { dblThirteenInch = dblThirteenInch + qty*joist.BaseLength; }

            }

            string stringFiveInch, stringSevenInch, stringEightInch, stringNineInch, stringElevenInch, stringThirteenInch;
            stringFiveInch = stringSevenInch = stringEightInch = stringNineInch = stringElevenInch = stringThirteenInch = String.Empty;
            if (dblFiveInch != 0)
            {
                stringFiveInch = "5\" = " + Convert.ToString(Convert.ToInt32(dblFiveInch)) + "  lf \r\n";
            }
            if (dblSevenInch != 0)
            {
                stringSevenInch = "7\" = " + Convert.ToString(Convert.ToInt32(dblSevenInch)) + "  lf \r\n";
            }
            if (dblEightInch != 0)
            {
                stringEightInch = "8\" = " + Convert.ToString(Convert.ToInt32(dblEightInch)) + "  lf \r\n";
            }
            if (dblNineInch != 0)
            {
                stringNineInch = "9\" = " + Convert.ToString(Convert.ToInt32(dblNineInch)) + "  lf \r\n";
            }
            if (dblElevenInch != 0)
            {
                stringElevenInch = "11\" = " + Convert.ToString(Convert.ToInt32(dblElevenInch)) + "  lf \r\n";
            }
            if (dblThirteenInch != 0)
            {
                stringThirteenInch = "13\" = " + Convert.ToString(Convert.ToInt32(dblThirteenInch)) + "  lf \r\n";
            }
            /*
            string woodRequirements =

                "5\" = " + Convert.ToString(Convert.ToInt16(fiveInch)) + "  lf \r\n" +
                "7 1/8\" = " + Convert.ToString(Convert.ToInt16(sevenInch)) + "  lf \r\n" +
                "8 1/8\" = " + Convert.ToString(Convert.ToInt16(eightInch)) + "  lf \r\n" +
                "9 1/8\" = " + Convert.ToString(Convert.ToInt16(nineInch)) + "  lf \r\n" +
                "10 1/8\" = " + Convert.ToString(Convert.ToInt16(tenInch)) + "  lf \r\n" +
                "11 1/8\" = " + Convert.ToString(Convert.ToInt16(elevenInch)) + "  lf \r\n";
            */
            string woodRequirements =

                stringFiveInch + stringSevenInch + stringEightInch + stringNineInch + stringElevenInch + stringThirteenInch;

            tBoxWoodReq.Text = woodRequirements;
        }
コード例 #3
0
        public Job JobFromShoporderJoistDetails()
        {
            Job job = new Job();
            List<Joist> allJoists = new List<Joist>();
            List<Girder> allGirders = new List<Girder>();

            OpenFileDialog openBOMFileDialog = new OpenFileDialog();
            openBOMFileDialog.Title = "SELECT JOIST DETAILS";
            //openBOMFileDialog.Filter = "Excel WorkBook|*.xls";
            if (openBOMFileDialog.ShowDialog() == DialogResult.OK)
            {
                string fileName = openBOMFileDialog.FileName;
                job.Number = fileName.Split(new string[] { " -", ".xls" }, StringSplitOptions.RemoveEmptyEntries)[1];

                string excelFileName = System.IO.Path.GetTempFileName();
                Byte[] BOMinByteArray = System.IO.File.ReadAllBytes(openBOMFileDialog.FileName);
                System.IO.File.WriteAllBytes(excelFileName, BOMinByteArray);
                Excel.Application oXL;
                Excel._Workbook oWB;
                Excel._Worksheet oSheet;
                Excel.Range oRng;

                oXL = new Excel.Application();
                oXL.Visible = false;

                oWB = oXL.Workbooks.Open(excelFileName);
                oSheet = (Excel._Worksheet)oWB.ActiveSheet;
                oRng = oSheet.UsedRange;

                oRng.get_Range("A1", Missing.Value);
                oRng = oRng.get_End(Excel.XlDirection.xlToRight);
                oRng = oRng.get_End(Excel.XlDirection.xlDown);
                string downJoistMarks = oRng.get_Address(Excel.XlReferenceStyle.xlA1, Type.Missing);
                oRng = oSheet.get_Range("A1", downJoistMarks);
                var joistDetailArray = (object[,])oRng.Value2;

                int joistDetailArrayRows = joistDetailArray.GetLength(0);

                for (int row = 2; row <= joistDetailArrayRows; row++)
                {
                    string joistDescription = (string)joistDetailArray[row, 1];
                    if (joistDescription.Contains("G") == true)
                    {
                        Girder girder = new Girder();
                        girder.Mark = (string)joistDetailArray[row, 1];
                        girder.Quantity = Convert.ToInt32(joistDetailArray[row, 2]);
                        girder.Description = (string)joistDetailArray[row, 3];
                        girder.BaseLength = Convert.ToDouble(joistDetailArray[row, 4]);
                        girder.JoistType = (string)joistDetailArray[row, 5];
                        girder.SeatsBDL = Convert.ToDouble(joistDetailArray[row, 6]);
                        girder.SeatsBDR = Convert.ToDouble(joistDetailArray[row, 7]);
                        girder.TCXL = Convert.ToDouble(joistDetailArray[row, 8]);
                        girder.TCXR = Convert.ToDouble(joistDetailArray[row, 9]);
                        girder.BCXL = Convert.ToDouble(joistDetailArray[row, 10]);
                        girder.BCXR = Convert.ToDouble(joistDetailArray[row, 11]);
                        string TCandBC = (string)joistDetailArray[row, 12];
                        girder.TC = TCandBC.Split('/')[0];
                        girder.BC = TCandBC.Split('/')[1];
                        girder.MaterialCost = Convert.ToDouble(joistDetailArray[row, 13]);
                        girder.WeightInLBS = Convert.ToDouble(joistDetailArray[row, 14]);
                        girder.TotalLH = Convert.ToDouble(joistDetailArray[row, 15]);
                        girder.BLDecimal = Convert.ToDouble(joistDetailArray[row, 19]);
                        girder.Time = Convert.ToDouble(joistDetailArray[row, 20]);
                        girder.UseWood = Convert.ToBoolean(joistDetailArray[row, 21]);
                        allGirders.Add(girder);

                    }
                    else
                    {
                        Joist joist = new Joist();
                        joist.Mark = (string)joistDetailArray[row, 1];
                        joist.Quantity = Convert.ToInt32(joistDetailArray[row, 2]);
                        joist.Description = (string)joistDetailArray[row, 3];
                        joist.BaseLength = Convert.ToDouble(joistDetailArray[row, 4]);
                        joist.JoistType = (string)joistDetailArray[row, 5];
                        joist.SeatsBDL = Convert.ToDouble(joistDetailArray[row, 6]);
                        joist.SeatsBDR = Convert.ToDouble(joistDetailArray[row, 7]);
                        joist.TCXL = Convert.ToDouble(joistDetailArray[row, 8]);
                        joist.TCXR = Convert.ToDouble(joistDetailArray[row, 9]);
                        joist.BCXL = Convert.ToDouble(joistDetailArray[row, 10]);
                        joist.BCXR = Convert.ToDouble(joistDetailArray[row, 11]);
                        string TCandBC = (string)joistDetailArray[row, 12];
                        joist.TC = TCandBC.Split('/')[0];
                        joist.BC = TCandBC.Split('/')[1];
                        joist.MaterialCost = Convert.ToDouble(joistDetailArray[row, 13]);
                        joist.WeightInLBS = Convert.ToDouble(joistDetailArray[row, 14]);
                        joist.TotalLH = Convert.ToDouble(joistDetailArray[row, 15]);
                        joist.BLDecimal = Convert.ToDouble(joistDetailArray[row, 19]);
                        joist.Time = Convert.ToDouble(joistDetailArray[row, 20]);
                        joist.UseWood = Convert.ToBoolean(joistDetailArray[row, 21]);
                        allJoists.Add(joist);
                    }

                }
                allJoists = allJoists.OrderBy(x => x.StrippedNumber).ToList();
                allGirders = allGirders.OrderBy(x => x.StrippedNumber).ToList();
                job.Joists = allJoists;
                job.Girders = allGirders;
            }
            return job;
        }