Exemplo n.º 1
0
        private void btnLancar_Click(object sender, EventArgs e)
        {// TODO: incluir possibilidade de lançar mais de uma ruptura de uma vez
            string tipoRuptura, produto, descProd, UM, loja, SQL, obs, chave, qtde;
            int    data, codMot, documento, pacote, tipoPed;
            long   TU, pedido;

            if (cmbCodMotivo.Text == "")
            {
                MessageBox.Show("Campo Código Motivo não pode estar em branco!", "Campo vazio", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                for (int i = 0; i < dgvMotivo.Rows.Count; i++)
                {
                    tipoRuptura = cmbTipoRuptura.Text;
                    data        = Convert.ToInt32(dtpData.Text.Substring(6, 4) + dtpData.Text.Substring(3, 2) + dtpData.Text.Substring(0, 2)); //trasforma a data no padrão do BD ex. 20160815
                    produto     = dgvLancamento.Rows[i].Cells["colProduto"].Value.ToString();
                    descProd    = dgvLancamento.Rows[i].Cells["colDesc"].Value.ToString();
                    qtde        = dgvLancamento.Rows[i].Cells["colQtd2"].Value.ToString().Replace(",", ".");
                    UM          = dgvLancamento.Rows[i].Cells["colUn"].Value.ToString();
                    tipoPed     = Convert.ToInt32(dgvLancamento.Rows[i].Cells["colDenominacao"].Value.ToString().Substring(0, 3));
                    codMot      = Convert.ToInt32(cmbCodMotivo.Text.ToString());
                    documento   = Convert.ToInt32(dgvLancamento.Rows[i].Cells["colNumDoc"].Value);
                    TU          = Convert.ToInt64(dgvLancamento.Rows[i].Cells["colTransportUT"].Value);
                    pacote      = Convert.ToInt32(dgvLancamento.Rows[i].Cells["colPacote"].Value);
                    pedido      = Convert.ToInt64(dgvLancamento.Rows[i].Cells["colPedido"].Value);
                    loja        = dgvLancamento.Rows[i].Cells["colReceberMercadoria"].Value.ToString();
                    obs         = txtObs.Text.ToString();
                    chave       = pedido.ToString() + produto + documento;

                    liteBd.AbrirConexao();

                    SQL = "INSERT INTO ruptura_pk (chave, data, tipo_ruptura, produto, descprod, quantidade, um, tipo_Ped, Cod_Mot, Documento, TU, Pacote, Pedido, Loja, Obs) " +
                          "VALUES('" + chave + "', " + data + ", '" + tipoRuptura + "', '" + produto + "', '" + descProd + "', " + qtde + ", '" + UM + "'," + tipoPed + ", " + codMot + ", " +
                          documento + ", " + TU + ", " + pacote + ", " + pedido + ", '" + loja + "', '" + obs + "')";

                    liteBd.InsertDeleteUpdate(SQL);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Os campos PRODUTO, DESCRIÇÃO, UM, DENOMINAÇÃO, RECEBEDOR MERCADORIA, QUANTIDADE, NUM. DOC, TRANSPORTADORA UT, PACOTE E PEDIDO não podem estar em branco ou com valores não correspondentes. Por favor verifique!" +
                                "\n\n Informação Técnica: " + ex.Message,
                                "Falha no lançamento!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //System.Threading.Thread.Sleep(1000);
            CarregaDGVRuptura();
            liteBd.FecharConexao();
            firebase.AtualizaRupturaPK();
        }
Exemplo n.º 2
0
        private void btnLancar_Click(object sender, EventArgs e)
        {
            int data = func.ConvertDataParaBD(dtpData.Text);

            try
            {
                liteBd.AbrirConexao();
                liteBd.InsertDeleteUpdate("INSERT INTO Faturamento (data, linhas, valor) " +
                                          "VALUES (" + data + ", " + txtLinhas.Text + "," + txtValor.Text.Replace(".", "").Replace(",", ".").Replace("R$ ", "") + ")");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Esta data já foi lançada ou os caracteres digitados são inválidos, verifique! \n\n " + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            liteBd.FecharConexao();
            CarregaDGV();
            firebase.AtualizaRupturaPK();
        }