Exemplo n.º 1
0
        private void bCreateAct_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == string.Empty)
            {
                MessageBox.Show("Выберите отдел фондодержателя!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (comboBox2.Text == string.Empty)
            {
                MessageBox.Show("Выберите год!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (comboBox3.Text == string.Empty)
            {
                MessageBox.Show("Выберите акт!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            KeyValuePair <string, string> item = (KeyValuePair <string, string>)comboBox3.SelectedItem;
            string ActNumberSort = item.Key.ToString();
            string ActNumber     = item.Value.ToString();

            using (ExcelWork excel = new ExcelWork(ActNumber))
            {
                try
                {
                    excel.Init();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
                List <BJBookInfo> books = wi.GetBooksByAct(ActNumberSort);
                int RowIndex            = 0;
                int Cost = 0;
                foreach (BJBookInfo b in books)
                {
                    foreach (BJExemplarInfo exemplar in b.Exemplars)
                    {
                        if (exemplar.Fields["929$b"].ToString() != string.Empty)
                        {
                            if (exemplar.Fields["929$b"].ToString() == ActNumber)
                            {
                                RowIndex++;
                                excel.InsertExemplar(exemplar, b, RowIndex);
                            }
                        }
                    }
                }
                excel.InsertDocumentHeader(RowIndex, comboBox1.Text, Cost);
                MessageBox.Show("Формирование акта успешно завершено!");
            }
        }
Exemplo n.º 2
0
        private void GenerateAct(List <BJExemplarInfo> Exemplars, string ActNumber)
        {
            if (comboBox1.Text == string.Empty)
            {
                MessageBox.Show("Выберите отдел фондодержателя!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (comboBox2.Text == string.Empty)
            {
                MessageBox.Show("Выберите год!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            KeyValuePair <string, string> item = (KeyValuePair <string, string>)comboBox3.SelectedItem;
            string ActNumberSort = item.Key.ToString();

            using (ExcelWork excel = new ExcelWork(ActNumber))
            {
                try
                {
                    excel.Init();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }

                int RowIndex = 0;
                int Cost     = 0;
                //foreach (BJBookInfo b in books)
                {
                    foreach (BJExemplarInfo exemplar in Exemplars)
                    {
                        if (exemplar.Fields["929$b"] != null)
                        {
                            //if (exemplar.Fields["929$b"].ToString() == ActNumber)
                            {
                                BJBookInfo b = BJBookInfo.GetBookInfoByPIN(exemplar.IDMAIN, exemplar.Fund);
                                RowIndex++;
                                excel.InsertExemplar(exemplar, b, RowIndex);
                            }
                        }
                    }
                }
                excel.InsertDocumentHeader(RowIndex, comboBox1.Text, Cost);
                MessageBox.Show("Формирование акта успешно завершено!");
            }
        }