Ejemplo n.º 1
0
        private void btnIncluir_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbxQuantidade.Text))
            {
                MessageBox.Show("Não é possivel incluir KIT sem uma quantidade de Capsulas");
                tbxQuantidade.Focus();
                return;
            }


            KitCapsulas kitCapsulas = new KitCapsulas();

            kitCapsulas.KitSaborID   = Convert.ToInt16(cbxKitSabor.SelectedValue);
            kitCapsulas.KitCapsulaID = Convert.ToInt16(cbxTipoDeCapsulas.SelectedValue);
            kitCapsulas.Quantidade   = Convert.ToInt16(tbxQuantidade.Text);


            string result = kitCapsulas.InserirCapuslaDeCafe(kitCapsulas);

            if (result != "ok")
            {
                MessageBox.Show(result);
            }
            else
            {
                MessageBox.Show("Capsula Cadastrada com sucesso!");
                PreencheDataGrid();
                //LimparTextBoxes();
                //IncluirPesquisarMostraBotoes();
                //DesabilitarCampos();
            };
        }
Ejemplo n.º 2
0
        public string InserirCapuslaDeCafe(KitCapsulas kitCapsula)
        {
            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.\"KitCapsulas\" values(@KitCapulasID,@Quantidade,@KitSaborID)";
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add(new NpgsqlParameter("@KitCapulasID", kitCapsula.KitCapsulaID));
                    cmd.Parameters.Add(new NpgsqlParameter("@Quantidade", kitCapsula.Quantidade));
                    cmd.Parameters.Add(new NpgsqlParameter("@KitSaborID", kitCapsula.KitSaborID));
                    cmd.ExecuteNonQuery();
                    cmd.Dispose();
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                return("ERROR : " + ex.ToString());
            }
            return(result);
        }
Ejemplo n.º 3
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;
        }