public Boolean GetExiste(ro_empleado_gastos_perso_Info info, ref string msg)
        {
            try
            {
                Boolean valorRetornar = false;
                using (EntitiesRoles db = new EntitiesRoles())
                {
                    int cont = (from a in db.ro_empleado_gastos_perso
                                where a.IdEmpresa == info.IdEmpresa && a.IdEmpleado == info.IdEmpleado &&
                                a.Anio_fiscal == info.Anio_fiscal
                                select a).Count();

                    if (cont > 0)
                    {
                        valorRetornar = true;
                    }
                    else
                    {
                        valorRetornar = false;
                    }
                }
                return(valorRetornar);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                mensaje = msg = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                throw new Exception(ex.InnerException.ToString());
            }
        }
 private void gridViewGastosPersonales_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     try
     {
         infoGastosPersonales = new ro_empleado_gastos_perso_Info();
         infoGastosPersonales = gridViewGastosPersonales.GetFocusedRow() as ro_empleado_gastos_perso_Info;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         Log_Error_bus.Log_Error(ex.Message);
     }
 }
        public List <ro_empleado_gastos_perso_Info> Get_Info_empleado_gastos_pers(int IdEmpresa, int IdEmpleado, int anio)
        {
            List <ro_empleado_gastos_perso_Info> lst = new List <ro_empleado_gastos_perso_Info>();

            try
            {
                using (EntitiesRoles rol = new EntitiesRoles())
                {
                    var Consulta = from q in rol.ro_empleado_gastos_perso
                                   where q.IdEmpresa == IdEmpresa &&
                                   q.IdEmpleado == IdEmpleado &&
                                   q.Anio_fiscal == anio
                                   orderby q.IdEmpleado
                                   select q;
                    foreach (var item in Consulta)
                    {
                        ro_empleado_gastos_perso_Info info = new ro_empleado_gastos_perso_Info();
                        info.IdEmpresa          = item.IdEmpresa;
                        info.IdEmpleado         = item.IdEmpleado;
                        info.Anio_fiscal        = item.Anio_fiscal;
                        info.fecha              = item.fecha;
                        info.observacion        = item.observacion;
                        info.Estado             = item.Estado;
                        info.Tipo_Iden          = item.Tipo_Iden;
                        info.Num_Identificacion = item.Num_Identificacion;
                        info.Apellidos_Nombres  = item.Apellidos_Nombres;
                        info.telefono           = item.telefono;
                        info.calle_prin         = item.calle_prin;
                        info.Numero             = item.Numero;
                        info.Intersecion        = item.Intersecion;
                        info.IdProvincia        = item.IdProvincia;
                        info.IdCidudad          = item.IdCidudad;
                        lst.Add(info);
                    }
                }
                return(lst);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
 public Boolean EliminarEmpleadoGastosPersona(ro_empleado_gastos_perso_Info info)
 {
     try
     {
         using (EntitiesRoles ro = new EntitiesRoles())
         {
             ro_empleado_gastos_perso EmpleadoGastosPerso = ro.ro_empleado_gastos_perso.First(v => v.IdEmpleado == info.IdEmpleado && v.Anio_fiscal == info.Anio_fiscal && v.IdEmpresa == info.IdEmpresa);
             ro.ro_empleado_gastos_perso.Remove(EmpleadoGastosPerso);
             ro.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         string arreglo = ToString();
         tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
         tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
         oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
         mensaje = ex.InnerException + " " + ex.Message;
         throw new Exception(ex.InnerException.ToString());
     }
 }
        public Boolean ModificarBD(ro_empleado_gastos_perso_Info info, ref string msg)
        {
            try
            {
                using (EntitiesRoles db = new EntitiesRoles())
                {
                    ro_empleado_gastos_perso item = (from a in db.ro_empleado_gastos_perso
                                                     where a.IdEmpresa == info.IdEmpresa && a.IdEmpleado == info.IdEmpleado &&
                                                     a.Anio_fiscal == info.Anio_fiscal
                                                     select a).FirstOrDefault();

                    item.fecha              = info.fecha;
                    item.observacion        = info.observacion;
                    item.Estado             = info.Estado;
                    item.Tipo_Iden          = info.Tipo_Iden;
                    item.Num_Identificacion = info.Num_Identificacion;
                    item.Apellidos_Nombres  = info.Apellidos_Nombres;
                    item.telefono           = info.telefono;
                    item.calle_prin         = info.calle_prin;
                    item.Numero             = info.Numero;
                    item.Intersecion        = info.Intersecion;
                    item.IdProvincia        = info.IdProvincia;
                    item.IdCidudad          = info.IdCidudad;
                    item.IdEmpresa          = info.IdEmpresa;

                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                mensaje = msg = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                throw new Exception(ex.InnerException.ToString());
            }
        }
Пример #6
0
        public Boolean GuardarBD(ro_empleado_gastos_perso_Info info, ref string msg)
        {
            try
            {
                Boolean valorRetornar = false;

                //MODIFICA
                if (oData.GetExiste(info, ref msg))
                {
                    valorRetornar = oData.ModificarBD(info, ref msg);
                }
                else  //GRABA
                {
                    info.Estado   = "A";
                    valorRetornar = oData.GuardarBD(info, ref msg);
                }

                //GUARDA DETALLE DE GASTOS PERSONALES
                if (valorRetornar)
                {
                    //ELIMINA VALORES PREVIOS
                    oRo_empleado_gastos_perso_x_Gastos_deduci_Bus.EliminarBD(info.IdEmpresa, info.IdEmpleado, info.Anio_fiscal, ref msg);


                    foreach (ro_empleado_gastos_perso_x_Gastos_deduci_Info item in info.oListRo_empleado_gastos_perso_x_Gastos_deduci_Info)
                    {
                        if (!oRo_empleado_gastos_perso_x_Gastos_deduci_Bus.GrabarBD(item, ref msg))
                        {
                            valorRetornar = false;
                            break;
                        }
                    }
                }


                //GUARDA DETALLE DE OTROS GASTOS PERSONALES
                if (valorRetornar)
                {
                    //ELIMINA VALORES PREVIOS
                    oRo_empleado_gastos_perso_x_otros_gast_deduci_Bus.EliminarBD(info.IdEmpresa, info.IdEmpleado, info.Anio_fiscal, ref msg);

                    foreach (ro_empleado_gastos_perso_x_otros_gast_deduci_Info item in info.oListRo_empleado_gastos_perso_x_otros_gast_deduci_Info)
                    {
                        if (!oRo_empleado_gastos_perso_x_otros_gast_deduci_Bus.GrabarBD(item, ref msg))
                        {
                            valorRetornar = false;
                            break;
                        }
                    }
                }

                return(valorRetornar);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "GuardarBD", ex.Message), ex)
                      {
                          EntityType = typeof(ro_empleado_gastos_perso_Bus)
                      };
            }
        }
        public Boolean GuardarXml()
        {
            try
            {
                int     controlaRuta = 1;
                int     secuencia    = 0;
                string  rut          = "";
                int     error        = 0;//lo uso para ver si encontro algun error al momento de comparacion del xsd y el xml
                Boolean retorna      = true;

                gastosPersonales DataGastos = new gastosPersonales();
                List <ro_empleado_gastos_perso_Info> EGPError = new List <ro_empleado_gastos_perso_Info>();

                //pasa el archivo de la base de datos hacia una variable con el mismo tipo
                paraminfo = new List <ro_Config_Rubros_ParametrosGenerales_Info>(parambus.ObtenerParamGenerales());
                foreach (var item2 in paraminfo)
                {
                    if (item2.IdTipoParametro == "FILEXSD107")
                    {
                        XSD = item2.File;
                    }
                }


                foreach (var item in xmlinfoGastosPersonales)
                {
                    if (item.check == true)
                    {
                        //DataGastos = CargaDatos();
                        string ruta = "";
                        DataGastos = empBus.Get_GastosPersonales_x_Empleado(param.IdEmpresa, item.IdEmpleado, item.Anio_fiscal);
                        string Nombre = "AGP" + item.Anio_fiscal + item.Num_Identificacion + ".xml";
                        saveFileDialog1 = new SaveFileDialog();
                        //saveFileDialog1.FileName = Nombre;
                        saveFileDialog1.FileName         = "Archivos";
                        saveFileDialog1.Filter           = "Todos los archivos (*.xml)|*.xml";
                        saveFileDialog1.InitialDirectory = @direcDoc;

                        //Obtener Ruta de Carpetas
                        if (controlaRuta == 1)
                        {
                            if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
                            {
                                retorna = false;
                                break;
                            }

                            System.IO.DirectoryInfo s = new DirectoryInfo(saveFileDialog1.FileName);
                            rut = s.Parent.FullName;
                            controlaRuta++;
                        }

                        ruta = rut + "\\" + Nombre;

                        if (File.Exists(ruta))
                        {
                            File.Delete(ruta);
                        }

                        if (SerializeToXML(DataGastos, ruta))
                        {
                            ////progressBar1.Value = 100;

                            if (XSD != null)
                            {
                                string msg = "";
                                if (XSD == null)
                                {
                                    MessageBox.Show("No puede realizar la validacón del xml con el XSD, debido a que el archivo XSD no se ha ingresado.. \nIngréselos desde la pantalla de parámetros Cuentas por Pagar,o comuníquese con sistemas", "SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                else
                                {
                                    if (!validaXmlConXsd(ruta, XSD, ref msg))
                                    {
                                        secuencia++;
                                        ro_empleado_gastos_perso_Info infoError = new ro_empleado_gastos_perso_Info();
                                        infoError.Secuencia   = secuencia;
                                        infoError.RutaArchivo = ruta;
                                        infoError.Error       = msg;
                                        EGPError.Add(infoError);
                                        error++;
                                    }
                                    //MessageBox.Show("Archivo AGP XML generado en la ruta:" + ruta + ", pero tiene los Siguientes errores:\n " + msg, "Errores en Validación con XSD", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    //else
                                    //    MessageBox.Show("Archivo AGP XML generado correctamente en la ruta:" + ruta, "SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Archivo AGP XML generado en la ruta:" + ruta + "\n No se realizo la validación XSD no ingresado", "SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            //progressBar1.Value = 0;
                            MessageBox.Show("Ocurrio un inconveniente al guardar el archivo AGP XML", "SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        //StreamReader sr = new StreamReader(saveFileDialog1.FileName, System.Text.Encoding.Default);
                        //this.richTextBox1.Text = sr.ReadToEnd();
                    }
                }
                if (error >= 1)
                {
                    MessageBox.Show("Se han detectado errores", "SISTEMA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    frmRo_Empleado_Gastos_Personales_Cons_Xml errorForm = new frmRo_Empleado_Gastos_Personales_Cons_Xml();
                    errorForm.SETINFO_ = EGPError;
                    errorForm.Show();
                }
                //else
                //{
                //    MessageBox.Show("Archivos Almacenados Correctamente", "Operación Correcta");
                //}
                return(retorna);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log_Error_bus.Log_Error(ex.Message); return(false);
            }
        }