public ActionResult Create(CategoriaModelo catMOD, HttpPostedFileBase file) { String fileName = "", pathh = ""; if (file != null && file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); pathh = Path.Combine(Server.MapPath("~/Images/Uploads"), fileName); file.SaveAs(pathh); } try { // TODO: Add insert logic here fileName = "/Images/Uploads" + fileName; CategoriaCEN cen = new CategoriaCEN(); cen.CrearCategoria(catMOD.nombre); return(RedirectToAction("Index")); } catch { return(View()); } }
//Método pesquisa categoria/sub-categoria pelo código public CategoriaModelo buscarCatSubCat(CategoriaModelo modCatSub) { try { AbrirConexao(); comando = new MySqlCommand("select descricao_categoria,tipo_categoria,ativo_categoria from categoria where id_categoria = '" + modCatSub.idCategoria + "'", conexao); dr = comando.ExecuteReader(); while (dr.Read()) { string nomeCatSub = Convert.ToString(dr["descricao_categoria"]); char tipoCatSub = Convert.ToChar(dr["tipo_categoria"]); bool ativoCatSub = Convert.ToBoolean(dr["ativo_categoria"]); modCatSub.nomeCategoria = nomeCatSub; modCatSub.tipoCategoria = tipoCatSub; modCatSub.ativoCategoria = ativoCatSub; } } catch (Exception erro) { throw new Exception("Erro ao pesquisar categoria e/ou sub-categoria, classe DAO!" + erro.Message); } return(modCatSub); }
public void CategoriaLista(CategoriaModelo categoria) { if (categoria == null) { return; } this.categoria = categoria; categoria_nombre_tb.Text = categoria.Nombre; }
public void buscarCatSubPorCodigo(CategoriaModelo modCatSub) { try { daoCatSub.buscarCatSubCat(modCatSub); }catch (Exception erro) { throw new Exception("Erro ao buscar categoria e/ou sub-categoria, classe bll" + erro.Message); } }
public static void EliminarCategoria(Categoria categoria) { try { CategoriaModelo.EliminarCategoria(categoria); } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <Categoria> ObtenerCategorias(bool estado) { try { return(CategoriaModelo.ObtenerCategorias(estado)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void buscarIDCategoriaSubCategoria(CategoriaModelo modCatSub) { try { daoCatSub.buscarUltimoRegistro(modCatSub); } catch (Exception erro) { throw new Exception("Erro ao pesquisar a id da categoria e/ou sub-categoria, classe bll! " + erro.Message); } }
public void excluir(CategoriaModelo modCategoria) { try { daoCatSub.ExcluirCategoria(modCategoria); } catch (Exception erro) { throw new Exception("Erro ao excluir categoria, classe BLL! " + erro.Message); } }
public void atualizar(CategoriaModelo categoria) { try { daoCatSub.atualizar(categoria); } catch (Exception erro) { throw erro; } }
public void salvar(CategoriaModelo categoria) { try { daoCatSub.salvar(categoria); } catch (Exception erro) { throw erro; } }
public ActionResult Edit(String id) { CategoriaModelo cat = null; SessionInitialize(); CategoriaEN catEN = new CategoriaCAD(session).ReadOIDDefault(id); cat = new CategoriaAssembler().ConvertENToModelUI(catEN); SessionClose(); return(View(cat)); }
public HistorialVentasFiltroForm(ISolicitudFiltro solicitante, ReporteFiltroModelo filtro = null) { InitializeComponent(); this.solicitante = solicitante; // Cargar filtro anterior if (filtro != null) { if (filtro.FiltroPorFechas) { if (filtro.FechaInicial != null) { fecha_inicial_dtp.Value = filtro.FechaInicial; } if (filtro.FechaFinal != null) { fecha_final_dtp.Value = filtro.FechaFinal; } } filtrar_por_fechas_groupbox.Enabled = filtro.FiltroPorFechas; habilitar_fechas_checkbox.Checked = filtro.FiltroPorFechas; if (filtro.FiltroPorCliente && filtro.Cliente != null) { cliente = filtro.Cliente; cliente_tb.Text = cliente.NombreCompleto; } filtrar_por_cliente_groupbox.Enabled = filtro.FiltroPorCliente; filtrar_por_cliente_checkbox.Checked = filtro.FiltroPorCliente; if (filtro.FiltroPorProducto && filtro.Producto != null) { producto = filtro.Producto; nombre_producto_tb.Text = filtro.Producto.Nombre; } filtrar_por_producto_groupbox.Enabled = filtro.FiltroPorProducto; filtrar_por_producto_checkbox.Checked = filtro.FiltroPorProducto; if (filtro.FiltroPorCategoria && filtro.Categoria != null) { categoria = filtro.Categoria; categoria_nombre_tb.Text = filtro.Categoria.Nombre; } filtrar_por_categoria_groupbox.Enabled = filtro.FiltroPorCategoria; filtrar_por_categoria_checkbox.Checked = filtro.FiltroPorCategoria; } }
private void button8_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtBusca.Text)) { cm = cc.buscaCategoriaNome(txtBusca.Text); txtCod.Text = cm.Cod.ToString(); txtNome.Text = cm.Nome; txtBusca.Text = ""; } else { MessageBox.Show("Campo de busca vazio", "Rebanho 1.0.0", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void MenuMarcaExcluir_Click(object sender, EventArgs e) { var result = MessageBox.Show("Deseja realmente excluir o registro? ", "Excluir Categoria", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { CategoriaBLL bllCategoria = new CategoriaBLL(); CategoriaModelo modCategoria = new CategoriaModelo(); modCategoria.idCategoria = Convert.ToInt32(textBoxCodigoCategoria.Text); bllCategoria.excluir(modCategoria); botaoClicado = "EXCLUIR"; inativarAtivarCamposBotoes(); } }
//Método excluir categoria public void ExcluirCategoria(CategoriaModelo modCategoria) { try { ConexaoBanco conexao = new ConexaoBanco(); conexao.AbrirConexao(); string comando = "delete from categoria where id_categoria =" + modCategoria.idCategoria; conexao.ExecutarComandoSQL(comando); } catch (Exception ex) { throw new Exception("Erro ao excluir a categoria: " + ex.Message); } }
public static List <Producto> ObtenerProductosPorCategoria(string categoria) { try { if (CategoriaModelo.ObtenerCategoriaPorNombre(categoria) == null) { throw new Exception("Categoria no valida"); } return(ProductoModelo.ObtenerProductosPorCategoria(categoria)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public static Categoria ObtenerCategoriaPorID(int id) { try { if (id <= 0) { throw new Exception("ID no valido"); } return(CategoriaModelo.ObtenerCategoriaPorID(id)); } catch (Exception ex) { throw new Exception(ex.Message); } }
//Método buscar a categoria e/ou sub-categoria atráves do código informado no campo public void buscarCatSubPorCodigo() { CategoriaModelo modCatSub = new CategoriaModelo(); CategoriaBLL bllCatSub = new CategoriaBLL(); try { modCatSub.idCategoria = Convert.ToInt32(textBoxCodigoCategoria.Text); bllCatSub.buscarCatSubPorCodigo(modCatSub); //Váido caso ñ encontro a categoria e/ou sub-categoria informo o usuário if (modCatSub.nomeCategoria == null) { MessageBox.Show("Categoria e/ou Sub-Categoria ñ encontrada!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); radioButtonCategoria.Checked = false; radioButtonSubCategoria.Checked = false; checkBoxCategoriaAtiva.Checked = false; textBoxCodigoCategoria.Clear(); } string nomeCatSub = modCatSub.nomeCategoria; char tipoCatSub = modCatSub.tipoCategoria; bool ativoCatSub = modCatSub.ativoCategoria; textBoxDescricaoCategoria.Text = nomeCatSub; if (Convert.ToString(tipoCatSub) == "C") { radioButtonCategoria.Checked = true; radioButtonSubCategoria.Checked = false; } else { radioButtonCategoria.Checked = false; radioButtonSubCategoria.Checked = true; } if (ativoCatSub == true) { checkBoxCategoriaAtiva.Checked = true; } else { checkBoxCategoriaAtiva.Checked = false; } }catch (Exception erro) { throw new Exception("Erro ao buscar categoria e/ou sub-categoria, frm!" + erro.Message); } }
public static void ModificarCategoria(Categoria categoria) { try { if (string.IsNullOrEmpty(categoria.nombre)) { throw new Exception("Nombre faltante"); } CategoriaModelo.ModificarCategoria(categoria); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void AgregarCategoria() { if (CategoriaEsValida() == false) { nombre_categoria_tb.Clear(); nombre_categoria_tb.Focus(); return; } var categoria = new CategoriaModelo(); categoria.Nombre = nombre_categoria_tb.Text.Trim(); categoriasSeleccionadas.Add(categoria); ActualizarListaCategorias(); nombre_categoria_tb.Clear(); nombre_categoria_tb.Focus(); }
public async Task <IActionResult> PostCategorias(CategoriaModelo categoriaModelo) { try { var categoria = _mapper.Map <Categoria>(categoriaModelo); if (await _repo.AdicionarAsync(categoria)) { var categoriaRetorno = _mapper.Map <CategoriaModelo>(categoria); return(CreatedAtAction("GetCategorias", new { id = categoria.Id }, categoriaRetorno)); } return(BadRequest()); } catch (System.Exception) { return(StatusCode(500, "Houve um erro com o processamento dos dados")); } }
//Método salva a categoria public void salvar(CategoriaModelo categoria) { try { AbrirConexao(); comando = new MySqlCommand("insert into categoria (descricao_categoria,ativo_categoria,tipo_categoria) values (@nomecategoria,@ativo,@tipocategoria)", conexao); comando.Parameters.AddWithValue("@nomecategoria", categoria.nomeCategoria); comando.Parameters.AddWithValue("@ativo", categoria.ativoCategoria); comando.Parameters.AddWithValue("@tipocategoria", categoria.tipoCategoria); comando.ExecuteNonQuery(); } catch (Exception erro) { throw erro; } finally { FecharConexao(); } }
//Método pesquisa o ultimo registro public CategoriaModelo buscarUltimoRegistro(CategoriaModelo modCatSub) { try { AbrirConexao(); comando = new MySqlCommand("select max(id_categoria) as numeroPego from categoria where descricao_categoria = '" + modCatSub.nomeCategoria + "'", conexao); dr = comando.ExecuteReader(); while (dr.Read()) { int idCategoria = Convert.ToInt32(dr["numeroPego"]); modCatSub.idCategoria = idCategoria; } } catch (Exception erro) { throw new Exception("Erro ao pesquisar id da categoria e/ou sub-categoria, classe DAO!" + erro.Message); } return(modCatSub); }
//Método atualizar a categoria public void atualizar(CategoriaModelo categoria) { try { AbrirConexao(); comando = new MySqlCommand("update categoria set descricao_categoria=@nomecategoria,ativo_categoria=@ativo,tipo_categoria=@tipocategoria where id_categoria=@idcategoria", conexao); comando.Parameters.AddWithValue("@nomecategoria", categoria.nomeCategoria); comando.Parameters.AddWithValue("@ativo", categoria.ativoCategoria); comando.Parameters.AddWithValue("@tipocategoria", categoria.tipoCategoria); comando.Parameters.AddWithValue("@idcategoria", categoria.idCategoria); comando.ExecuteNonQuery(); } catch (Exception erro) { throw erro; } finally { FecharConexao(); } }
public ActionResult Create() { CategoriaModelo cat = new CategoriaModelo(); return(View(cat)); }
private void MenuMarcaGravar_Click(object sender, EventArgs e) { CategoriaModelo categoriaModelo = new CategoriaModelo(); salvar(categoriaModelo); }
//Método salvar categoria e/ou sub-categoria private void salvar(CategoriaModelo modCategoria) { if (flag == 0) { CategoriaBLL categoriaBLL = new CategoriaBLL(); if (radioButtonCategoria.Checked == false && radioButtonSubCategoria.Checked == false) { MessageBox.Show("Selecione o tipo!!!", "Categoria/Sub-Categoria", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { modCategoria.nomeCategoria = textBoxDescricaoCategoria.Text; if (checkBoxCategoriaAtiva.Checked) { modCategoria.ativoCategoria = true; } else { modCategoria.ativoCategoria = false; } if (radioButtonCategoria.Checked) { modCategoria.tipoCategoria = 'C'; } else if (radioButtonSubCategoria.Checked) { modCategoria.tipoCategoria = 'S'; } categoriaBLL.salvar(modCategoria); MessageBox.Show("Categoria incluida com sucesso!!!", "Cadastro Categorias", MessageBoxButtons.OK, MessageBoxIcon.None); botaoClicado = "SALVAR"; inativarAtivarCamposBotoes(); //Método chama o ultimo registro categoriaBLL.buscarIDCategoriaSubCategoria(modCategoria); int idReturn = modCategoria.idCategoria; textBoxCodigoCategoria.Text = Convert.ToString(idReturn); } } else if (flag == 1) { CategoriaBLL categoriaBLL = new CategoriaBLL(); if (radioButtonCategoria.Checked == false && radioButtonSubCategoria.Checked == false) { MessageBox.Show("Selecione o tipo!!!", "Categoria/Sub-Categoria", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { modCategoria.nomeCategoria = textBoxDescricaoCategoria.Text; if (checkBoxCategoriaAtiva.Checked) { modCategoria.ativoCategoria = true; } else { modCategoria.ativoCategoria = false; } if (radioButtonCategoria.Checked) { modCategoria.tipoCategoria = 'C'; } else if (radioButtonSubCategoria.Checked) { modCategoria.tipoCategoria = 'S'; } modCategoria.idCategoria = Convert.ToInt32(textBoxCodigoCategoria.Text); categoriaBLL.atualizar(modCategoria); MessageBox.Show("Categoria atualizada com sucesso!!!", "Cadastro Categorias", MessageBoxButtons.OK, MessageBoxIcon.Information); botaoClicado = "SALVAR"; inativarAtivarCamposBotoes(); } } }