public void WriteDataToExcelUpdate(DataModel dataModel, CalculatedData calculateData)
        {
            stringBuilder = new StringBuilder();
            StringBuilder path = stringBuilder.Append(directoryName).Append("\\").Append(dataModel.solderPassportID).Append(dataModel.SolderName).Append(dataModel.SoldeSurername).Append(dataModel.Solderfname).Append(".csv");

            if (File.Exists(path.ToString()))
            {
                WriteCalcutateDataToExcel(dataModel, calculateData, path.ToString());
            }
            else
            {
                CreatdataExcel(path.ToString(), dataModel);
                WriteCalcutateDataToExcel(dataModel, calculateData, path.ToString());
            }
        }
        private void WriteCalcutateDataToExcel(DataModel dataModel, CalculatedData calculateData, string path)
        {
            List <string> listofData = dataModel.DatamodelValueCalculate();

            excelData = new Excel.Application();
            workbook  = excelData.Workbooks.Open(path.ToString(), false);
            Excel.Workbook excelWorkBook = excelData.Workbooks.Add(misValue);
            excelSheet = (Excel.Worksheet)excelWorkBook.Worksheets.get_Item(1);
            int count = TestExcelCalls(path.ToString());

            for (int i = 1; i < listofData.Count; i++)
            {
                excelSheet.Cells[count, i]     = listofData[i];
                excelSheet.Cells[count + 1, i] = calculateData.ListCalculateData(i);
            }
            excelData.DisplayAlerts = false;
            excelWorkBook.Save();
            excelWorkBook.Close(true, path.ToString(), misValue);
            excelData.Quit();
            MessageBox.Show("Update");
        }
Пример #3
0
        private void buttonSaveFile_Click(object sender, EventArgs e)
        {
            calculateData = new CalculatedData(double.Parse(textBoxazaltilleryX.Text), double.Parse(textBoxazAltilleryY.Text), double.Parse(textBoxInitialSpeed.Text), double.Parse(textBoxamAltilleryX.Text), double.Parse(textBoxamAltilleryY.Text), Convert.ToDouble(numericUpDownProjAngle.Value));
            chart1.Series[0].Points.Clear();
            for (double t = 0.1; t < calculateData.FlightDuration; t += 0.1)
            {
                if ((calculateData.V2 * t - (10 * t * t) / 2) >= 0)
                {
                    chart1.Series["Series"].Points.AddXY(calculateData.AltilleryX + calculateData.V1 * t, calculateData.AltilleryY + calculateData.V2 * t - (10 * t * t) / 2);
                }
                else
                {
                    break;
                }
            }
            chart1.Series["Series"].Points.AddXY((calculateData.AdversaryX), (calculateData.AdversaryY));
            textBoxFlightDuration.Text = calculateData.FlightDuration.ToString();
            textBoxMaxSize.Text        = Math.Floor(calculateData.H).ToString();
            WriteDataToExcel write = new WriteDataToExcel();

            datamodel = new DataModel(textBoxPassportID.Text, textboxFirstName.Text, textBoxLastName.Text, textBoxFName.Text, Convert.ToInt16(numericUpDownAge.Value), comboBoxTitle.Text, comboBoxClassical.Text, comboBoxCompany.Text, comboBoxBattalion.Text, comboBoxBowl.Text, textBoxArtilleryName.Text, textBoxArtilleryModel.Text, textBoxAltilerTitle.Text, Convert.ToInt16(numericUpDownaltiler.Value));
            write.GetDefaultDirectory();
            write.WriteDataToExcelUpdate(datamodel, calculateData);
        }