Beispiel #1
0
 public in_subgrupo_Info get_info(int IdEmpresa, string IdCategoria, int IdLinea, int IdGrupo, int IdSubgrupo)
 {
     try
     {
         in_subgrupo_Info info = new in_subgrupo_Info();
         using (Entities_inventario Context = new Entities_inventario())
         {
             in_subgrupo Entity = Context.in_subgrupo.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdCategoria == IdCategoria && q.IdLinea == IdLinea && q.IdGrupo == IdGrupo && q.IdSubgrupo == IdSubgrupo);
             if (Entity == null)
             {
                 return(null);
             }
             info = new in_subgrupo_Info
             {
                 IdEmpresa    = Entity.IdEmpresa,
                 IdCategoria  = Entity.IdCategoria,
                 IdLinea      = Entity.IdLinea,
                 IdGrupo      = Entity.IdGrupo,
                 IdSubgrupo   = Entity.IdSubgrupo,
                 cod_subgrupo = Entity.cod_subgrupo,
                 nom_subgrupo = Entity.nom_subgrupo,
                 Estado       = Entity.Estado
             };
         }
         return(info);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #2
0
        public bool guardarDB(in_subgrupo_Info info)
        {
            try
            {
                using (Entities_inventario Context = new Entities_inventario())
                {
                    in_subgrupo Entity = new in_subgrupo
                    {
                        IdEmpresa    = info.IdEmpresa,
                        IdCategoria  = info.IdCategoria,
                        IdLinea      = info.IdLinea,
                        IdGrupo      = info.IdGrupo,
                        IdSubgrupo   = info.IdSubgrupo = get_id(info.IdEmpresa, info.IdCategoria, info.IdLinea, info.IdGrupo),
                        cod_subgrupo = info.cod_subgrupo,
                        nom_subgrupo = info.nom_subgrupo,
                        Estado       = info.Estado = "A",

                        IdUsuario     = info.IdUsuario,
                        Fecha_Transac = DateTime.Now
                    };
                    Context.in_subgrupo.Add(Entity);
                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #3
0
        public bool modificarDB(in_subgrupo_Info info)
        {
            try
            {
                using (Entities_inventario Context = new Entities_inventario())
                {
                    in_subgrupo Entity = Context.in_subgrupo.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdCategoria == info.IdCategoria && q.IdLinea == info.IdLinea && q.IdGrupo == info.IdGrupo && q.IdSubgrupo == info.IdSubgrupo);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.cod_subgrupo = info.cod_subgrupo;
                    Entity.nom_subgrupo = info.nom_subgrupo;

                    Entity.IdUsuarioUltMod = info.IdUsuarioUltMod;
                    Entity.Fecha_UltMod    = DateTime.Now;
                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #4
0
        public Boolean GrabarDB(in_subgrupo_info info, ref int IdSubGrupo, ref string msg)
        {
            try
            {
                using (EntitiesInventario context = new EntitiesInventario())
                {
                    var lst = from q in context.in_subgrupo
                              where q.IdEmpresa == info.IdEmpresa &&
                              q.IdCategoria == info.IdCategoria &&
                              q.IdLinea == info.IdLinea &&
                              q.IdGrupo == info.IdGrupo &&
                              q.IdSubgrupo == info.IdSubgrupo
                              select q;

                    if (lst.Count() == 0)
                    {
                        in_subgrupo objSubGrupo = new in_subgrupo();

                        objSubGrupo.IdEmpresa   = info.IdEmpresa;
                        objSubGrupo.IdCategoria = info.IdCategoria;
                        objSubGrupo.IdLinea     = info.IdLinea;
                        objSubGrupo.IdGrupo     = info.IdGrupo;

                        objSubGrupo.IdSubgrupo = IdSubGrupo = (info.IdSubgrupo == null || info.IdSubgrupo == 0) ? GetIdSubGrupo(info.IdEmpresa, info.IdCategoria, info.IdLinea, info.IdGrupo) : info.IdSubgrupo;

                        if (info.cod_subgrupo == null || info.cod_subgrupo == "")
                        {
                            info.cod_subgrupo = objSubGrupo.IdSubgrupo.ToString();
                        }

                        objSubGrupo.cod_subgrupo = info.cod_subgrupo.Trim();


                        objSubGrupo.nom_subgrupo = info.nom_subgrupo.Trim();

                        if (info.abreviatura == null || info.abreviatura == "")
                        {
                            info.abreviatura = info.cod_subgrupo.Trim();
                        }

                        objSubGrupo.abreviatura = info.abreviatura;
                        objSubGrupo.Estado      = "A";

                        if (info.observacion == "" || info.observacion == null)
                        {
                            info.observacion = "";
                        }

                        objSubGrupo.observacion   = info.observacion;
                        objSubGrupo.IdUsuario     = (info.IdUsuario == null) ? "" : info.IdUsuario;
                        objSubGrupo.Fecha_Transac = DateTime.Now;
                        objSubGrupo.nom_pc        = info.nom_pc;
                        objSubGrupo.ip            = info.ip;

                        objSubGrupo.IdCtaCtble_Inve  = info.IdCtaCtble_Inve;
                        objSubGrupo.IdCtaCtble_Costo = info.IdCtaCtble_Costo;

                        objSubGrupo.IdCtaCtble_Gasto_x_cxp = info.IdCtaCtble_Gasto_x_cxp;
                        objSubGrupo.IdCtaCble_Vta          = info.IdCtaCble_Vta;


                        //objSubGrupo.IdCentro_Costo_Inv = info.IdCentro_Costo_Inv;
                        //objSubGrupo.IdCentro_Costo_Cost = info.IdCentro_Costo_Cost;
                        //objSubGrupo.IdCentro_Costo_x_Gasto_x_cxp = info.IdCentro_Costo_x_Gasto_x_cxp;
                        //objSubGrupo.IdCentroCosto_sub_centro_costo_inv = info.IdCentroCosto_sub_centro_costo_inv;
                        //objSubGrupo.IdCentroCosto_sub_centro_costo_cost = info.IdCentroCosto_sub_centro_costo_cost;
                        //objSubGrupo.IdCentroCosto_sub_centro_costo_cxp = info.IdCentroCosto_sub_centro_costo_cxp;
                        //objSubGrupo.IdCtaCble_CosBaseIva = info.IdCtaCble_CosBaseIva;
                        //objSubGrupo.IdCtaCble_CosBase0 = info.IdCtaCble_CosBase0;
                        //objSubGrupo.IdCtaCble_VenIva = info.IdCtaCble_VenIva;
                        //objSubGrupo.IdCtaCble_Ven0 = info.IdCtaCble_Ven0;
                        //objSubGrupo.IdCtaCble_DesIva = info.IdCtaCble_DesIva;
                        //objSubGrupo.IdCtaCble_DevIva = info.IdCtaCble_DevIva;

                        objSubGrupo.IdCtaCble_Des0 = info.IdCtaCble_Des0;
                        objSubGrupo.IdCtaCble_Dev0 = info.IdCtaCble_Dev0;


                        context.in_subgrupo.Add(objSubGrupo);
                        context.SaveChanges();
                    }
                    msg = "Grabación ok..";
                }
                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() + " " + ex.Message;
                throw new Exception(mensaje);
            }
        }