private void LoadTemplate() { try { dataGridView2.Rows.Clear(); dataGridView2.ReadOnly = true; dataTableTemplate = FirmaInCloudDB.LoadTemplate(null, ""); dataGridView2.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView2.Columns[1].HeaderCell.Style.Font = new Font("Microsoft Tai Le", 10, FontStyle.Bold); dataGridView2.Columns[2].HeaderCell.Style.Font = new Font("Microsoft Tai Le", 10, FontStyle.Bold); dataGridView2.Columns[3].HeaderCell.Style.Font = new Font("Microsoft Tai Le", 10, FontStyle.Bold); dataGridView2.Columns[0].HeaderCell.Style.Font = new Font("Microsoft Tai Le", 10, FontStyle.Bold); foreach (DataRow item in dataTableTemplate.Rows) { int n = dataGridView2.Rows.Add(); dataGridView2.Rows[n].Cells[0].Value = item[0].ToString(); dataGridView2.Rows[n].Cells[0].Style.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView2.Rows[n].Cells[1].Value = item[1].ToString(); dataGridView2.Rows[n].Cells[2].Value = item[2].ToString(); dataGridView2.Rows[n].Cells[3].Value = DateTime.ParseExact(item[3].ToString(), "yyyyMMddHHmm", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);; dataGridView2.Rows[n].Cells[3].Style.Alignment = DataGridViewContentAlignment.MiddleCenter; } } catch (Exception ex) { MessageBox.Show("Errore caricamento griglia template: " + ex.Message); } finally { dataTableTemplate = null; } }
private void btnFirma_Click(object sender, EventArgs e) { if (this.isModified) { if (DialogResult.No == MessageBox.Show("Per proseguire รจ necessario salvare i dati inseriti. Vuoi proseguire ?", "Firma documento", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } if (!ValidateControls()) { return; } Save(); } //if (DialogResult.No == MessageBox.Show("Selezionare una directory in cui salvare il documento." + Environment.NewLine + "Vuoi proseguire ?", "Firma documento", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) // return; //SaveFileDialog dlg = new SaveFileDialog //{ // Title = "Salvataggio Pdf", // AddExtension = true, // Filter = "PDF|*.pdf" //}; //if (dlg.ShowDialog() != DialogResult.OK) // return; //if (string.IsNullOrEmpty(dlg.FileName)) // return; if (cmbTemplate.SelectedIndex == 0) { MessageBox.Show("E' necessario selezionare un template valido !", "Firma documento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.isModified = false; return; } string strFileNameOutput = $"{FileHelper.GetPath("pdfElab")}{user.COGNOME}" + " " + $"{user.NOME}" + " " + $"{DateTime.Today:yyyyMMdd}" + ".pdf"; string strFileName = PDFManager.RunSignPro(strFileNameOutput, cmbTemplate.SelectedIndex, user); if (string.IsNullOrEmpty(strFileName)) { return; } var pathString = FirmaInCloudDB.LoadTemplate(cmbTemplate.SelectedIndex, "").AsEnumerable().First(); FileNameParser fileNameParser = new FileNameParser(strFileName); TemplateLinq templateLinq = new TemplateLinq { KEY_USER = user.KEY_USER, DTSIGN = DateTime.Now, PATH = strFileName, DESCR = fileNameParser.DESCR, KEY_TEMPL = Convert.ToInt32(pathString.ItemArray[0]) }; FirmaInCloudDB.SaveTemplate_Linq(templateLinq, user); ConfigDB.SaveConfig(Config.ParamValues.COUNT, (int.Parse(ConfigDB.LoadConfig(Config.ParamValues.COUNT).CONF_VALUE) + 1).ToString()); LoadTemplate_Linq(templateLinq); if (DialogResult.No == MessageBox.Show("E' possibile inviare il documento appena firmato all'indirizzo mail: " + user.MAIL + Environment.NewLine + "Vuoi proseguire ?", "Firma documento", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } Mail.SendMail(strFileName, txtMail.Text, user.NOME + " " + user.COGNOME, ""); }