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()) { SeasonBE objE_Season = new SeasonBE(); objE_Season.IdSeason = int.Parse(gvSeason.GetFocusedRowCellValue("IdSeason").ToString()); objE_Season.Login = Parametros.strUsuarioLogin; objE_Season.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objE_Season.IdCompany = Parametros.intEmpresaId; SeasonBL objBL_Season = new SeasonBL(); objBL_Season.Elimina(objE_Season); 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()) { SeasonBL objBL_Season = new SeasonBL(); SeasonBE objSeason = new SeasonBE(); objSeason.IdSeason = IdSeason; objSeason.NameSeason = txtDescripcion.Text; objSeason.FlagState = true; objSeason.Login = Parametros.strUsuarioLogin; objSeason.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objSeason.IdCompany = Parametros.intEmpresaId; if (pOperacion == Operacion.Nuevo) { objBL_Season.Inserta(objSeason); } else { objBL_Season.Actualiza(objSeason); } 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\\Season.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 <SeasonBE> lstSeason = null; lstSeason = new SeasonBL().ListaTodosActivo(Parametros.intEmpresaId); if (lstSeason.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 lstSeason) { xlHoja.Cells[Row, 1] = item.IdSeason; xlHoja.Cells[Row, 2] = item.NameSeason; Row = Row + 1; Secuencia = Secuencia + 1; } } xlLibro.SaveAs("C:\\Excel\\Season.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; BSUtils.OpenExcel("C:\\Excel\\Season.xlsx"); //XtraMessageBox.Show("It was imported correctly \n The file was generated C:\\Excel\\Season.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 frmManSeasonEdit_Load(object sender, EventArgs e) { if (pOperacion == Operacion.Nuevo) { this.Text = "Season - New"; } else if (pOperacion == Operacion.Modificar) { this.Text = "Season - Update"; SeasonBE objE_Season = null; objE_Season = new SeasonBL().Selecciona(IdSeason); if (objE_Season != null) { txtDescripcion.Text = objE_Season.NameSeason.Trim(); } } txtDescripcion.Select(); }