private void btnGuardar_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; List <MssBD.VW_DOC_Anexos> _ListGrilla = new List <MssBD.VW_DOC_Anexos>(); List <MssBD.VW_DOC_Anexos> _ListGuardar = new List <MssBD.VW_DOC_Anexos>(); this.gridContratos.Refresh(); _ListGrilla = (List <MssBD.VW_DOC_Anexos>) this.gridContratos.DataSource; if (this.gridContratos.DataSource == null || _ListGrilla.Count() < 1) { return; } foreach (DataGridViewRow item in this.gridContratos.Rows) { if ((Boolean)item.Cells["porVisarDataGridViewCheckBoxColumn"].Value) { _ListGuardar.Add((MssBD.VW_DOC_Anexos)item.DataBoundItem); } } if (_ListGuardar.Count == 0) { MessageBox.Show(String.Concat("Debe seleccionar algún Anexos a autorizar."), "Mss", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); return; } String mensaje = string.Empty; Folder.ShowDialog(); if (Folder.SelectedPath.ToString() != string.Empty) { Negocio.Documentos.Anexos _Contrato = new Negocio.Documentos.Anexos(_usuarioSesion); _Contrato._RutaInicioProyecto = System.Windows.Forms.Application.StartupPath; if (!_Contrato.GenereAnexosMasivos(ref mensaje, _ListGuardar, String.Concat(Folder.SelectedPath.ToString(), "\\"))) { if (mensaje == string.Empty) { MessageBox.Show(String.Concat("Ha ocurrido un problema al generar Anexos."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(String.Concat(mensaje), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(String.Concat("Anexos se han generado con éxito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information); } BuscaDocumentosVisados(); } } catch (Exception ex) { Cursor.Current = Cursors.Default; MensajeControlado mensa = new MensajeControlado("", ex.Message, ex); mensa.Show(); return; } finally { Cursor.Current = Cursors.Default; } }
private void btnAnexo_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; String mensaje = string.Empty; Boolean Visacion = false; if (!Valida()) { return; } _Anexos = new Negocio.Documentos.Anexos(_usuarioSesion); _Documento = new Negocio.Documentos.Documento(); _ConsultaEmp.FechaIngreso = txtFechaInicio.Value; _ConsultaEmp.FechaVencimiento = txtFechaVencimiento.Value; _Anexos._FechaAnexo = txtFechaAnexo.Value; _Anexos._TipoContrato = cboTipoContrato.Text; _Anexos._per = _ConsultaEmp; _Anexos._RutaInicioProyecto = System.Windows.Forms.Application.StartupPath; Int32 _ContratoId = 0; if (!_Documento.RetornaContratoId(_ConsultaEmp, ref mensaje, ref _ContratoId)) { if (mensaje == string.Empty) { MessageBox.Show(String.Concat("Ha ocurrido un problema al consultar contrato Previo."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (_usuarioSesion.Privilegio_Id < 2) { Visacion = false; } //Registra Anexo Int32 _Doc_Id = 0; _Documento = new Negocio.Documentos.Documento(); if (!_Documento.RegistrarDocumento(2, _usuarioSesion, _ConsultaEmp, Visacion, String.Concat(Folder.SelectedPath.ToString(), "\\"), ref mensaje, ref _Doc_Id)) { if (mensaje == string.Empty) { MessageBox.Show(String.Concat("Ha ocurrido un problema al registrar visado de Anexo."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { if (!Visacion) { Folder.ShowDialog(); if (Folder.SelectedPath.ToString() != string.Empty) { _Anexos._RutaFinal = String.Concat(Folder.SelectedPath.ToString(), "\\"); if (!_Anexos.GeneraAnexo(ref mensaje)) { if (mensaje == string.Empty) { MessageBox.Show(String.Concat("Ha ocurrido un problema al generar Anexo."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } } if (_Documento.RegistrarAnexo(2, _usuarioSesion, _ConsultaEmp, Visacion, String.Concat(Folder.SelectedPath.ToString(), "\\"), ref mensaje, _ContratoId)) { MessageBox.Show(String.Concat("Anexo se ha registrado con éxito."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (mensaje == string.Empty) { MessageBox.Show(String.Concat("Ha ocurrido un problema al registrar visado de Anexo."), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(String.Concat(mensaje), "Mss", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { Cursor.Current = Cursors.Default; MensajeControlado mensa = new MensajeControlado("", ex.Message, ex); mensa.Show(); return; } finally { Cursor.Current = Cursors.Default; } }