private void btnGrabar_Click(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; if (!ValidarIngreso()) { PhaseBL objBL_Phase = new PhaseBL(); PhaseBE objPhase = new PhaseBE(); objPhase.IdPhase = IdPhase; objPhase.NamePhase = txtDescripcion.Text; objPhase.FlagState = true; objPhase.Login = Parametros.strUsuarioLogin; objPhase.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objPhase.IdCompany = Parametros.intEmpresaId; if (pOperacion == Operacion.Nuevo) { objBL_Phase.Inserta(objPhase); } else { objBL_Phase.Actualiza(objPhase); } this.Close(); } } catch (Exception ex) { Cursor = Cursors.Default; XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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()) { PhaseBE objE_Phase = new PhaseBE(); objE_Phase.IdPhase = int.Parse(gvPhase.GetFocusedRowCellValue("IdPhase").ToString()); objE_Phase.Login = Parametros.strUsuarioLogin; objE_Phase.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objE_Phase.IdCompany = Parametros.intEmpresaId; PhaseBL objBL_Phase = new PhaseBL(); objBL_Phase.Elimina(objE_Phase); 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); } }
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\\Phase.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 <PhaseBE> lstPhase = null; lstPhase = new PhaseBL().ListaTodosActivo(Parametros.intEmpresaId); if (lstPhase.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 lstPhase) { xlHoja.Cells[Row, 1] = item.IdPhase; xlHoja.Cells[Row, 2] = item.NamePhase; Row = Row + 1; Secuencia = Secuencia + 1; } } xlLibro.SaveAs("C:\\Excel\\Phase.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\\Phase.xlsx"); //XtraMessageBox.Show("It was imported correctly \n The file was generated C:\\Excel\\Phase.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 frmManPhaseEdit_Load(object sender, EventArgs e) { if (pOperacion == Operacion.Nuevo) { this.Text = "Phase - New"; } else if (pOperacion == Operacion.Modificar) { this.Text = "Phase - Update"; PhaseBE objE_Phase = null; objE_Phase = new PhaseBL().Selecciona(IdPhase); if (objE_Phase != null) { txtDescripcion.Text = objE_Phase.NamePhase.Trim(); } } txtDescripcion.Select(); }