Esempio n. 1
0
        public bool Salvar(TipoM tipo)
        {
            try
            {
                string sql = "INSERT INTO Tb_Tipo (Descricao) values (@Descricao)";

                using (var cmd = sqliteConnection.CreateCommand())
                {
                    cmd.CommandText = sql;
                    cmd.Parameters.AddWithValue("@Descricao", tipo.Descricao);
                    cmd.ExecuteNonQuery();
                }
                return(true);
            }
            catch (SqlException)
            {
                throw;
            }
        }
Esempio n. 2
0
        protected void SalvarBt_Click(object sender, EventArgs e)
        {
            TipoM tipo = new TipoM()
            {
                Descricao = DescricaoTxt.Text,
            };

            TipoDB tipoDB = new TipoDB();
            bool   status = tipoDB.Salvar(tipo);

            if (status)
            {
                Label1.Text = "Registro Inserido!";
                LimparComponentes();
                CarregarTabela();
            }
            else
            {
                Label1.Text      = "Erro ao inserir registro";
                Label1.ForeColor = Color.Red;
            }
        }