Ejemplo n.º 1
0
        public Boolean ModificarDB(tb_Bodega_Info info, ref string msg)
        {
            try
            {
                using (EntitiesGeneral context = new EntitiesGeneral())
                {
                    var selecte = context.tb_bodega.Count(q => q.IdEmpresa == info.IdEmpresa && q.IdSucursal == info.IdSucursal && q.IdBodega == info.IdBodega);

                    if (selecte == 0)
                    {
                        tb_Sucursal_Data        odata   = new tb_Sucursal_Data();
                        List <tb_Sucursal_Info> listaSu = new List <tb_Sucursal_Info>();
                        listaSu = odata.Get_List_Sucursal(info.IdEmpresa);

                        tb_Sucursal_Info infoSu = new tb_Sucursal_Info();
                        infoSu = listaSu.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdSucursal == info.IdSucursal);

                        msg = "La Sucursal : " + infoSu.Su_Descripcion + " no tiene bodega creada";
                        return(false);
                    }

                    else
                    {
                        var contact = context.tb_bodega.First(obj => obj.IdEmpresa == info.IdEmpresa && obj.IdSucursal == info.IdSucursal && obj.IdBodega == info.IdBodega);
                        if (info.Estado == false)
                        {
                            if (VerificarSiBodegaTieneMovimientos(info, ref msg))
                            {
                                return(false);
                            }
                        }

                        contact.bo_Descripcion       = info.bo_Descripcion;
                        contact.cod_punto_emision    = info.cod_punto_emision;
                        contact.bo_EsBodega          = info.bo_esBodega;
                        contact.bo_manejaFacturacion = info.bo_manejaFacturacion;
                        contact.IdUsuarioUltMod      = info.IdUsuarioUltMod;
                        contact.Fecha_UltMod         = info.Fecha_UltMod;
                        contact.IdCentroCosto        = info.IdCentroCosto;
                        contact.nom_pc = info.nom_pc;
                        contact.ip     = info.ip;
                        contact.Estado = (info.Estado == true) ? "A" : "I";
                        contact.IdEstadoAproba_x_Ing_Egr_Inven = info.IdEstadoAproba_x_Ing_Egr_Inven;

                        contact.IdCtaCtble_Inve  = (info.IdCtaCtble_Inve == "") ? null : info.IdCtaCtble_Inve;
                        contact.IdCtaCtble_Costo = (info.IdCtaCtble_Costo == "") ? null : info.IdCtaCtble_Costo;


                        context.SaveChanges();
                        msg = "Se ha procedido actualizar el registro de la Bodega #: " + info.IdBodega.ToString() + " exitosamente";
                    }
                }
                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;
                msg     = "Se ha producido el siguiente error: " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        public Boolean GrabarDB(tb_Empresa_Info info)
        {
            try
            {
                int idEmpresa = 0;
                using (EntitiesGeneral context = new EntitiesGeneral())
                {
                    EntitiesGeneral EDB = new EntitiesGeneral();
                    var             Q   = from per in EDB.tb_empresa
                                          where per.IdEmpresa == info.IdEmpresa
                                          select per;
                    if (Q.ToList().Count == 0)
                    {
                        idEmpresa = getIdEmpresa();

                        var address = new tb_empresa();

                        if (info.codigo == "")
                        {
                            info.codigo = idEmpresa.ToString();
                        }
                        address.IdEmpresa              = idEmpresa;
                        address.em_nombre              = info.em_nombre;
                        address.em_ruc                 = info.em_ruc;
                        address.em_gerente             = info.em_gerente;
                        address.em_contador            = info.em_contador;
                        address.em_rucContador         = info.em_rucContador;
                        address.em_telefonos           = info.em_telefonos;
                        address.em_fax                 = info.em_fax;
                        address.em_notificacion        = info.em_notificacion;
                        address.em_direccion           = info.em_direccion;
                        address.em_tel_int             = info.em_tel_int;
                        address.em_logo                = info.em_logo;
                        address.em_fondo               = info.em_fondo;
                        address.em_fechaInicioContable = info.em_fechaInicioContable;
                        address.Estado                 = info.Estado;
                        address.codigo                 = info.codigo;
                        address.RazonSocial            = info.RazonSocial;
                        address.NombreComercial        = info.NombreComercial;
                        address.ContribuyenteEspecial  = info.ContribuyenteEspecial;
                        address.ObligadoAllevarConta   = info.ObligadoAllevarConta;
                        address.cod_entidad_dinardap   = info.cod_entidad_dinardap;
                        address.em_Email               = info.em_Email;
                        context.tb_empresa.Add(address);
                        context.SaveChanges();

                        tb_Sucursal_Data oDataSucursal = new tb_Sucursal_Data();
                        tb_Sucursal_Info infoSucursal  = new tb_Sucursal_Info();

                        int    id  = 0;
                        string msg = "";

                        infoSucursal.IdEmpresa      = idEmpresa;
                        infoSucursal.Su_Descripcion = "MATRIZ";
                        infoSucursal.Fecha_Transac  = DateTime.Now;

                        oDataSucursal.GrabarDB(infoSucursal, ref id, ref msg);
                    }
                    else
                    {
                        return(false);
                    }
                }
                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(ex.ToString());
            }
        }