public clsTipoColecao CarregarCategoria() { try { clsTipoColecao tipoColecao = new clsTipoColecao(); acessoDadosSqlServer.LimparParametros(); DataTable dataTable = acessoDadosSqlServer.ExecutarConsulta(CommandType.Text, "SELECT * FROM tblTipo"); foreach (DataRow linha in dataTable.Rows) { clsTipo t = new clsTipo(); t.Descricao = Convert.ToString(linha["Descricao"]); t.id = Convert.ToInt32(linha["id"]); tipoColecao.Add(t); } return(tipoColecao); } catch (Exception) { throw; } }
private void btnSalvar_Click(object sender, EventArgs e) { clsItem item = new clsItem(); clsTipo tipo = new clsTipo(); clsItemNegocio itemNegocio = new clsItemNegocio(); item.Descricao = txtDescricaoCadastrar.Text; int idTipo = ((clsTipo)cboCategoriaCadastrar.SelectedItem).id; item.idTipo = idTipo; item.Qtde = Convert.ToInt32(txtQtdeCadastrar.Text); item.PrecoUnit = Convert.ToDouble(txtPrecoCadastrar.Text); string retorno = itemNegocio.Inserir(item); try { int id_Produto = Convert.ToInt32(retorno); MetroFramework.MetroMessageBox.Show(this, "Produto inserido com sucesso. Código: " + id_Produto.ToString(), "INFORMAÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Information); //this.DialogResult = DialogResult.Yes; } catch { MessageBox.Show("Não foi possivel inserir. Detalhe: " + retorno, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); //this.DialogResult = DialogResult.No; } }
public CascadingDropDownNameValue[] getTipo_New(string knownCategoryValues) { clsTipo oCls = new clsTipo(); DataTable dt; StringBuilder strHTML = new StringBuilder(); List <CascadingDropDownNameValue> values = new List <CascadingDropDownNameValue>(); dt = oCls.GetAllTipo(); if (dt == null) { return(values.ToArray()); } else { if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { values.Add(new CascadingDropDownNameValue { name = row[1].ToString(), value = row[0].ToString() }); } return(values.ToArray()); } else { return(values.ToArray()); } } }
private void btnCategoriaSalvar_Click(object sender, EventArgs e) { if (txtNomeCategoriaCadastrar.Text != "") { clsTipo T = new clsTipo(); clsTipoNegocio TN = new clsTipoNegocio(); T.Descricao = txtNomeCategoriaCadastrar.Text; DialogResult resp = MetroFramework.MetroMessageBox.Show(this, "\nCATEGORIA: " + txtNomeCategoriaCadastrar.Text, "CADASTRAR ESSA CATEGORIA ?", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (resp == DialogResult.Yes) { string retorno = TN.CadastrarCategoria(T); MetroFramework.MetroMessageBox.Show(this, "\n\nCATEGORIA CADASTRADA COM SUCESSO" + "\nCOD: " + retorno, "INFORMAÇÃO !", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult resp2 = MetroFramework.MetroMessageBox.Show(this, "DESEJA CONTINUAR ?", "INFORMAÇÃO !", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (resp2 == DialogResult.Yes) { txtNomeCategoriaCadastrar.Clear(); txtNomeCategoriaCadastrar.Focus(); } else { Close(); } } } else { MetroFramework.MetroMessageBox.Show(this, "\nCAMPOS EM BRANCO !\n\nPREENCHA TODOS OS CAMPOS, POR FAVOR !", "INFORMAÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtNomeCategoriaCadastrar.Focus(); } }
public string CadastrarCategoria(clsTipo desc) { try { acessoDadosSqlServer.LimparParametros(); acessoDadosSqlServer.AdicionarParametros("@Descricao", desc.Descricao); string idProduto = acessoDadosSqlServer.ExecutarManipulacao(CommandType.StoredProcedure, "uspCategoriaCadastrar").ToString(); return(idProduto); } catch (Exception exception) { return(exception.Message); } }
public List<clsTipo> ListasTipos() { SqlCommand cmd = new SqlCommand("PA_ListarTipos", cnx); cmd.CommandType = CommandType.StoredProcedure; cnx.Open(); SqlDataReader dr = cmd.ExecuteReader(); List<clsTipo> col = new List<clsTipo>(); while (dr.Read()) { clsTipo obj = new clsTipo(); obj.Codigo = Convert.ToInt32(dr["IdTipo"]); obj.Nombre = dr["Nombre"].ToString(); obj.Estado = Convert.ToBoolean(dr["Estado"]); col.Add(obj); } cnx.Close(); return col; }