Exemple #1
0
        public bool modificarDB(in_Ing_Egr_Inven_fj_Info info)
        {
            try
            {
                using (EntitiesInventario_Fj Context = new EntitiesInventario_Fj())
                {
                    in_Ing_Egr_Inven_fj Entity = Context.in_Ing_Egr_Inven_fj.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdSucursal == info.IdSucursal && q.IdMovi_inven_tipo == info.IdMovi_inven_tipo && q.IdNumMovi == info.IdNumMovi);
                    if (Entity != null)
                    {
                        Entity.cod_orden_mantenimiento = info.cod_orden_mantenimiento;
                        Entity.IdEmpleado = info.IdEmpleado;
                        Context.SaveChanges();
                    }
                    else
                    {
                        guardarDB(info);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                string mensaje = "";
                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.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Exemple #2
0
        public decimal Get_Id(int idEmpresa, int idSucursal)
        {
            try
            {
                decimal x = 0;
                using (EntitiesInventario_Fj Conexion = new EntitiesInventario_Fj())
                {
                    x = (from q in Conexion.in_Orden_servicio_x_Activo_fijo
                         where q.IdEmpresa == idEmpresa && q.IdSucursal == idSucursal
                         select q.IdOrdenSer_x_Af).Max() + 1;
                }

                return(x);
            }
            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.ToString();
                return(1);
            }
        }
Exemple #3
0
        public bool guardarDB(in_Ing_Egr_Inven_fj_Info info)
        {
            try
            {
                using (EntitiesInventario_Fj Context = new EntitiesInventario_Fj())
                {
                    in_Ing_Egr_Inven_fj Entity = new in_Ing_Egr_Inven_fj();
                    Entity.IdEmpresa               = info.IdEmpresa;
                    Entity.IdSucursal              = info.IdSucursal;
                    Entity.IdMovi_inven_tipo       = info.IdMovi_inven_tipo;
                    Entity.IdNumMovi               = info.IdNumMovi;
                    Entity.cod_orden_mantenimiento = info.cod_orden_mantenimiento;
                    Entity.IdEmpleado              = info.IdEmpleado;
                    Context.in_Ing_Egr_Inven_fj.Add(Entity);
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                string mensaje = "";
                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.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Exemple #4
0
        public Boolean ActualizarDB(in_Orden_servicio_x_Activo_fijo_Info info)
        {
            try
            {
                using (EntitiesInventario_Fj Conexion = new EntitiesInventario_Fj())
                {
                    in_Orden_servicio_x_Activo_fijo Orden = Conexion.in_Orden_servicio_x_Activo_fijo.FirstOrDefault(q => q.IdOrdenSer_x_Af == info.IdOrdenSer_x_Af && q.IdEmpresa == info.IdEmpresa &&
                                                                                                                    q.IdSucursal == info.IdSucursal);

                    Orden.IdEmpresa       = info.IdEmpresa;
                    Orden.IdSucursal      = info.IdSucursal;
                    Orden.IdOrdenSer_x_Af = info.IdOrdenSer_x_Af;
                    Orden.IdBodega        = info.IdBodega;
                    Orden.IdActivoFijo    = info.IdActivoFijo;
                    Orden.IdProveedor     = info.IdProveedor;
                    Orden.Fecha           = info.Fecha;
                    Orden.Num_Fact        = info.Num_Fact;
                    Orden.Num_Documento   = info.Num_Documento;
                    Orden.IdCentroCosto   = info.IdCentroCosto;
                    Orden.Observacion     = info.Observacion;
                    Orden.Estado          = info.Estado;

                    in_Orden_servicio_x_Activo_fijo_det_Data        Data = new in_Orden_servicio_x_Activo_fijo_det_Data();
                    List <in_Orden_servicio_x_Activo_fijo_det_Info> Lista_det_OS;
                    Lista_det_OS = new List <in_Orden_servicio_x_Activo_fijo_det_Info>(Data.Get_Lista_det_x_Orden_servicio(info.IdEmpresa, info.IdSucursal, info.IdOrdenSer_x_Af));

                    if (Lista_det_OS.Count() != 0)
                    {
                        Data.EliminarDB(info);
                    }

                    foreach (var item in info.List_in_Orden_servicio_x_Activo_fijo_det)
                    {
                        item.IdEmpresa       = info.IdEmpresa;
                        item.IdSucursal      = info.IdSucursal;
                        item.IdOrdenSer_x_Af = info.IdOrdenSer_x_Af;
                    }
                    Data.GuardarDB(info.List_in_Orden_servicio_x_Activo_fijo_det);

                    Conexion.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.ToString();
                throw new Exception(ex.ToString());
            }
        }
Exemple #5
0
        public List <in_Orden_servicio_x_Activo_fijo_Info> Get_Lista_Vista_x_sucursal_x_bodega(int idEmpresa, int idSucursal, int idSucursalFin, int idBodega, int idBodegaFin, DateTime fechaIni, DateTime FechaFin, ref string mensaje)
        {
            try
            {
                List <in_Orden_servicio_x_Activo_fijo_Info> Lista = new List <in_Orden_servicio_x_Activo_fijo_Info>();

                using (EntitiesInventario_Fj Conexion = new EntitiesInventario_Fj())
                {
                    Lista = (from q in Conexion.vwin_Orden_servicio_x_activo_fijo
                             where q.IdEmpresa == idEmpresa &&
                             idSucursal <= q.IdSucursal && q.IdSucursal <= idSucursalFin &&
                             idBodega <= q.IdBodega && q.IdBodega <= idBodegaFin &&
                             fechaIni <= q.Fecha && q.Fecha <= FechaFin
                             select new in_Orden_servicio_x_Activo_fijo_Info
                    {
                        IdEmpresa = q.IdEmpresa,
                        IdSucursal = q.IdSucursal,
                        IdOrdenSer_x_Af = q.IdOrdenSer_x_Af,
                        IdBodega = q.IdBodega,
                        IdActivoFijo = q.IdActivoFijo,
                        IdProveedor = q.IdProveedor,
                        Fecha = q.Fecha,
                        Num_Fact = q.Num_Fact,
                        Num_Documento = q.Num_Documento,
                        IdCentroCosto = q.IdCentroCosto,
                        Observacion = q.Observacion,
                        Estado = q.Estado,
                        bo_Descripcion = q.bo_Descripcion,
                        Af_Nombre = q.Af_Nombre,
                        Centro_costo = q.Centro_costo,
                        pr_nombre = q.pr_nombre,
                        Su_Descripcion = q.Su_Descripcion
                    }).ToList();
                }
                return(Lista);
            }
            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.ToString();
                throw new Exception(ex.ToString());
            }
        }
Exemple #6
0
        public Boolean GuardarDB(in_Orden_servicio_x_Activo_fijo_Info info)
        {
            try
            {
                using (EntitiesInventario_Fj Conexion = new EntitiesInventario_Fj())
                {
                    in_Orden_servicio_x_Activo_fijo Orden = new in_Orden_servicio_x_Activo_fijo();

                    Orden.IdEmpresa       = info.IdEmpresa;
                    Orden.IdSucursal      = info.IdSucursal;
                    Orden.IdOrdenSer_x_Af = info.IdOrdenSer_x_Af = Get_Id(info.IdEmpresa, info.IdSucursal);
                    Orden.IdBodega        = info.IdBodega;
                    Orden.IdActivoFijo    = info.IdActivoFijo;
                    Orden.IdProveedor     = info.IdProveedor;
                    Orden.Fecha           = info.Fecha;
                    Orden.Num_Fact        = info.Num_Fact;
                    Orden.Num_Documento   = info.Num_Documento;
                    Orden.IdCentroCosto   = info.IdCentroCosto;
                    Orden.Observacion     = info.Observacion;
                    Orden.Estado          = info.Estado;

                    Conexion.in_Orden_servicio_x_Activo_fijo.Add(Orden);
                    Conexion.SaveChanges();

                    in_Orden_servicio_x_Activo_fijo_det_Data Data = new in_Orden_servicio_x_Activo_fijo_det_Data();
                    foreach (var item in info.List_in_Orden_servicio_x_Activo_fijo_det)
                    {
                        item.IdEmpresa       = info.IdEmpresa;
                        item.IdSucursal      = info.IdSucursal;
                        item.IdOrdenSer_x_Af = info.IdOrdenSer_x_Af;
                    }
                    Data.GuardarDB(info.List_in_Orden_servicio_x_Activo_fijo_det);
                }

                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.ToString();
                throw new Exception(ex.ToString());
            }
        }
Exemple #7
0
        public List <in_Orden_servicio_x_Activo_fijo_Info> Get_Lista_Orden_servicio_x_Sucursal_y_Bodega(int idEmpresa, int idSucursal, int idBodega)
        {
            try
            {
                List <in_Orden_servicio_x_Activo_fijo_Info> Lista = new List <in_Orden_servicio_x_Activo_fijo_Info>();

                using (EntitiesInventario_Fj Conexion = new EntitiesInventario_Fj())
                {
                    Lista = (from q in Conexion.in_Orden_servicio_x_Activo_fijo
                             where q.IdEmpresa == idEmpresa && q.IdSucursal == idSucursal &&
                             q.IdBodega == idBodega
                             select new in_Orden_servicio_x_Activo_fijo_Info
                    {
                        IdEmpresa = q.IdEmpresa,
                        IdSucursal = q.IdSucursal,
                        IdOrdenSer_x_Af = q.IdOrdenSer_x_Af,
                        IdBodega = q.IdBodega,
                        IdActivoFijo = q.IdActivoFijo,
                        IdProveedor = q.IdProveedor,
                        Fecha = q.Fecha,
                        Num_Fact = q.Num_Fact,
                        Num_Documento = q.Num_Documento,
                        IdCentroCosto = q.IdCentroCosto,
                        Observacion = q.Observacion,
                        IdUsuarioUltAnu = q.IdUsuarioUltAnu,
                        motivoAnulacion = q.motivoAnulacion,
                        FechaHoraAnul = q.FechaHoraAnul,
                        Estado = q.Estado
                    }).ToList();
                }
                return(Lista);
            }
            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.ToString();
                throw new Exception(ex.ToString());
            }
        }
Exemple #8
0
        public Boolean EliminarDB(in_Orden_servicio_x_Activo_fijo_Info info)
        {
            try
            {
                EntitiesInventario_Fj Conexion = new EntitiesInventario_Fj();

                var Comando = Conexion.Database.ExecuteSqlCommand("delete from in_Orden_servicio_x_Activo_fijo_det where IdEmpresa = " + info.IdEmpresa + " and IdSucursal = " + info.IdSucursal + " and IdOrdenSer_x_Af = " + info.IdOrdenSer_x_Af + "");

                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.ToString();
                throw new Exception(ex.ToString());
            }
        }
Exemple #9
0
        public Boolean GuardarDB(List <in_Orden_servicio_x_Activo_fijo_det_Info> info)
        {
            try
            {
                int sec = 1;
                foreach (var item in info)
                {
                    using (EntitiesInventario_Fj Conexion = new EntitiesInventario_Fj())
                    {
                        in_Orden_servicio_x_Activo_fijo_det Orden = new in_Orden_servicio_x_Activo_fijo_det();
                        Orden.IdEmpresa       = item.IdEmpresa;
                        Orden.IdSucursal      = item.IdSucursal;
                        Orden.IdOrdenSer_x_Af = item.IdOrdenSer_x_Af;
                        Orden.Secuencia       = sec;
                        Orden.IdProducto      = item.IdProducto;
                        Orden.Cantidad        = item.Cantidad;
                        Orden.Costo           = item.Costo;
                        Orden.SubTotal        = item.SubTotal;
                        Orden.Iva             = item.Iva;
                        Orden.Total           = item.Total;
                        Orden.Maneja_Iva      = item.Maneja_Iva;

                        Conexion.in_Orden_servicio_x_Activo_fijo_det.Add(Orden);
                        Conexion.SaveChanges();
                    }
                    sec++;
                }
                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.ToString();
                throw new Exception(ex.ToString());
            }
        }
Exemple #10
0
        public in_Ing_Egr_Inven_fj_Info get_info(int IdEmpresa, int IdSucursal, int IdMoviInven_tipo, decimal IdNumMovi)
        {
            try
            {
                in_Ing_Egr_Inven_fj_Info info = new in_Ing_Egr_Inven_fj_Info();

                using (EntitiesInventario_Fj Context = new EntitiesInventario_Fj())
                {
                    var lst = from q in Context.in_Ing_Egr_Inven_fj
                              where q.IdEmpresa == IdEmpresa &&
                              q.IdSucursal == IdSucursal &&
                              q.IdMovi_inven_tipo == IdMoviInven_tipo &&
                              q.IdNumMovi == IdNumMovi
                              select q;

                    foreach (var item in lst)
                    {
                        info.IdEmpresa               = item.IdEmpresa;
                        info.IdSucursal              = item.IdSucursal;
                        info.IdMovi_inven_tipo       = item.IdMovi_inven_tipo;
                        info.IdNumMovi               = item.IdNumMovi;
                        info.cod_orden_mantenimiento = item.cod_orden_mantenimiento;
                        info.IdEmpleado              = item.IdEmpleado;
                    }
                }

                return(info);
            }
            catch (Exception ex)
            {
                string mensaje = "";
                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.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Exemple #11
0
        public Boolean AnularDB(in_Orden_servicio_x_Activo_fijo_Info info)
        {
            try
            {
                using (EntitiesInventario_Fj Conexion = new EntitiesInventario_Fj())
                {
                    in_Orden_servicio_x_Activo_fijo Orden = Conexion.in_Orden_servicio_x_Activo_fijo.FirstOrDefault(q => q.IdOrdenSer_x_Af == info.IdOrdenSer_x_Af && q.IdEmpresa
                                                                                                                    == info.IdEmpresa && q.IdSucursal == info.IdSucursal);

                    Orden.Estado          = "I";
                    Orden.IdUsuarioUltAnu = info.IdUsuarioUltAnu;
                    Orden.motivoAnulacion = info.motivoAnulacion;
                    Orden.FechaHoraAnul   = info.FechaHoraAnul;

                    in_Orden_servicio_x_Activo_fijo_det_Data        Data = new in_Orden_servicio_x_Activo_fijo_det_Data();
                    List <in_Orden_servicio_x_Activo_fijo_det_Info> Lista_det_OS;
                    Lista_det_OS = new List <in_Orden_servicio_x_Activo_fijo_det_Info>(Data.Get_Lista_det_x_Orden_servicio(info.IdEmpresa, info.IdSucursal, info.IdOrdenSer_x_Af));

                    if (Lista_det_OS.Count() != 0)
                    {
                        Data.EliminarDB(info);
                    }

                    Conexion.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.ToString();
                throw new Exception(ex.ToString());
            }
        }
Exemple #12
0
        public List <in_Orden_servicio_x_Activo_fijo_det_Info> Get_Lista_det_x_Orden_servicio(int idEmpresa, int idSucursal, decimal IdOrdenSer_x_Af)
        {
            try
            {
                List <in_Orden_servicio_x_Activo_fijo_det_Info> Lista = new List <in_Orden_servicio_x_Activo_fijo_det_Info>();

                using (EntitiesInventario_Fj Conexion = new EntitiesInventario_Fj())
                {
                    Lista = (from q in Conexion.in_Orden_servicio_x_Activo_fijo_det
                             where q.IdEmpresa == idEmpresa && q.IdSucursal == idSucursal && q.IdOrdenSer_x_Af == IdOrdenSer_x_Af
                             select new in_Orden_servicio_x_Activo_fijo_det_Info {
                        IdEmpresa = q.IdEmpresa,
                        IdSucursal = q.IdSucursal,
                        IdOrdenSer_x_Af = q.IdOrdenSer_x_Af,
                        Secuencia = q.Secuencia,
                        IdProducto = q.IdProducto,
                        Cantidad = q.Cantidad,
                        Costo = q.Costo,
                        SubTotal = q.SubTotal,
                        Iva = q.Iva,
                        Total = q.Total,
                        Maneja_Iva = q.Maneja_Iva,
                    }).ToList();
                }
                return(Lista);
            }
            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.ToString();
                throw new Exception(ex.ToString());
            }
        }