Esempio n. 1
0
            //ya  esta lista esta funcion 16/10/17
            private bool InternalSave(Sucursal sucursal)
            {
                try
                {
                    SqlCommand comando = new SqlCommand();
                    comando.CommandText = "usp_Sucursal_Add";
                    comando.CommandType = CommandType.StoredProcedure;

                    comando.Parameters.Add("@UidSucursal", SqlDbType.UniqueIdentifier);
                    comando.Parameters["@UidSucursal"].Direction = ParameterDirection.Output;

                    comando.Parameters.Add("@UidEmpresa", SqlDbType.UniqueIdentifier);
                    comando.Parameters["@UidEmpresa"].Value = sucursal._UidEmpresa;

                    comando.Parameters.Add("@VchNombre", SqlDbType.NVarChar, 30);
                    comando.Parameters["@VchNombre"].Value = sucursal._StrNombre;

                    comando.Parameters.Add("@DtFechaRegistro", SqlDbType.DateTime);
                    comando.Parameters["@DtFechaRegistro"].Value = DateTime.Today;

                    comando.Parameters.Add("@VchRutaImagen", SqlDbType.NVarChar, 200);
                    comando.Parameters["@VchRutaImagen"].Value = sucursal._RutaImagen;

                    comando.Parameters.Add("@UidStatus", SqlDbType.UniqueIdentifier);
                    comando.Parameters["@UidStatus"].Value = sucursal._UidStatus;

                    comando.AddParameter("@UidTipoSucursal", sucursal._UidTipoSucursal, SqlDbType.UniqueIdentifier);

                    bool result = _Conexion.ExecuteCommand(comando, false);

                    sucursal._UidSucursal = new Guid(comando.Parameters["@UidSucursal"].Value.ToString());

                    comando.Dispose();

                    return(result);
                }
                catch (SqlException e)
                {
                    throw new DatabaseException("Cannot update Empresa entry", e);
                }
            }
Esempio n. 2
0
            //ya  esta lista esta funcion 16/10/17
            public List <Sucursal> BuscarSucursal(Guid UidEmpresa, string Nombre)
            {
                List <Sucursal> sucursales = new List <Sucursal>();
                Sucursal        sucursal   = null;

                SqlCommand comando = new SqlCommand();

                comando.CommandText = "usp_BuscarSucursal";
                comando.CommandType = CommandType.StoredProcedure;

                comando.Parameters.Add("@UidEmpresa", SqlDbType.UniqueIdentifier);
                comando.Parameters["@UidEmpresa"].Value = UidEmpresa;

                if (Nombre != string.Empty)
                {
                    comando.Parameters.Add("@VchNombre", SqlDbType.NVarChar, 50);
                    comando.Parameters["@VchNombre"].Value = Nombre;
                }


                DataTable table = _Conexion.ExecuteQuery(comando);

                foreach (DataRow row in table.Rows)
                {
                    sucursal = new Sucursal()
                    {
                        _ExistsInDatabase = true,
                        _UidSucursal      = new Guid(row["UidSucursal"].ToString()),
                        _StrNombre        = row["VchNombre"].ToString(),
                        _DtFechaRegistro  = (DateTime)row["DtFechaRegistro"],
                        _UidEmpresa       = new Guid(row["UidEmpresa"].ToString()),
                        _UidTipoSucursal  = (Guid)row["UidTipoSucursal"],
                        _UidStatus        = (Guid)row["UidStatus"],
                        _StrTipoSucursal  = (string)row["VchTipoSucursal"],
                        _RutaImagen       = row["VchRutaImagen"].ToString(),
                    };
                    sucursales.Add(sucursal);
                }
                return(sucursales);
            }
Esempio n. 3
0
            public List <Sucursal> FindAll(Guid uidEmpresa)
            {
                List <Sucursal> sucursales = new List <Sucursal>();
                Sucursal        Sucursal   = null;

                try
                {
                    SqlCommand comando = new SqlCommand();
                    comando.CommandText = "usp_Sucursal_FindAll";
                    comando.CommandType = CommandType.StoredProcedure;

                    comando.AddParameter("@UidEmpresa", uidEmpresa, SqlDbType.UniqueIdentifier);

                    DataTable table = _Conexion.ExecuteQuery(comando);

                    foreach (DataRow row in table.Rows)
                    {
                        Sucursal = new Sucursal()
                        {
                            _ExistsInDatabase = true,
                            _UidSucursal      = new Guid(row["UidSucursal"].ToString()),
                            _StrNombre        = row["VchNombre"].ToString(),
                            _DtFechaRegistro  = (DateTime)row["DtFechaRegistro"],
                            _UidEmpresa       = new Guid(row["UidEmpresa"].ToString()),
                            _UidTipoSucursal  = (Guid)row["UidTipoSucursal"],
                            _StrTipoSucursal  = (string)row["VchTipoSucursal"],
                            _UidStatus        = (Guid)row["UidStatus"],
                            _RutaImagen       = row["VchRutaImagen"].ToString(),
                        };
                        sucursales.Add(Sucursal);
                    }
                }
                catch (SqlException e)
                {
                    throw new DatabaseException("Cannot load Sucursales", e);
                }

                return(sucursales);
            }