internal Telefone buscarTelefoneDaFilial(Filial filial)
        {
            Telefone telefone = new Telefone();

            SqlCommand command = new SqlCommand();

            command.Connection  = this.conexao;
            command.CommandType = CommandType.Text;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT * FROM telefone ");
            sql.Append("INNER JOIN telefone_filial ON telefone.Id = telefone_filial.id_telefone ");
            sql.Append("WHERE id_filial = @id");
            command.Parameters.AddWithValue("id", filial.Id);

            command.CommandText = sql.ToString();
            SqlDataReader reader = command.ExecuteReader();

            reader.Read();

            telefone.Id     = (Int32)reader["Id"];
            telefone.Numero = (String)reader["numero"];

            return(telefone);
        }
        public async Task <IActionResult> PutFilial(int id, Filial filial)
        {
            if (id != filial.Id)
            {
                return(BadRequest());
            }

            _context.Entry(filial).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FilialExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #3
0
 private void carregar_comboBox(Filial filial)
 {
     if (filial.Fili_ID != 0)
     {
         cb_config_endereco.combox_Cidade(cb_cidade_descricao, cb_cidade_ID, filial);
     }
 }
Exemple #4
0
    public static void Filial_Update(Filial filial)
    {
        int?filialAddressId;

        if (filial.FilialAddress.Id <= 0)
        {
            filialAddressId = filial.FilialAddress.Set();
        }
        else
        {
            if (filial.FilialAddress.IsEmpty())             //Luego del uptade de Filial se borra el registro
            {
                filialAddressId = null;
            }
            else
            {
                filialAddressId = filial.FilialAddress.Id;
            }
        }

        db.ExecuteScalar("spFilialUpdate", filial.Id, filial.TaxpayerId,
                         filial.Birthdate, filial.Birthplace, filial.DocumentType1.Id, filial.DocumentNumber1,
                         filial.DocumentType2.Id, filial.DocumentNumber2, filial.DocumentType3.Id, filial.DocumentNumber3,
                         filialAddressId, filial.Sex.Id, filial.MartialStatus.Id, filial.PdfFile,
                         HttpContext.Current.Session["UserId"]);
        filial.CopyValuesToOrigValues();

        if (filial.FilialAddress.Id > 0)
        {
            filialAddressId = filial.FilialAddress.Set();
        }
    }
Exemple #5
0
        public IActionResult CreateFilial([FromBody] Filial filial)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest());
                }

                var filialJaExistente = _repository.Filial.GetFilialBySiglaENome(filial.sigla, filial.nome);

                if (filialJaExistente != null)
                {
                    var message = "Filial com sigla e nome ja cadastrados!";
                    return(BadRequest(new { message = message }));
                }

                _repository.Filial.CreateFilial(filial);

                return(CreatedAtRoute("FilialById", new { id = filial.id }, filial));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, "Internal server error " + ex.Message));
            }
        }
        public IHttpActionResult PutFilial(int empresaCod, string cidadeNome, Filial filial)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (empresaCod != filial.EmpresaCod || cidadeNome != filial.CidadeNome)
            {
                return(BadRequest());
            }

            db.Entry(filial).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FilialExists(empresaCod, cidadeNome))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #7
0
    private void LoadFilial()
    {
        if (Session["ContribId"] != null && Convert.ToInt32(Session["ContribId"]) > 0)
        {
            Filial filial = DataAccess.Filial_GetByTaxpayerId(Convert.ToInt32(Session["ContribId"]));
            if (filial != null)
            {
                hdnIdFilial.Value         = filial.Id.ToString();
                txtFechaNac.Text          = ((filial.Birthdate.HasValue) ? filial.Birthdate.Value.ToShortDateString() : "");
                txtLugarNac.Text          = filial.Birthplace;
                cboTipoDoc1.SelectedIndex = cboTipoDoc1.Items.IndexOf(cboTipoDoc1.Items.FindByValue(filial.DocumentType1.Id.ToString()));
                cboTipoDoc2.SelectedIndex = cboTipoDoc2.Items.IndexOf(cboTipoDoc2.Items.FindByValue(filial.DocumentType2.Id.ToString()));
                cboTipoDoc3.SelectedIndex = cboTipoDoc3.Items.IndexOf(cboTipoDoc3.Items.FindByValue(filial.DocumentType3.Id.ToString()));
                txtDoc1.Text = filial.DocumentNumber1;
                txtDoc2.Text = filial.DocumentNumber2;
                txtDoc3.Text = filial.DocumentNumber3;

                if (filial.FilialAddress != null && filial.FilialAddress.Id > 0)
                {
                    hdnIdDir.Value    = filial.FilialAddress.Id.ToString();
                    txtDireccion.Text = filial.FilialAddress.StreetAddress;
                    txtCiudad.Text    = filial.FilialAddress.City;
                    txtProvincia.Text = filial.FilialAddress.State;
                    txtCP.Text        = filial.FilialAddress.PostCode;
                    txtPais.Text      = filial.FilialAddress.Country;
                }
                cboSexo.SelectedIndex   = cboSexo.Items.IndexOf(cboSexo.Items.FindByValue(filial.Sex.Id.ToString()));
                cboEstado.SelectedIndex = cboEstado.Items.IndexOf(cboEstado.Items.FindByValue(filial.MartialStatus.Id.ToString()));
            }
        }
    }
Exemple #8
0
        internal List <Filial> buscarFiliaisLike(string filtro)
        {
            List <Filial> filiais = new List <Filial>();

            SqlCommand command = new SqlCommand();

            command.Connection  = this.conexao;
            command.CommandType = CommandType.Text;
            command.CommandText = "SELECT * FROM filial WHERE nome like @filtro";
            command.Parameters.AddWithValue("filtro", "%" + filtro + "%");
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Filial filial = new Filial();
                filial.Id       = (Int32)reader["Id"];
                filial.Nome     = (String)reader["nome"];
                filial.Cnpj     = (String)reader["cnpj"];
                filial.Endereco = (String)reader["endereco"];

                filiais.Add(filial);
            }

            FabricaConexao.CloseConnection(conexao);

            return(filiais);
        }
Exemple #9
0
        internal Filial buscarFilialDoAtendente(Atendente atendente)
        {
            Filial filial = new Filial();


            SqlCommand command = new SqlCommand();

            command.Connection  = this.conexao;
            command.CommandType = CommandType.Text;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT * FROM filial ");
            sql.Append("INNER JOIN atendente_filial ON filial.Id = atendente_filial.id_filial ");
            sql.Append("WHERE id_atendente = @id");
            command.Parameters.AddWithValue("id", atendente.Id);

            command.CommandText = sql.ToString();
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                filial.Id       = (Int32)reader["Id"];
                filial.Nome     = (String)reader["nome"];
                filial.Endereco = (String)reader["endereco"];
                filial.Cnpj     = (String)reader["cnpj"];

                return(filial);
            }

            return(null);
        }
        private String BuscarUnidadeFixo(SimuladoDTO simulado)
        {
            Filial unidadeFixo = null;

            switch ((Constants.TipoSimulado)simulado.TipoId)
            {
            case Constants.TipoSimulado.R3_Pediatria:
                unidadeFixo = _filialRepository.GetFilial((int)Constants.Stores.R3_MEDERI);
                break;

            case Constants.TipoSimulado.R3_Clinica:
                unidadeFixo = _filialRepository.GetFilial((int)Constants.Stores.R3_MEDWRITERS);
                break;

            case Constants.TipoSimulado.R3_Cirurgia:
                unidadeFixo = _filialRepository.GetFilial((int)Constants.Stores.R3_MEDERI);
                break;

            case Constants.TipoSimulado.R4_GO:
                unidadeFixo = _filialRepository.GetFilial((int)Constants.Stores.R3_MEDERI);
                break;
            }

            return(unidadeFixo != null ? unidadeFixo.Nome : null);
        }
Exemple #11
0
        internal List <Filial> buscarFiliaisDaBarbearia(Barbearia barbearia)
        {
            List <Filial> filiais = new List <Filial>();

            SqlCommand command = new SqlCommand();

            command.Connection  = this.conexao;
            command.CommandType = CommandType.Text;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT * FROM filial ");
            sql.Append("INNER JOIN filial_barbearia ON filial.Id = filial_barbearia.id_filial ");
            sql.Append("WHERE filial_barbearia.id_barbearia = @id");
            command.Parameters.AddWithValue("@id", barbearia.Id);

            command.CommandText = sql.ToString();

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Filial filial = new Filial();
                filial.Id       = (Int32)reader["Id"];
                filial.Nome     = (String)reader["nome"];
                filial.Cnpj     = (String)reader["cnpj"];
                filial.Endereco = (String)reader["endereco"];

                filiais.Add(filial);
            }

            FabricaConexao.CloseConnection(conexao);

            return(filiais);
        }
Exemple #12
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Cep,Endereco,Numero,Bairro,Cidade,UF,Telefone")] Filial filial)
        {
            if (id != filial.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(filial);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FilialExists(filial.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(filial));
        }
        private void cbFiliais_SelectedIndexChanged(object sender, EventArgs e)
        {
            Filial           filial     = (Filial)cbFiliais.SelectedValue;
            List <Atendente> atendentes = AtendenteService.BuscarAtendentesDaFilial(filial);

            cbAtendente.DataSource = atendentes;
        }
        private void btnFinalizar_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Deseja finalizar compra?", "Aviso!", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                Barbearia barbearia = (Barbearia)cbBarbearias.SelectedValue;
                Filial    filial    = (Filial)cbFiliais.SelectedValue;
                Atendente atendente = (Atendente)cbAtendente.SelectedValue;
                Cliente   cliente   = (Cliente)cbClientes.SelectedValue;

                this.pedidoAtual.Barbearia  = barbearia;
                this.pedidoAtual.Filial     = filial;
                this.pedidoAtual.Atendente  = atendente;
                this.pedidoAtual.Cliente    = cliente;
                this.pedidoAtual.DataPedido = DateTime.Now;

                try
                {
                    PedidoService.SalvarPedido(this.pedidoAtual);

                    MessageBox.Show("Salvo com sucesso!");
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemple #15
0
        public async Task CreateTransactionAsync(Customer customer, Filial filial, decimal amount, DateTime?date = null)
        {
            var transaction = new Transaction()
            {
                AllAmount     = amount,
                Filial        = filial,
                Customer      = customer,
                DateTime      = date ?? DateTime.Now,
                PartnerName   = filial.Partner.Name,
                CategoryId    = filial.Partner.CategoryId,
                SubcategoryId = filial.Partner.SubcategoryId,
                FilialAddress = filial.Street + ' ' + filial.HouseNumber
            };
            var balance = await _context.CustomersBalances.Where(x => x.PartnerId == filial.PartnerId && x.CustomerId == customer.Id).SingleOrDefaultAsync();

            if (balance == null)
            {
                var newBalance = new CustomersBalance()
                {
                    ResetDate = DateTime.Today,
                    IsPremium = false,
                    Partner   = filial.Partner
                };
                customer.CustomersBalances.Add(newBalance);
            }
            if (balance.IsPremium)
            {
                await CalculatePremiumDiscount(transaction, balance);
            }
            else
            {
                await CalculateStandartDiscount(transaction, balance);
            }
            await _context.Transactions.AddAsync(transaction);
        }
Exemple #16
0
        internal void salvarFilial(Filial filial)
        {
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.Text;
            command.Connection  = this.conexao;
            if (tx != null)
            {
                command.Transaction = tx;
            }

            StringBuilder sql = new StringBuilder();

            sql.Append("INSERT INTO filial(nome, endereco, cnpj)");
            sql.Append("VALUES (@nome, @endereco, @cnpj)");
            sql.Append("SELECT @@identity from filial");
            command.CommandText = sql.ToString();
            command.Parameters.AddWithValue("@nome", filial.Nome);
            command.Parameters.AddWithValue("@endereco", filial.Endereco);
            command.Parameters.AddWithValue("@cnpj", filial.Cnpj);

            decimal id = (decimal)command.ExecuteScalar();

            filial.Id = Convert.ToInt32(id);
        }
        internal Filial BuscarFilialEmail(int Codigo)
        {
            b.getComandoSQL().Parameters.Clear();

            b.getComandoSQL().CommandText = @"select f.fil_codigo, f.fil_razao, f.fil_cnpj, f.fil_stativo, e.end_codigo, e.end_logradouro, e.end_numero, e.end_referencia, e.end_bairro,  e.end_cep,              
                                                e.end_cidade, e.end_estado, p.pes_codigo, p.pes_nome, r.reg_codigo, 
                                                r.reg_descricao, r.reg_stativo, p.pes_email, pr.pes_email as emailReg, pr.pes_nome as gerente
                                              from Filial f 
                                              inner join Endereco e on f.end_codigo = e.end_codigo
                                              inner join Pessoa p on f.pes_codigo = p.pes_codigo
                                              inner join Regional r on f.reg_codigo = r.reg_codigo
                                              inner join Pessoa pr on pr.pes_codigo = r.pes_codigo
                                              where f.fil_stativo = 1 and f.fil_codigo = @codigo;";
            b.getComandoSQL().Parameters.AddWithValue("@codigo", Codigo);

            DataTable dt = b.ExecutaSelect();
            Filial    f  = null;

            if (dt.Rows.Count > 0)
            {
                f = TableToListCompleta(dt).FirstOrDefault();

                f.GetResponsavel().SetEmail(dt.Rows[0]["pes_email"].ToString());
                f.GetRegional().GetPessoa().SetEmail(dt.Rows[0]["emailReg"].ToString());
                f.GetRegional().GetPessoa().SetNome(dt.Rows[0]["gerente"].ToString());
            }

            return(f);
        }
Exemple #18
0
        internal List <Filial> buscarTodasFiliais()
        {
            List <Filial> filiais = new List <Filial>();

            SqlCommand command = new SqlCommand();

            command.Connection  = conexao;
            command.CommandType = CommandType.Text;
            command.CommandText = "SELECT * FROM filial";
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Filial filial = new Filial();
                filial.Id       = (Int32)reader["Id"];
                filial.Cnpj     = (String)reader["cnpj"];
                filial.Nome     = (String)reader["nome"];
                filial.Endereco = (String)reader["endereco"];

                filiais.Add(filial);
            }

            FabricaConexao.CloseConnection(conexao);

            return(filiais);
        }
        public IHttpActionResult PostFilial(Filial filial)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Filial.Add(filial);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (FilialExists(filial.EmpresaCod, filial.CidadeNome))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = filial.EmpresaCod }, new FilialDTO(filial)));
        }
        internal static void AtualizarFilial(Filial filial)
        {
            SqlConnection  conexao = null;
            SqlTransaction tx      = null;

            try
            {
                conexao = FabricaConexao.GetConnection();
                tx      = conexao.BeginTransaction();

                FilialDAO filialDAO = new FilialDAO(conexao, tx);
                filialDAO.atualizarFilial(filial);

                BarbeariaDAO barbeariaDAO = new BarbeariaDAO(conexao, tx);
                barbeariaDAO.atualizarBarbeariaDaFilial(filial);

                TelefoneDAO telefoneDAO = new TelefoneDAO(conexao, tx);
                telefoneDAO.atualizarTelefoneDaFilial(filial);

                tx.Commit();
            }
            catch (Exception ex)
            {
                tx.Rollback();
                throw ex;
            }
            finally
            {
                FabricaConexao.CloseConnection(conexao);
            }
        }
Exemple #21
0
    public static Filial Filial_GetByTaxpayerId(int id)
    {
        Filial  filial = null;
        DataSet ds     = db.ExecuteDataSet("spFilialGetByTaxpayerId", id);

        if (ds.Tables[0].Rows.Count > 0)
        {
            DataRow dr = ds.Tables[0].Rows[0];
            filial            = new Filial();
            filial.Id         = Convert.ToInt32(dr["Id"]);
            filial.TaxpayerId = Convert.ToInt32(dr["TaxpayerId"]);
            if ((dr["Birthdate"] != DBNull.Value))
            {
                filial.Birthdate = (DateTime?)(dr["Birthdate"]);
            }
            filial.Birthplace      = dr["Birthplace"].ToString();
            filial.DocumentType1   = new Code(Convert.ToInt32(dr["DocumentTypeId1"]));
            filial.DocumentNumber1 = dr["DocumentNumber1"].ToString();
            filial.DocumentType2   = new Code(Convert.ToInt32(dr["DocumentTypeId2"]));
            filial.DocumentNumber2 = dr["DocumentNumber2"].ToString();
            filial.DocumentType3   = new Code(Convert.ToInt32(dr["DocumentTypeId3"]));
            filial.DocumentNumber3 = dr["DocumentNumber3"].ToString();
            if (dr["AddressId"] != DBNull.Value)
            {
                filial.FilialAddress = Address_GetById(Convert.ToInt32(dr["AddressId"]));
            }

            filial.Sex           = new Code(Convert.ToInt32(dr["SexId"]));
            filial.MartialStatus = new Code(Convert.ToInt32(dr["MartialStatusId"]));
            filial.PdfFile       = dr["PdfFile"].ToString();

            filial.CopyValuesToOrigValues();
        }
        return(filial);
    }
        public static void SalvarFilial(Filial filial)
        {
            SqlConnection  conexao = null;
            SqlTransaction tx      = null;

            try
            {
                conexao = FabricaConexao.GetConnection();
                tx      = conexao.BeginTransaction();

                FilialDAO filialDAO = new FilialDAO(conexao, tx);
                filialDAO.salvarFilial(filial);
                filialDAO.salvarFilialBarbearia(filial);

                TelefoneDAO telefoneDAO = new TelefoneDAO(conexao, tx);
                telefoneDAO.salvarTelefone(filial.Telefone);
                filialDAO.salvarFilialTelefone(filial);

                tx.Commit();
            }
            catch (Exception ex)
            {
                tx.Rollback();
                throw ex;
            }
            finally
            {
                FabricaConexao.CloseConnection(conexao);
            }
        }
Exemple #23
0
    public static List <Filial> BuscaFilial()
    {
        String        conexao = ConfigurationManager.ConnectionStrings["conexao"].ConnectionString;
        SqlConnection con     = new SqlConnection();

        con.ConnectionString = conexao.ToString();

        SqlCommand cmd = new SqlCommand();


        cmd.CommandText = @"select * from tb_filial";

        List <Filial> retorno = new List <Filial>();

        cmd.Connection = con;
        con.Open();
        SqlDataReader dr = cmd.ExecuteReader();

        while (dr.Read())
        {
            Filial filial = new Filial();
            filial.cod_filial = Convert.ToInt32(dr["cod_filial"]);
            filial.ds_filial  = dr["ds_filial"].ToString();
            retorno.Add(filial);
        }

        dr.Close();
        con.Close();

        return(retorno);
    }
Exemple #24
0
        public ActionResult Update([FromServices] Context context, [FromBody] Filial model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            using (var transaction = context.Database.BeginTransaction())
            {
                try
                {
                    context.Filial.Attach(model);
                    context.Entry(model).State = EntityState.Modified;
                    context.SaveChanges();
                    transaction.Commit();
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    return(BadRequest(e.Message));
                }
            }

            return(Ok(model));
        }
        public async Task <IActionResult> PutFilial([FromRoute] Guid id, [FromBody] Filial filial)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != filial.Id)
            {
                return(BadRequest());
            }

            _context.Entry(filial).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FilialExiste(id))
                {
                    return(NotFound());
                }
                throw;
            }

            return(NoContent());
        }
        public int Gravar(int Codigo, string Razao, string Cnpj, Boolean StAtivo, int Endereco, string EndLogradouro, int EndNumero, string EndReferencia, string EndBairro, string EndCep, string EndCidade, string EndEstado, int Responsavel, int Regional)
        {
            Filial Filial = new Filial(Codigo, Razao, Cnpj, StAtivo, Endereco, EndLogradouro, EndNumero, EndReferencia, EndBairro, EndCep, EndCidade, EndEstado, Responsavel, Regional);
            Filial Valida = new Filial();

            if (Codigo == 0)
            {
                if (Valida.BuscarFilial(Razao) == null)
                {
                    if (Filial.Gravar())
                    {
                        return(10);
                    }
                    else
                    {
                        return(-10);
                    }
                }
                else
                {
                    return(-20);
                }
            }
            else
            {
                if (Filial.Gravar())
                {
                    return(10);
                }
                else
                {
                    return(-10);
                }
            }
        }
        public async Task <ActionResult <Filial> > PostFilial(Filial filial)
        {
            _context.Filiais.Add(filial);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFilial", new { id = filial.Id }, filial));
        }
Exemple #28
0
        public Filial save(Filial filial)
        {
            _context.filiais.Add(filial);
            _context.SaveChanges();

            return(filial);
        }
 private void frm_Roteador_Load(object sender, EventArgs e)
 {
     empresa        = new Empresa();
     filial         = new Filial();
     empresa.Emp_ID = Properties.Settings.Default.EMPRESA_ID;
     cb_config_filial.combox_Carregado_Filial(cb_filial, empresa);
 }
        internal Barbearia buscarBarbeariaDaFilial(Filial filial)
        {
            Barbearia barbearia = new Barbearia();

            SqlCommand command = new SqlCommand();

            command.Connection  = this.conexao;
            command.CommandType = CommandType.Text;

            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT * FROM barbearia ");
            sql.Append("INNER JOIN filial_barbearia ON barbearia.Id = filial_barbearia.id_barbearia ");
            sql.Append("WHERE id_filial = @id");
            command.Parameters.AddWithValue("id", filial.Id);

            command.CommandText = sql.ToString();
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                barbearia.Id   = (Int32)reader["Id"];
                barbearia.Nome = (String)reader["name"];
                barbearia.Cnpj = (String)reader["cnpj"];

                return(barbearia);
            }

            return(null);
        }