Пример #1
0
        /// <summary>
        /// Selects the Single object of SucursalModel table.
        /// </summary>
        public SucursalModel GetSucursalModel(int aId)
        {
            SucursalModel SucursalModel = null;

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlCommand command = connection.CreateCommand();

                    command.Parameters.AddWithValue("@pMode", 2);
                    command.Parameters.AddWithValue("@Id", aId);

                    command.CommandType = CommandType.StoredProcedure;

                    command.CommandText = "sp_tSucursal";

                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            int    Id        = (int)(reader["Id"]);
                            string Nombre    = (string)(reader["Nombre"]);
                            string Ubicacion = (string)(reader["Ubicacion"]);
                            int    IdBanco   = (int)(reader["IdBanco"]);

                            SucursalModel = new SucursalModel
                            {
                                Id        = Id,
                                Nombre    = Nombre,
                                Ubicacion = Ubicacion,
                                Idbanco   = IdBanco,
                            };
                        }
                    }
                }

                return(SucursalModel);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public async Task <CommonResult <SucursalModel> > Sucursal_Crea(SucursalModel sucursalModel)
        {
            CommonResult <SucursalModel> _commonResult = new CommonResult <SucursalModel>();

            try
            {
                using (IDbConnection conexion = new SqlConnection(_Iconexion.GetConexion()))
                {
                    var Parameters = new DynamicParameters();
                    Parameters.Add("@IdSucursal", sucursalModel.IdSucursal, dbType: DbType.Int32, direction: ParameterDirection.Input);
                    Parameters.Add("@CodCliente", sucursalModel.CodCliente, dbType: DbType.String, direction: ParameterDirection.Input, size: 10);
                    Parameters.Add("@NombreInterno", sucursalModel.NombreInterno, dbType: DbType.String, direction: ParameterDirection.Input, size: 200);
                    Parameters.Add("@Direccion", sucursalModel.Direccion, dbType: DbType.String, direction: ParameterDirection.Input, size: 200);
                    Parameters.Add("@Telefono", sucursalModel.Telefono, dbType: DbType.String, direction: ParameterDirection.Input, size: 15);
                    Parameters.Add("@Telefono2", sucursalModel.Telefono2, dbType: DbType.String, direction: ParameterDirection.Input, size: 15);
                    Parameters.Add("@Correo", sucursalModel.Correo, dbType: DbType.String, direction: ParameterDirection.Input, size: 50);
                    Parameters.Add("@IB_Geolocalizacion", sucursalModel.IB_Geolocalizacion, dbType: DbType.Boolean, direction: ParameterDirection.Input);
                    Parameters.Add("@Lng", sucursalModel.Lng, dbType: DbType.String, direction: ParameterDirection.Input, size: 50);
                    Parameters.Add("@Lat", sucursalModel.Lat, dbType: DbType.String, direction: ParameterDirection.Input, size: 50);
                    Parameters.Add("@UsuReg", sucursalModel.UsuReg, dbType: DbType.String, direction: ParameterDirection.Input, size: 100);
                    Parameters.Add("@IB_EsPrinc", sucursalModel.IB_EsPrinc, dbType: DbType.Boolean, direction: ParameterDirection.Input);
                    Parameters.Add("@msj", dbType: DbType.String, direction: ParameterDirection.Output, size: 200);
                    var Result = await conexion.ExecuteScalarAsync("SP_Sucursal_CreaMdf", param : Parameters, commandType : CommandType.StoredProcedure);

                    string PCmsj = Parameters.Get <string>("@msj");
                    if (String.IsNullOrEmpty(PCmsj))
                    {
                        _commonResult.Exito = true;
                        return(_commonResult);
                    }
                    else
                    {
                        _commonResult.Exito    = false;
                        _commonResult.MsjDB    = PCmsj;
                        _commonResult.MsjError = "";
                        return(_commonResult);
                    }
                }
            }
            catch (Exception ex)
            {
                _commonResult.Exito    = false;
                _commonResult.MsjDB    = ex.Message;
                _commonResult.MsjError = ex.Message;
                return(_commonResult);
            }
        }
Пример #3
0
        /// <summary>
        /// Updates a record to the SucursalModel table.
        /// returns True if value saved successfully else false
        /// Throw exception with message value EXISTS if the data is duplicate
        /// </summary>
        public bool Update(SucursalModel aSucursalModel, int ID_user)
        {
            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;

                    command.Parameters.AddWithValue("@pMode", 5);
                    command.Parameters.AddWithValue("@ID_user", ID_user);
                    command.Parameters.AddWithValue("@Id", aSucursalModel.Id);
                    command.Parameters.AddWithValue("@Nombre", aSucursalModel.Nombre);
                    command.Parameters.AddWithValue("@Ubicacion", aSucursalModel.Ubicacion);
                    command.Parameters.AddWithValue("@IdBanco", aSucursalModel.Idbanco);

                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "sp_tSucursal";

                    int afectados = command.ExecuteNonQuery();

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();

                    if (afectados > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #4
0
 public static Sucursal Map(SucursalModel Model)
 {
     return(new Sucursal()
     {
         Direccion = Model.Direccion,
         FechaRegistro = Model.FechaRegistro,
         Id = Model.Id,
         Nombre = Model.Nombre,
         Banco = new Banco
         {
             Id = Model.Banco.Id,
             Direccion = Model.Banco.Direccion,
             FechaRegistro = Model.Banco.FechaRegistro,
             Nombre = Model.Banco.Nombre
         }
     });
 }
Пример #5
0
        //Asignar Sucursales A Dispositivos
        public async Task <dynamic> Actualizar_Sucursal(SucursalModel sucursal)
        {
            HttpClient client = getCliente();
            string     json   = JsonConvert.SerializeObject(sucursal);

            try
            {
                var contenido = new StringContent(json, Encoding.UTF8, "application/json");
                HttpResponseMessage respuesta = await client.PostAsync($"{URL}/Sucursal/update_sucursal", contenido);
            }
            catch (HttpRequestException ex)
            {
                await App.Current.MainPage.DisplayAlert("ERROR", $"{ex.Message}", "OK");

                System.Diagnostics.Debug.WriteLine(ex);
            }
            return("");
        }
        public async Task <ActionResult> Sucursal_Crea([FromBody] SucursalModel sucursalModel)
        {
            sucursalModel.UsuReg = Usuario;
            var data = await _clienteBussines.Sucursal_Crea(sucursalModel);

            if (data.Exito)
            {
                if (sucursalModel.IdSucursal == 0)
                {
                    return(Ok(new { data = "La sucursal fué registrado correctamente." }));
                }
                else
                {
                    return(Ok(new { data = "La sucursal fué editado correctamente." }));
                }
            }
            else
            {
                return(BadRequest(new { data = data.MsjDB }));
            }
        }
Пример #7
0
 private void btCargarSucursalesClick(object sender, RoutedEventArgs e)
 {
     if (cbEditarSucursal.SelectedIndex > -1)
     {
         if (MessageBox.Show($"Editar {cbEditarSucursal.Text}, se perderan los datos actuales del formulario\n\n Desea continuar?", "Editar", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             lsAsuetos.ItemsSource = "";
             SucursalModel suc = sc.getSucursal(cbEditarSucursal.Text);
             tbNombreSucursal.Text       = suc.NombreSucursal ?? "";
             cbDepartamento.SelectedItem = suc.Departamento;
             cbMunicipio.SelectedItem    = suc.Municipio;
             tbDireccion.Text            = suc.Direccion;
             lsAsuetos.ItemsSource       = "";
             List <string> list = new List <string>();
             foreach (var asu in suc.DiasAsueto)
             {
                 list.Add(asu.ToString());
             }
             lsAsuetos.ItemsSource     = list;
             cbSupervisor.SelectedItem = suc.NombreEmpleado;
         }
     }
 }
        public async Task <CommonResult <SucursalModel> > Sucursal_ConsUn(int IdSucursal)
        {
            CommonResult <SucursalModel> _commonResult = new CommonResult <SucursalModel>();

            try
            {
                using (IDbConnection conexion = new SqlConnection(_Iconexion.GetConexion()))
                {
                    var Parameters = new DynamicParameters();
                    Parameters.Add("@IdSucursal", IdSucursal, dbType: DbType.Int32, direction: ParameterDirection.Input);
                    Parameters.Add("@msj", dbType: DbType.String, direction: ParameterDirection.Output, size: 200);
                    SucursalModel Result = await conexion.QueryFirstAsync <SucursalModel>("SP_SucursalConsUn", param : Parameters, commandType : CommandType.StoredProcedure);

                    string PCmsj = Parameters.Get <string>("@msj");
                    if (String.IsNullOrEmpty(PCmsj))
                    {
                        _commonResult.Exito   = true;
                        _commonResult.Entidad = Result;
                        return(_commonResult);
                    }
                    else
                    {
                        _commonResult.Exito    = false;
                        _commonResult.MsjDB    = PCmsj;
                        _commonResult.MsjError = "";
                        return(_commonResult);
                    }
                }
            }
            catch (Exception ex)
            {
                _commonResult.Exito    = false;
                _commonResult.MsjDB    = "";
                _commonResult.MsjError = ex.Message;
                return(_commonResult);
            }
        }
Пример #9
0
 public bool Crear(SucursalModel aSucursal)
 {
     return(ADSucursalManager.Insert(aSucursal));
 }
Пример #10
0
 /// <summary>
 /// Saves a record to the sucursal table.
 /// returns True if value saved successfully else false
 /// Throw exception with message value EXISTS if the data is duplicate
 /// </summary>
 public bool Crear(SucursalModel aSucursal, int id_user)
 {
     return(ADSucursalManager.Insert(aSucursal, id_user));
 }
 public bool Sucursal_Editar(SucursalModel aSucursal, int id_user)
 {
     return(BLSucursal.Editar(aSucursal, id_user));
 }
 public bool Sucursal_Crear(SucursalModel aSucursal, int id_user)
 {
     return(BLSucursal.Crear(aSucursal, id_user));
 }
Пример #13
0
        public IActionResult UpdateOrdenPago([FromBody] SucursalModel sucursal)
        {
            var resul = _SucursalService.UpdateSucursal(SucursalMappers.Map(sucursal));

            return(Ok(resul));
        }
Пример #14
0
 public bool Editar(SucursalModel aSucursal)
 {
     return(ADSucursalManager.Update(aSucursal));
 }
Пример #15
0
 public bool Sucursal_Crear(SucursalModel aSucursal)
 {
     return(BLSucursal.Crear(aSucursal));
 }
Пример #16
0
 public Task <CommonResult <SucursalModel> > Sucursal_Crea(SucursalModel sucursalModel)
 {
     return(_clienteRepository.Sucursal_Crea(sucursalModel));
 }
Пример #17
0
 public bool Sucursal_Editar(SucursalModel aSucursal)
 {
     return(BLSucursal.Editar(aSucursal));
 }
Пример #18
0
 /// <summary>
 /// Updates a record to the sucursal table.
 /// returns True if value saved successfully else false
 /// Throw exception with message value EXISTS if the data is duplicate
 /// </summary>
 public bool Editar(SucursalModel aSucursal, int id_user)
 {
     return(ADSucursalManager.Update(aSucursal, id_user));
 }
Пример #19
0
 public void UpdateCell(SucursalModel Sucursal)
 {
     this.lblNombre.Text    = Sucursal.Sucursal_Descripcion;
     this.lblDomicilio.Text = Sucursal.Sucursal_Domicilio;
     SucursalId             = Sucursal.Sucursal_Id;
 }