Esempio n. 1
0
        private void RequisicaoForm_Load(object sender, EventArgs e)
        {
            txtIDSetor.Enabled           = false;
            txtNomeProduto.Enabled       = false;
            txtIDProduto.Enabled         = false;
            txtQuantidadeProduto.Enabled = false;
            txtData.Enabled = false;

            gpbPesquisa.Visible = false;

            CAMADAS.BLL.Setor bllSetor = new CAMADAS.BLL.Setor();
            cbSetor.DisplayMember = "nome";
            cbSetor.ValueMember   = "id";
            cbSetor.DataSource    = bllSetor.Select();

            CAMADAS.BLL.Almoxarifado bllAlmoxarifado = new CAMADAS.BLL.Almoxarifado();
            dgvProdutos.DataSource = "";
            dgvProdutos.DataSource = bllAlmoxarifado.Select();



            CAMADAS.BLL.Requisicao bllRequisicao = new CAMADAS.BLL.Requisicao();
            dgvRequisicoes.DataSource = "";
            dgvRequisicoes.DataSource = bllRequisicao.Select();



            habilitaControles(false);
        }
Esempio n. 2
0
        private void btnRemover_Click(object sender, EventArgs e)
        {
            CAMADAS.BLL.Setor bllSetor = new CAMADAS.BLL.Setor();

            string msg    = "Não há dados selecionado para remover";
            string titBox = "Erro";

            if (lblID.Text != "")
            {
                msg    = "Deseja Remover o Setor: " + txtNome.Text;
                titBox = "Remover";
                DialogResult resposta = MessageBox.Show(msg, titBox, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                if (resposta == DialogResult.Yes)
                {
                    int id = Convert.ToInt32(lblID.Text);
                    bllSetor.Delete(id);
                }
            }
            else
            {
                msg    = "Não há dados selecionado para remover";
                titBox = "Erro";
                MessageBox.Show(msg, titBox, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            limpaControles();
            dgvSetor.DataSource = bllSetor.Select();
        }
Esempio n. 3
0
 private void SetoresForm_Load(object sender, EventArgs e)
 {
     CAMADAS.BLL.Setor bllSetor = new CAMADAS.BLL.Setor();
     dgvSetor.DataSource = "";
     dgvSetor.DataSource = bllSetor.Select();
     habilitaControles(false);
 }
Esempio n. 4
0
        private void btnNovo_Click(object sender, EventArgs e)
        {
            CAMADAS.BLL.Setor bllSetor = new CAMADAS.BLL.Setor();
            cbSetor.DisplayMember = "nome";
            cbSetor.ValueMember   = "id";
            cbSetor.DataSource    = bllSetor.Select();

            habilitaControles(true);
            limpaControles();

            lblID.Text = "-1";
            cbSetor.Focus();
            txtData.Text = DateTime.Now.ToString();
        }
Esempio n. 5
0
        public List <MODEL.Requisicao> SelectByNome(List <MODEL.Almoxarifado> listaAlmoxarifado)
        {
            List <MODEL.Requisicao> lstRequisicao = new List <MODEL.Requisicao>();
            int           id;
            string        sql;
            SqlConnection conexao = new SqlConnection(strCon);

            for (int indice = 0; indice < listaAlmoxarifado.Count; indice++)
            {
                id = listaAlmoxarifado[indice].id;

                // conexao = new SqlConnection(strCon);
                sql = "SELECT * FROM Requisicao WHERE produtoID=@produtoID;";
                SqlCommand cmd = new SqlCommand(sql, conexao);
                cmd.Parameters.AddWithValue("@produtoID", id);

                try {
                    conexao.Open();
                    SqlDataReader dados = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                    while (dados.Read())
                    {
                        MODEL.Requisicao requisicao = new MODEL.Requisicao();

                        requisicao.id         = Convert.ToInt32(dados["id"].ToString());
                        requisicao.setorID    = Convert.ToInt32(dados["setorID"].ToString());
                        requisicao.produtoID  = Convert.ToInt32(dados["produtoID"].ToString());
                        requisicao.produto    = listaAlmoxarifado[indice].nome;
                        requisicao.quantidade = Convert.ToInt32(dados["quantidade"].ToString());
                        requisicao.data       = Convert.ToDateTime(dados["data"].ToString());

                        //recuperar nome Setor
                        BLL.Setor   bllSetor = new CAMADAS.BLL.Setor();
                        MODEL.Setor setor    = bllSetor.SelectByID(requisicao.setorID);
                        requisicao.setor = setor.nome;

                        lstRequisicao.Add(requisicao);
                    }
                }
                catch {
                    Console.WriteLine("Erro listar Banco sql-Rquisição");
                }
            }
            conexao.Close();

            return(lstRequisicao);
        }
Esempio n. 6
0
        public List <MODEL.Requisicao> SelectByID(int id)
        {
            List <MODEL.Requisicao> lstRequisicao = new List <MODEL.Requisicao>();

            SqlConnection conexao = new SqlConnection(strCon);
            string        sql     = "SELECT * FROM Requisicao WHERE id=@id;";
            SqlCommand    cmd     = new SqlCommand(sql, conexao);

            cmd.Parameters.AddWithValue("@id", id);

            try {
                conexao.Open();
                SqlDataReader dados = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                if (dados.Read())
                {
                    MODEL.Requisicao requisicao = new MODEL.Requisicao();

                    requisicao.id         = Convert.ToInt32(dados["id"].ToString());
                    requisicao.setorID    = Convert.ToInt32(dados["setorID"].ToString());
                    requisicao.produtoID  = Convert.ToInt32(dados["produtoID"].ToString());
                    requisicao.quantidade = Convert.ToInt32(dados["quantidade"].ToString());
                    requisicao.data       = Convert.ToDateTime(dados["data"].ToString());

                    //recuperar nome Setor e Produto
                    CAMADAS.BLL.Setor   bllSetor = new CAMADAS.BLL.Setor();
                    CAMADAS.MODEL.Setor setor    = bllSetor.SelectByID(requisicao.setorID);
                    requisicao.setor = setor.nome;

                    BLL.Almoxarifado   bllAlmo      = new BLL.Almoxarifado();
                    MODEL.Almoxarifado almoxarifado = bllAlmo.SelectByID(requisicao.produtoID)[0];
                    requisicao.produto = almoxarifado.nome;

                    lstRequisicao.Add(requisicao);
                }
            }
            catch {
                Console.WriteLine("Erro listar Banco sql-Rquisição");
            }
            finally {
                conexao.Close();
            }
            return(lstRequisicao);
        }
Esempio n. 7
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            CAMADAS.BLL.Setor bllSetor = new CAMADAS.BLL.Setor();
            string            msg      = "";
            string            titMsg   = "";

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

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

            if (resposta == DialogResult.Yes)
            {
                CAMADAS.MODEL.Setor setor = new CAMADAS.MODEL.Setor();
                setor.id   = Convert.ToInt32(lblID.Text);
                setor.nome = txtNome.Text;

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

            limpaControles();
            habilitaControles(false);
            dgvSetor.DataSource = bllSetor.Select();
        }