Example #1
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbxDescricao.Text))
            {
                MessageBox.Show("Não é possivel incluir um Kit Sabor sem sua descrição!");
                tbxDescricao.Focus();
                return;
            }

            KitSabor kitSabor = new KitSabor();

            kitSabor.Descricao = tbxDescricao.Text;

            string result = kitSabor.InserirKitSabor(kitSabor);

            if (result != "ok")
            {
                MessageBox.Show(result);
            }
            else
            {
                MessageBox.Show("Capsula Cadastrada com sucesso!");
                LimparTextBoxes();
                IncluirPesquisarMostraBotoes();
                DesabilitarCampos();
            };
        }
Example #2
0
        public string InserirKitSabor(KitSabor kitSabor)
        {
            string result = "ok";

            try
            {
                ConnetionPostgres connectionPostgres = new ConnetionPostgres();
                /* Insertion After Validations*/
                using (NpgsqlConnection conn = new NpgsqlConnection(connectionPostgres.ConnString))
                {
                    conn.Open();
                    NpgsqlCommand cmd = new NpgsqlCommand();
                    cmd.Connection  = conn;
                    cmd.CommandText = "Insert into public.\"KitSabor\" values(@Descricao)";
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add(new NpgsqlParameter("@Descricao", kitSabor.Descricao));
                    cmd.ExecuteNonQuery();
                    cmd.Dispose();
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                return("ERROR : " + ex.ToString());
            }
            return(result);
        }
Example #3
0
        private void PreencheCbxKitSabor()
        {
            KitSabor  kitSabor   = new KitSabor();
            DataTable dtKitSabor = kitSabor.ListarKitSabor();

            cbxKitSabor.DataSource    = dtKitSabor;
            cbxKitSabor.DisplayMember = "Descricao";
            cbxKitSabor.ValueMember   = "KitSaborID";
        }
Example #4
0
        public FormKitCapsulas()
        {
            InitializeComponent();

            KitSabor  kitSabor   = new KitSabor();
            DataTable dtKitSabor = kitSabor.ListarKitSabor();

            cbxKitSabor.DataSource    = dtKitSabor;
            cbxKitSabor.DisplayMember = "Descricao";
            cbxKitSabor.ValueMember   = "KitSaborID";

            CapsulasDeCafe capsulas   = new CapsulasDeCafe();
            DataTable      dtCapsulas = capsulas.ListarCapsulas();

            cbxTipoDeCapsulas.DataSource    = dtCapsulas;
            cbxTipoDeCapsulas.DisplayMember = "Descricao";
            cbxTipoDeCapsulas.ValueMember   = "capsulasID";

            KitCapsulas kitCapsulas   = new KitCapsulas();
            DataTable   dtKitCapsulas = kitCapsulas.ListarKitCapsulas();

            dgvKitCapsulas.DataSource = dtKitCapsulas;
        }