Ejemplo n.º 1
0
        private void mscnBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.mscnBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.dJDataSet);
            Otchgen d = new Otchgen();

            d.GenerateOtchet(mscnDataGridView, "mscn");
            string path = System.IO.Directory.GetCurrentDirectory() + @"\" + "Save_emp.xlsx";

            /*Excel.Application excelapp = new Excel.Application();
             * Excel.Workbook workbook = excelapp.Workbooks.Add();
             * Excel.Worksheet worksheet = workbook.ActiveSheet;
             * string[] ms = new string[3] { "Код жанра", "Наименование", "О жанре" };
             *
             * for (int i = 0; i < mscnDataGridView.RowCount - 1; i++)
             * {
             *
             *  for (int j = 0; j < mscnDataGridView.ColumnCount; j++)
             *  {
             *      worksheet.Rows[1].Columns[j + 1] = ms[j];
             *      worksheet.Rows[i + 2].Columns[j + 1] = mscnDataGridView.Rows[i].Cells[j].Value;
             *
             *  }
             * }
             *
             *
             * excelapp.AlertBeforeOverwriting = false;
             * workbook.SaveAs(path);
             * excelapp.Quit();*/
        }
Ejemplo n.º 2
0
        private void empBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            string[,] ar = new string[2, 2];
            Dictionary <int, string> pairs = new Dictionary <int, string>();

            //this.tableAdapterManager.UpdateAll(this.dJDataSet);
            empTableAdapter.Update(dJDataSet.emp);
            //this.empBindingSource.EndEdit();
            //empTableAdapter.Update(dJDataSet.emp);



            string path = System.IO.Directory.GetCurrentDirectory() + @"\" + "Save_emp.xlsx";


            string[] ms = new string[8] {
                "Код сотрудника", "ФИО", "Возраст", "Пол", "Адрес", "Номер", "Паспортные данные", "Должность"
            };

            for (int i = 0; i < empDataGridView.RowCount - 1; i++)
            {
                for (int j = 0; j < empDataGridView.ColumnCount; j++)
                {
                    if (j == 7)
                    {
                        try
                        {
                            n_ps_comb.SelectedIndex = int.Parse(empDataGridView.Rows[i].Cells[j].Value.ToString()) - 1;
                            pairs.Add(i, n_ps_comb.GetItemText(n_ps_comb.SelectedItem) + " 7");
                        }
                        catch
                        {
                        }
                    }
                    if (j == 3)
                    {
                        /*if ((bool)empDataGridView.Rows[i].Cells[j].EditedFormattedValue)
                         *  worksheet.Rows[i + 2].Columns[j + 1] = "Мужчина";
                         * else worksheet.Rows[i + 2].Columns[j + 1] = "Женщина";*/

                        if ((bool)empDataGridView.Rows[i].Cells[j].EditedFormattedValue)
                        {
                            pairs.Add(i, "Мужчина 3");
                        }
                        else
                        {
                            pairs.Add(i, "Женщина 3");
                        }
                    }
                }
            }


            Otchgen d = new Otchgen();

            d.GenerateOtchet(empDataGridView, "empl", pairs);


            /*excelapp.AlertBeforeOverwriting = false;
             * workbook.SaveAs(path);
             * excelapp.Quit()/*/
        }