private void fillTable()
        {
            reports = (List <Report>)getReportstsList();
            List <int> workshops = new List <int>();

            foreach (var report in reports)
            {
                workshops.Add(report.workshop_sender_pk);
            }
            List <Workshop> workshopsModels = (List <Workshop>)ApiConnector.getWorkshops(workshops);

            if (reportsGrid.InvokeRequired)
            {
                reportsGrid.Invoke(new MethodInvoker(delegate
                {
                    foreach (var report in (List <Report>)reports)
                    {
                        reportsGrid.Rows.Add(report.doc_num, report.date, workshopsModels.Find(workshop => workshop.workshop_pk == report.workshop_sender_pk).workshop_name);
                    }

                    AutoCompleteSourceForDocNum.Clear();
                    foreach (Report report in reports)
                    {
                        AutoCompleteSourceForDocNum.Add(report.doc_num.ToString());
                    }
                    finishThread();
                }));
            }
        }
Exemple #2
0
        private void fillTable()
        {
            vedomosts = (List <Vedomost>)getVedomostsList();
            if (inventarizationTable.InvokeRequired)
            {
                inventarizationTable.Invoke(new MethodInvoker(delegate
                {
                    foreach (var vedomost in (List <Vedomost>)vedomosts)
                    {
                        inventarizationTable.Rows.Add(vedomost.doc_num, vedomost.creation_date);
                    }

                    AutoCompleteSourceForDocNum.Clear();
                    foreach (Vedomost vedomost in vedomosts)
                    {
                        AutoCompleteSourceForDocNum.Add(vedomost.doc_num.ToString());
                    }
                    finishThread();
                }));
            }
        }
        private void reportsGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 4)
            {
                // удалить здесь
                DialogResult dialogResult = MessageBox.Show("Вы действительно хотите удалить рапорт №" +
                                                            reportsGrid.CurrentRow.Cells[0].Value.ToString() + "?", "Удаление", MessageBoxButtons.YesNo,
                                                            MessageBoxIcon.Question,
                                                            MessageBoxDefaultButton.Button1);

                if (dialogResult == DialogResult.Yes)
                {
                    int index = e.RowIndex;
                    ApiConnector.deleteReport(reports[index]);
                    reports.RemoveAt(index);
                    AutoCompleteSourceForDocNum.RemoveAt(index);
                    reportsGrid.Rows.RemoveAt(index);
                    MessageBox.Show("Рапорт был успешно удален.", "Удаление рапорта",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
            if (e.ColumnIndex == 3)
            {
                var identificationTable = new Dictionary <DataGridViewRow, ReportLine>();

                // открыть форму для редактирования рапорта

                Report currReport = reports.Find(report => reportsGrid.CurrentRow.Cells[0].Value.ToString() == report.doc_num.ToString());
                editingReport      = currReport;
                indexEditingReport = e.RowIndex;

                EditingReportForm editingReportForm = new EditingReportForm(currReport);
                ReportDocument    reportDocument    = editingReportForm.GetPanel;

                reportDocument.GetDocCreationTime.Value = DateTime.Parse(currReport.date);
                reportDocument.GetDocNumberTextBox      = currReport.doc_num.ToString();

                for (int i = 0; i < depNameComboBoxItems.Count; i++)
                {
                    reportDocument.GetDepSender.Items.Add(depNameComboBoxItems[i]);
                }
                string workshopName = ApiConnector.getWorkshop(currReport.workshop_sender_pk).workshop_name;
                int    index        = depNameComboBoxItems.IndexOf(workshopName);
                reportDocument.GetDepSender.SelectedIndex = index;

                DataGridView table = reportDocument.GetTable;
                table.AllowUserToAddRows  = false;
                reportDocument.SetDetails = details;

                foreach (var workshop in workshops)
                {
                    (table.Columns[3] as DataGridViewComboBoxColumn).Items.Add(workshop.workshop_name);
                }

                for (int i = 0; i < currReport.report_lines.Count; i++)
                {
                    table.Rows.Add();
                    table.Rows[i].Cells[1].Value   = currReport.report_lines[i].detail.cipher_detail;
                    table.Rows[i].Cells[2].Value   = currReport.report_lines[i].produced.ToString();
                    (table.Rows[i].Cells[0]).Value = currReport.report_lines[i].detail.detail_name;
                    table.Rows[i].Cells[3].Value   =
                        workshops.Find(workshop => workshop.workshop_pk == currReport.report_lines[i].workshop_receiver_pk).workshop_name;
                    identificationTable.Add(table.Rows[i], currReport.report_lines[i]);
                }
                reportDocument.identificationTable = identificationTable;
                table.AllowUserToAddRows           = true;
                editingReportForm.Show();
                editingReportForm.FormClosed += new FormClosedEventHandler(refreshFunc);
            }
        }
Exemple #4
0
        private void inventarizationTable_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 3)
            {
                // удалить здесь
                DialogResult dialogResult = MessageBox.Show("Вы действительно хотите удалить ведомость №" +
                                                            inventarizationTable.CurrentRow.Cells[0].Value.ToString() + "?", "Удаление", MessageBoxButtons.YesNo,
                                                            MessageBoxIcon.Question,
                                                            MessageBoxDefaultButton.Button1);

                if (dialogResult == DialogResult.Yes)
                {
                    int index = e.RowIndex;
                    ApiConnector.deleteVedomost(vedomosts[index]);
                    vedomosts.RemoveAt(index);
                    AutoCompleteSourceForDocNum.RemoveAt(index);
                    inventarizationTable.Rows.RemoveAt(index);

                    MessageBox.Show("Ведомость была успешно удалена.", "Удаление ведомости",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
            if (e.ColumnIndex == 2)
            {
                var identificationTable = new Dictionary <DataGridViewRow, VedomostLine>();

                // открыть форму для редактирования инвентаризации
                Vedomost currVedomost = vedomosts.Find(vedomost => inventarizationTable.CurrentRow.Cells[0].Value.ToString() == vedomost.doc_num.ToString());
                editingVedomost      = currVedomost;
                indexEditingVedomost = e.RowIndex;
                EditingInventarization  editingInventarizationForm = new EditingInventarization(currVedomost);
                InventarizationDocument inventarization            = editingInventarizationForm.GetPanel;
                inventarization.GetDocCreateDate.Value   = DateTime.Parse(currVedomost.creation_date);
                inventarization.GetDocNumberTextBox.Text = currVedomost.doc_num.ToString();

                for (int i = 0; i < depNameComboBoxItems.Count; i++)
                {
                    inventarization.GetDepComboBox.Items.Add(depNameComboBoxItems[i]);
                }

                string workshopName = ApiConnector.getWorkshop(currVedomost.workshop_pk).workshop_name;
                int    index        = depNameComboBoxItems.IndexOf(workshopName);
                inventarization.GetDepComboBox.SelectedIndex = index;
                DataGridView table = inventarization.GetTable;
                table.AllowUserToAddRows = false;

                inventarization.SetDetails = details;
                for (int i = 0; i < currVedomost.vedomost_lines.Count; i++)
                {
                    table.Rows.Add();
                    table.Rows[i].Cells[1].Value   = currVedomost.vedomost_lines[i].detail.cipher_detail;
                    table.Rows[i].Cells[2].Value   = currVedomost.vedomost_lines[i].amount;
                    (table.Rows[i].Cells[0]).Value = currVedomost.vedomost_lines[i].detail.detail_name;
                    identificationTable.Add(table.Rows[i], currVedomost.vedomost_lines[i]);
                }
                table.AllowUserToAddRows            = true;
                inventarization.identificationTable = identificationTable;
                editingInventarizationForm.Show();

                editingInventarizationForm.FormClosed += new FormClosedEventHandler(RefreshVedomosts);
            }
        }