예제 #1
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                if (!ValidarIngreso())
                {
                    TypeDesignBL objBL_TypeDesign = new TypeDesignBL();
                    TypeDesignBE objTypeDesign    = new TypeDesignBE();

                    objTypeDesign.IdTypeDesign   = IdTypeDesign;
                    objTypeDesign.NameTypeDesign = txtDescripcion.Text;
                    objTypeDesign.FlagState      = true;
                    objTypeDesign.Login          = Parametros.strUsuarioLogin;
                    objTypeDesign.Machine        = WindowsIdentity.GetCurrent().Name.ToString();
                    objTypeDesign.IdCompany      = Parametros.intEmpresaId;

                    if (pOperacion == Operacion.Nuevo)
                    {
                        objBL_TypeDesign.Inserta(objTypeDesign);
                    }
                    else
                    {
                        objBL_TypeDesign.Actualiza(objTypeDesign);
                    }

                    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())
                    {
                        TypeDesignBE objE_TypeDesign = new TypeDesignBE();
                        objE_TypeDesign.IdTypeDesign = int.Parse(gvTypeDesign.GetFocusedRowCellValue("IdTypeDesign").ToString());
                        objE_TypeDesign.Login        = Parametros.strUsuarioLogin;
                        objE_TypeDesign.Machine      = WindowsIdentity.GetCurrent().Name.ToString();
                        objE_TypeDesign.IdCompany    = Parametros.intEmpresaId;

                        TypeDesignBL objBL_TypeDesign = new TypeDesignBL();
                        objBL_TypeDesign.Elimina(objE_TypeDesign);
                        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\\TypeDesign.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 <TypeDesignBE> lstTypeDesign = null;
                lstTypeDesign = new TypeDesignBL().ListaTodosActivo(Parametros.intEmpresaId);
                if (lstTypeDesign.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 lstTypeDesign)
                    {
                        xlHoja.Cells[Row, 1] = item.IdTypeDesign;
                        xlHoja.Cells[Row, 2] = item.NameTypeDesign;

                        Row       = Row + 1;
                        Secuencia = Secuencia + 1;
                    }
                }

                xlLibro.SaveAs("C:\\Excel\\TypeDesign.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\\TypeDesign.xlsx");
                //XtraMessageBox.Show("It was imported correctly \n The file was generated C:\\Excel\\TypeDesign.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);
            }
        }
예제 #4
0
        private void frmManTypeDesignEdit_Load(object sender, EventArgs e)
        {
            if (pOperacion == Operacion.Nuevo)
            {
                this.Text = "TypeDesign - New";
            }
            else if (pOperacion == Operacion.Modificar)
            {
                this.Text = "TypeDesign - Update";
                TypeDesignBE objE_TypeDesign = null;
                objE_TypeDesign = new TypeDesignBL().Selecciona(IdTypeDesign);
                if (objE_TypeDesign != null)
                {
                    txtDescripcion.Text = objE_TypeDesign.NameTypeDesign.Trim();
                }
            }

            txtDescripcion.Select();
        }