Ejemplo n.º 1
0
        public bool MakeTemplate(string courseIndex, string teacherIndex)
        {
            Templater templater = new Templater();

            try
            {
                DbWorker dbWorker     = new DbWorker();
                var      education    = dbWorker.GetEducation(teacherIndex, courseIndex);
                string   selectedPath = null;

                if (education != null)
                {
                    OpenFileDialog folderBrowser = new OpenFileDialog();
                    // Set validate names and check file exists to false otherwise windows will
                    // not let you select "Folder Selection."
                    folderBrowser.ValidateNames   = false;
                    folderBrowser.CheckFileExists = false;
                    folderBrowser.CheckPathExists = true;
                    // Always default to Folder Selection.
                    folderBrowser.FileName = $"Направление_№-{education.Id}.docx";
                    if (folderBrowser.ShowDialog() == DialogResult.OK)
                    {
                        selectedPath = folderBrowser.FileName;
                    }

                    templater.CourseReferral(selectedPath, education.Id, "Napravlenie_na_prokhozhdenie_kursa.docx");                    //"\\Documents\\Направление на прохождение курса.docx"
                    MessageBox.Show("Справка сформирована!");
                    return(true);
                }
                else
                {
                    MessageBox.Show("Данные не найдены");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Справка не сформирована");
                return(false);
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            Templater templater = new Templater();

            try
            {
                int index = dataGridView1.CurrentRow.Index;

                if (Convert.ToDateTime(dataGridView1[6, index].Value.ToString()) < DateTime.Now)
                {
                    DbWorker dbWorker = new DbWorker();

                    string id           = dataGridView1[0, index].Value.ToString();
                    string educationId  = dataGridView1[0, index].Value.ToString();
                    string selectedPath = null;

                    OpenFileDialog folderBrowser = new OpenFileDialog();
                    folderBrowser.ValidateNames   = false;
                    folderBrowser.CheckFileExists = false;
                    folderBrowser.CheckPathExists = true;
                    folderBrowser.FileName        = $"Справка_№-{educationId}.docx";
                    if (folderBrowser.ShowDialog() == DialogResult.OK)
                    {
                        selectedPath = folderBrowser.FileName;
                    }

                    templater.Maketemplate(selectedPath, educationId, "shablon.docx");                    //"\\Documents\\шаблон.docx"
                    MessageBox.Show("Справка сформирована!");
                }
                else
                {
                    MessageBox.Show("Не возможно сформировать справку для не оконченных курсов!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Справка не сформирована");
            }
            dataGridView1.Rows.Clear();
            FillDataGridWithFilter();
        }
Ejemplo n.º 3
0
        public bool MakeApproval(string educationId)
        {
            Templater templater = new Templater();

            try
            {
                DbWorker dbWorker     = new DbWorker();
                string   selectedPath = null;

                if (!string.IsNullOrEmpty(educationId) || !string.IsNullOrWhiteSpace(educationId))
                {
                    OpenFileDialog folderBrowser = new OpenFileDialog();
                    // Set validate names and check file exists to false otherwise windows will
                    // not let you select "Folder Selection."
                    folderBrowser.ValidateNames   = false;
                    folderBrowser.CheckFileExists = false;
                    folderBrowser.CheckPathExists = true;
                    // Always default to Folder Selection.
                    folderBrowser.FileName = $"Одобрение_курса_№-{educationId}.docx";
                    if (folderBrowser.ShowDialog() == DialogResult.OK)
                    {
                        selectedPath = folderBrowser.FileName;
                    }

                    templater.CourseReferral(selectedPath, educationId, "odobrenie_kursa.docx");                    //"\\Documents\\Направление на прохождение курса.docx"
                    MessageBox.Show("Справка сформирована!");
                    return(true);
                }
                else
                {
                    MessageBox.Show("Данные не найдены");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Справка не сформирована");
                return(false);
            }
        }