Ejemplo n.º 1
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            CAMADAS.BLL.Almoxarifado bllAlmo = new CAMADAS.BLL.Almoxarifado();
            string msg    = "";
            string titMsg = "";

            if (lblID.Text == "-1")
            {
                msg    = "Deseja Inserir novo Item?";
                titMsg = "Inserir";
            }
            else
            {
                msg    = "Deseja Alterar o Item?";
                titMsg = "Atualizar";
            }

            DialogResult resposta = MessageBox.Show(msg, titMsg, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

            if (resposta == DialogResult.Yes)
            {
                CAMADAS.MODEL.Almoxarifado almoxarifado = new CAMADAS.MODEL.Almoxarifado();
                almoxarifado.id           = Convert.ToInt32(lblID.Text);
                almoxarifado.fornecedorID = Convert.ToInt32(txtFornecedor.Text);
                almoxarifado.nome         = txtItem.Text;
                almoxarifado.quantidade   = Convert.ToInt32(txtQuantidade.Text);

                if (lblID.Text == "-1")
                {
                    bllAlmo.Insert(almoxarifado);
                }
                else
                {
                    bllAlmo.Update(almoxarifado);
                }
            }

            limpaControles();
            habilitaControles(false);
            dgvItens.DataSource = bllAlmo.Select();
        }