private void tlbMenu_DeleteClick() { try { Cursor = Cursors.WaitCursor; if (XtraMessageBox.Show("Be sure to delete the record?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (!ValidarIngreso()) { TypeCertificateBE objE_TypeCertificate = new TypeCertificateBE(); objE_TypeCertificate.IdTypeCertificate = int.Parse(gvTypeCertificate.GetFocusedRowCellValue("IdTypeCertificate").ToString()); objE_TypeCertificate.Login = Parametros.strUsuarioLogin; objE_TypeCertificate.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objE_TypeCertificate.IdCompany = Parametros.intEmpresaId; TypeCertificateBL objBL_TypeCertificate = new TypeCertificateBL(); objBL_TypeCertificate.Elimina(objE_TypeCertificate); XtraMessageBox.Show("The record was successfully deleted.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); Cargar(); } } Cursor = Cursors.Default; } catch (Exception ex) { Cursor = Cursors.Default; XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnGrabar_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; if (!ValidarIngreso()) { TypeCertificateBL objBL_TypeCertificate = new TypeCertificateBL(); TypeCertificateBE objTypeCertificate = new TypeCertificateBE(); objTypeCertificate.IdTypeCertificate = IdTypeCertificate; objTypeCertificate.NameTypeCertificate = txtDescripcion.Text; objTypeCertificate.FlagState = true; objTypeCertificate.Login = Parametros.strUsuarioLogin; objTypeCertificate.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objTypeCertificate.IdCompany = Parametros.intEmpresaId; if (pOperacion == Operacion.Nuevo) { objBL_TypeCertificate.Inserta(objTypeCertificate); } else { objBL_TypeCertificate.Actualiza(objTypeCertificate); } this.Close(); } } catch (Exception ex) { Cursor = Cursors.Default; XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void ExportarExcel(string filename) { Excel._Application xlApp; Excel._Workbook xlLibro; Excel._Worksheet xlHoja; Excel.Sheets xlHojas; xlApp = new Excel.Application(); filename = Path.Combine(Directory.GetCurrentDirectory(), "Excel\\TypeCertificate.xlsx"); xlLibro = xlApp.Workbooks.Open(filename, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); xlHojas = xlLibro.Sheets; xlHoja = (Excel._Worksheet)xlHojas[1]; Cursor.Current = Cursors.WaitCursor; try { int Row = 6; int Secuencia = 1; List <TypeCertificateBE> lstTypeCertificate = null; lstTypeCertificate = new TypeCertificateBL().ListaTodosActivo(Parametros.intEmpresaId); if (lstTypeCertificate.Count > 0) { xlHoja.Shapes.AddPicture(Path.Combine(Directory.GetCurrentDirectory(), "Logo.jpg"), Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, 1, 1, 100, 60); foreach (var item in lstTypeCertificate) { xlHoja.Cells[Row, 1] = item.IdTypeCertificate; xlHoja.Cells[Row, 2] = item.NameTypeCertificate; Row = Row + 1; Secuencia = Secuencia + 1; } } xlLibro.SaveAs("C:\\Excel\\TypeCertificate.xlsx", Excel.XlFileFormat.xlWorkbookDefault, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlExclusive, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); xlLibro.Close(true, Missing.Value, Missing.Value); xlApp.Quit(); Cursor.Current = Cursors.Default; XtraMessageBox.Show("It was imported correctly \n The file was generated C:\\Excel\\TypeCertificate.xlsx", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { xlLibro.Close(false, Missing.Value, Missing.Value); xlApp.Quit(); Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void frmManTypeCertificateEdit_Load(object sender, EventArgs e) { if (pOperacion == Operacion.Nuevo) { this.Text = "TypeCertificate - New"; } else if (pOperacion == Operacion.Modificar) { this.Text = "TypeCertificate - Update"; TypeCertificateBE objE_TypeCertificate = null; objE_TypeCertificate = new TypeCertificateBL().Selecciona(IdTypeCertificate); if (objE_TypeCertificate != null) { txtDescripcion.Text = objE_TypeCertificate.NameTypeCertificate.Trim(); } } txtDescripcion.Select(); }