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()) { StatusPOBE objE_StatusPO = new StatusPOBE(); objE_StatusPO.IdStatusPO = int.Parse(gvStatusPO.GetFocusedRowCellValue("IdStatusPO").ToString()); objE_StatusPO.Login = Parametros.strUsuarioLogin; objE_StatusPO.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objE_StatusPO.IdCompany = Parametros.intEmpresaId; StatusPOBL objBL_StatusPO = new StatusPOBL(); objBL_StatusPO.Elimina(objE_StatusPO); 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()) { StatusPOBL objBL_StatusPO = new StatusPOBL(); StatusPOBE objStatusPO = new StatusPOBE(); objStatusPO.IdStatusPO = IdStatusPO; objStatusPO.NameStatusPO = txtDescripcion.Text; objStatusPO.FlagState = true; objStatusPO.Login = Parametros.strUsuarioLogin; objStatusPO.Machine = WindowsIdentity.GetCurrent().Name.ToString(); objStatusPO.IdCompany = Parametros.intEmpresaId; if (pOperacion == Operacion.Nuevo) { objBL_StatusPO.Inserta(objStatusPO); } else { objBL_StatusPO.Actualiza(objStatusPO); } 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\\StatusPO.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 <StatusPOBE> lstStatusPO = null; lstStatusPO = new StatusPOBL().ListaTodosActivo(Parametros.intEmpresaId); if (lstStatusPO.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 lstStatusPO) { xlHoja.Cells[Row, 1] = item.IdStatusPO; xlHoja.Cells[Row, 2] = item.NameStatusPO; Row = Row + 1; Secuencia = Secuencia + 1; } } xlLibro.SaveAs("C:\\Excel\\StatusPO.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\\StatusPO.xlsx"); //XtraMessageBox.Show("It was imported correctly \n The file was generated C:\\Excel\\StatusPO.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 frmManStatusPOEdit_Load(object sender, EventArgs e) { if (pOperacion == Operacion.Nuevo) { this.Text = "StatusPO - New"; } else if (pOperacion == Operacion.Modificar) { this.Text = "StatusPO - Update"; StatusPOBE objE_StatusPO = null; objE_StatusPO = new StatusPOBL().Selecciona(IdStatusPO); if (objE_StatusPO != null) { txtDescripcion.Text = objE_StatusPO.NameStatusPO.Trim(); } } txtDescripcion.Select(); }