Ejemplo n.º 1
0
        private Decimal TotalCupom(int CUPOMELETRONICOID)
        {
            decimal result = 0;

            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("CUPOMELETRONICOID", "System.Int32", "=", CUPOMELETRONICOID.ToString()));
                LIS_PRODUTONFCECollection LIS_PRODUTONFCEColl = new LIS_PRODUTONFCECollection();
                LIS_PRODUTONFCEColl = LIS_PRODUTONFCEP.ReadCollectionByParameter(RowRelatorio);

                foreach (var item in LIS_PRODUTONFCEColl)
                {
                    result += Convert.ToDecimal(item.VALORTOTAL);
                }

                return(result);
            }
            catch (Exception ex)
            {
                return(result);

                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void ExibirDadosCupom(int CUPOMELETRONICOID)
        {
            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("CUPOMELETRONICOID", "System.Int32", "=", CUPOMELETRONICOID.ToString()));
                LIS_PRODUTONFCEColl = LIS_PRODUTONFCEP.ReadCollectionByParameter(RowRelatorio);

                lblNumItens.Text = "Nº de Itens: " + LIS_PRODUTONFCEColl.Count.ToString();

                dtgItensCupom.AutoGenerateColumns = false;
                dtgItensCupom.DataSource          = LIS_PRODUTONFCEColl;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Ejemplo n.º 3
0
        private LIS_PRODUTONFCECollection ProdutoRel(int CUPOMELETRONICOID)
        {
            LIS_PRODUTONFCECollection LIS_PRODUTONFCEColl_2 = new LIS_PRODUTONFCECollection();

            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("CUPOMELETRONICOID", "System.Int32", "=", CUPOMELETRONICOID.ToString()));

                LIS_PRODUTONFCEColl_2 = LIS_PRODUTONFCEP.ReadCollectionByParameter(RowRelatorio);

                return(LIS_PRODUTONFCEColl_2);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro Técnico: " + ex.Message);
                return(LIS_PRODUTONFCEColl_2);
            }
        }
Ejemplo n.º 4
0
        private void AddItemProdutosNFCe(int CUPOMELETRONICOID)
        {
            LIS_PRODUTONFCECollection LIS_PRODUTONFCEColl_iTEM = new LIS_PRODUTONFCECollection();

            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("CUPOMELETRONICOID", "System.Int32", "=", CUPOMELETRONICOID.ToString()));
            LIS_PRODUTONFCEColl_iTEM = LIS_PRODUTONFCEP.ReadCollectionByParameter(RowRelatorio, "PRODUTONFCEID");

            PRODUTONFCEProvider PRODUTONFCEP = new PRODUTONFCEProvider();
            int itemProduto = 1;

            foreach (LIS_PRODUTONFCEEntity item in LIS_PRODUTONFCEColl_iTEM)
            {
                PRODUTONFCEEntity PRODUTONFCETy = new PRODUTONFCEEntity();
                PRODUTONFCETy      = PRODUTONFCEP.Read(Convert.ToInt32(item.PRODUTONFCEID));
                PRODUTONFCETy.ITEM = itemProduto;
                PRODUTONFCEP.Save(PRODUTONFCETy);
                itemProduto++;
            }
        }
Ejemplo n.º 5
0
        private void btnPesquisa_Click(object sender, EventArgs e)
        {
            if (Validacoes())
            {
                try
                {
                    RowRelatorio.Clear();
                    string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text);
                    string DataFinal   = Util.ConverStringDateSearch(msktDataFinal.Text);

                    if (Convert.ToInt32(cbFuncionario.SelectedValue) > 0)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDVENDEDOR", "System.Int32", "=", Convert.ToInt32(cbFuncionario.SelectedValue).ToString()));
                    }

                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", ">=", DataInicial));
                    RowRelatorio.Add(new RowsFiltro("DTEMISSAO", "System.DateTime", "<=", DataFinal));

                    if (Convert.ToInt32(cbProduto.SelectedValue) > 0)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", Convert.ToInt32(cbProduto.SelectedValue).ToString()));
                    }

                    if (Convert.ToInt32(cbStatus.SelectedValue) > 0)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDSTATUSNFCE", "System.Int32", "=", Convert.ToInt32(cbStatus.SelectedValue).ToString()));
                    }



                    LIS_PRODUTONFCEColl = LIS_PRODUTONFCEP.ReadCollectionByParameter(RowRelatorio, "CUPOMELETRONICOID desc");

                    PreencheGrid();
                }
                catch (Exception EX)
                {
                    MessageBox.Show("Erro na pesquisa!");
                    MessageBox.Show("Erro técnico: " + EX.Message);
                }
            }
        }
Ejemplo n.º 6
0
        private static LIS_PRODUTONFCECollection ExecuteReader(ref LIS_PRODUTONFCECollection collection, ref FbDataReader dataReader, FbCommand dbCommand)
        {
            using (dataReader = dbCommand.ExecuteReader())
            {
                collection = new LIS_PRODUTONFCECollection();

                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        collection.Add(FillEntityObject(ref dataReader));
                    }
                }

                if (!(dataReader.IsClosed))
                {
                    dataReader.Close();
                }
                dataReader.Dispose();
            }

            return(collection);
        }
Ejemplo n.º 7
0
        private void PreencheGrid()
        {
            TotalGeralPedido   = 0;
            TotalGeralComissao = 0;

            CreaterCursor Cr = new CreaterCursor();

            this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0);

            DataGriewDados.Rows.Clear();


            foreach (var LIS_CUPOMELETRONICOTy in LIS_CUPOMELETRONICOColl)
            {
                string DataEmissao = string.Empty;
                if (LIS_CUPOMELETRONICOTy.CUPOMELETRONICOID != null)
                {
                    DataEmissao = Convert.ToDateTime(LIS_CUPOMELETRONICOTy.DTEMISSAO).ToString("dd/MM/yyyy");
                }

                string TotalPedido = Convert.ToDecimal(LIS_CUPOMELETRONICOTy.TOTALNOTA).ToString("n2");

                //Comissao Vendedor
                decimal?            Porcetagem    = 0;
                FUNCIONARIOProvider FUNCIONARIOP  = new FUNCIONARIOProvider();
                FUNCIONARIOEntity   FUNCIONARIOtY = new FUNCIONARIOEntity();
                FUNCIONARIOtY = FUNCIONARIOP.Read(Convert.ToInt32(LIS_CUPOMELETRONICOTy.IDVENDEDOR));
                if (FUNCIONARIOtY != null)
                {
                    Porcetagem = FUNCIONARIOtY.COMISSAO;
                }
                // string TotalComissao = Convert.ToDecimal(LIS_PEDIDOTy.VALORCOMISSAO).ToString("n2");
                string TotalComissao = Convert.ToDecimal((LIS_CUPOMELETRONICOTy.TOTALNOTA * Porcetagem) / 100).ToString("n2");


                DataGridViewRow row2 = new DataGridViewRow();
                row2.CreateCells(DataGriewDados, LIS_CUPOMELETRONICOTy.NUMERONFCE, DataEmissao, LIS_CUPOMELETRONICOTy.NOMECLIENTE, LIS_CUPOMELETRONICOTy.NOMESTATUS, LIS_CUPOMELETRONICOTy.NOMEVENDEDOR, TotalPedido, TotalComissao);
                row2.DefaultCellStyle.Font = new Font("Arial", 8);
                DataGriewDados.Rows.Add(row2);

                TotalGeralPedido   += Convert.ToDecimal(TotalPedido);
                TotalGeralComissao += Convert.ToDecimal(TotalComissao);

                if (chkExibirProdutos.Checked)
                {
                    //Produtos
                    DataGridViewRow row3 = new DataGridViewRow();
                    row3.CreateCells(DataGriewDados, "PRODUTOS");
                    row3.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(row3);

                    //Cabeçalho do produto
                    DataGridViewRow row4 = new DataGridViewRow();
                    row4.CreateCells(DataGriewDados, "Quant.", "Total", "Produtos");
                    row4.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(row4);

                    LIS_PRODUTONFCECollection LIS_PRODUTONFCEColl = new LIS_PRODUTONFCECollection();
                    LIS_PRODUTONFCEColl = ProdutoRel(Convert.ToInt32(LIS_CUPOMELETRONICOTy.CUPOMELETRONICOID));
                    foreach (LIS_PRODUTONFCEEntity item in LIS_PRODUTONFCEColl)
                    {
                        DataGridViewRow row5 = new DataGridViewRow();
                        row5.CreateCells(DataGriewDados, Convert.ToDecimal(item.QUANTIDADE).ToString("n2"), Convert.ToDecimal(item.VALORTOTAL).ToString("n2"), item.NOMEPRODUTO);
                        row5.DefaultCellStyle.Font = new Font("Arial", 8);
                        DataGriewDados.Rows.Add(row5);
                    }


                    DataGridViewRow rowLinha_2 = new DataGridViewRow();
                    rowLinha_2.CreateCells(DataGriewDados, "_________", "__________", "________________________________________", "______________________", "_____________________", "__________", "__________", "______________");
                    rowLinha_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
                    DataGriewDados.Rows.Add(rowLinha_2);
                }
            }

            DataGridViewRow rowLinha_1 = new DataGridViewRow();

            rowLinha_1.CreateCells(DataGriewDados, "", "", "", "", "", "", "", "");
            rowLinha_1.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
            DataGriewDados.Rows.Add(rowLinha_1);

            DataGridViewRow rowLinha = new DataGridViewRow();

            rowLinha.CreateCells(DataGriewDados, "", "", "", "", "TOTAL GERAL:", TotalGeralPedido, TotalGeralComissao, "");
            rowLinha.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold);
            DataGriewDados.Rows.Add(rowLinha);

            this.Cursor = Cursors.Default;
        }
Ejemplo n.º 8
0
        public LIS_PRODUTONFCECollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder)
        {
            FbDataReader dataReader              = null;
            string       strSqlCommand           = String.Empty;
            LIS_PRODUTONFCECollection collection = null;

            try
            {
                if (RowsFiltro != null)
                {
                    if (RowsFiltro.Count > 0)
                    {
                        strSqlCommand = "SELECT * FROM LIS_PRODUTONFCE WHERE (";

                        ArrayList _rowsFiltro = new ArrayList();
                        RowsFiltro.ForEach(delegate(RowsFiltro i)
                        {
                            string[] item = { i.Condicao.ToString(), i.Campo.ToString(), i.Tipo.ToString(), i.Operador.ToString(), i.Valor.ToString() };
                            _rowsFiltro.Add(item);
                        });

                        int _count = 1;
                        foreach (string[] item in _rowsFiltro)
                        {
                            strSqlCommand += "(" + item[1] + " " + item[3];
                            switch (item[2])
                            {
                            case ("System.String"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Int16"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Int32"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Int64"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Double"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Decimal"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Float"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " " + item[4] + ")";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Byte"):
                                strSqlCommand += " " + item[4] + ")";
                                break;

                            case ("System.SByte"):
                                strSqlCommand += " " + item[4] + ")";
                                break;

                            case ("System.Char"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.DateTime"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Guid"):
                                if (item[3].ToUpper() != "LIKE")
                                {
                                    strSqlCommand += " '" + item[4] + "')";
                                }
                                else
                                {
                                    strSqlCommand += " '%" + item[4] + "%')";
                                }
                                break;

                            case ("System.Boolean"):
                                strSqlCommand += " " + item[4] + ")";
                                break;
                            }
                            if (_rowsFiltro.Count > 1)
                            {
                                if (_count < _rowsFiltro.Count)
                                {
                                    strSqlCommand += " " + item[0] + " ";
                                }
                                _count++;
                            }
                        }
                        strSqlCommand += ") order by  " + FieldOrder;
                    }
                    else
                    {
                        strSqlCommand = "SELECT * FROM LIS_PRODUTONFCE  order by  " + FieldOrder;
                    }
                }
                else
                {
                    strSqlCommand = "SELECT * FROM LIS_PRODUTONFCE order by  " + FieldOrder;
                }

                //Verificando a existência de um transação aberta
                if (dbTransaction != null)
                {
                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand(strSqlCommand, dbCnn);
                    dbCommand.CommandType = CommandType.Text;
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = new FbConnection(connectionString);
                    }

                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand(strSqlCommand, dbCnn);
                    dbCommand.CommandType = CommandType.Text;
                    dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted);
                }


                collection = ExecuteReader(ref collection, ref dataReader, dbCommand);

                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                }

                if (dbTransaction == null)
                {
                    dbCommand.Transaction.Commit();
                    dbCnn.Close();
                }

                return(collection);
            }
            catch (Exception ex)
            {
                // Deleta reader
                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                }

                if (dbTransaction != null)
                {
                    this.RollbackTransaction();
                }
                else
                {
                    if (dbCommand.Transaction != null)
                    {
                        dbCommand.Transaction.Rollback();
                    }
                    if (dbCnn.State == ConnectionState.Open)
                    {
                        dbCnn.Close();
                    }
                }

                throw ex;
            }
        }
Ejemplo n.º 9
0
        public LIS_PRODUTONFCECollection ReadCollection()
        {
            FbDataReader dataReader = null;

            try
            {
                LIS_PRODUTONFCECollection collection = null;

                //Verificando a existência de um transação aberta
                if (dbTransaction != null)
                {
                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand("SELECT * FROM LIS_PRODUTONFCE", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

                    if (dbCnn.State == ConnectionState.Closed)
                    {
                        dbCnn.Open();
                    }

                    dbCommand             = new FbCommand("SELECT * FROM LIS_PRODUTONFCE", dbCnn);
                    dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted);
                }

                // Tipo do comando de banco Procedure ou SQL
                dbCommand.CommandType = CommandType.Text;

                collection = ExecuteReader(ref collection, ref dataReader, dbCommand);

                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                }

                if (dbTransaction == null)
                {
                    dbCommand.Transaction.Commit();
                    dbCnn.Close();
                }

                return(collection);
            }
            catch (Exception ex)
            {
                // Deleta reader
                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                }

                if (dbTransaction != null)
                {
                    this.RollbackTransaction();
                }
                else
                {
                    if (dbCommand.Transaction != null)
                    {
                        dbCommand.Transaction.Rollback();
                    }
                    if (dbCnn.State == ConnectionState.Open)
                    {
                        dbCnn.Close();
                    }
                }

                throw ex;
            }
        }
Ejemplo n.º 10
0
        private void ExibirDadosCupom(int CUPOMELETRONICOID)
        {
            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("CUPOMELETRONICOID", "System.Int32", "=", CUPOMELETRONICOID.ToString()));
                LIS_PRODUTONFCEColl = LIS_PRODUTONFCEP.ReadCollectionByParameter(RowRelatorio);

                lblNumItens.Text = "Nº de Itens: " + LIS_PRODUTONFCEColl.Count.ToString();

                Entity = CUPOMELETRONICOP.Read(CUPOMELETRONICOID);

                if (LIS_PRODUTONFCEColl.Count > 0)
                {
                    EMPRESAEntity   EMPRESATy = new EMPRESAEntity();
                    EMPRESAProvider EMPRESAP  = new EMPRESAProvider();
                    EMPRESATy = EMPRESAP.Read(1);

                    tbProdutos.Text  = String.Empty;
                    tbProdutos.Text += @"-----------------------------------------------------" + Environment.NewLine;
                    tbProdutos.Text += @"Data: " + DateTime.Now.ToString("dd/MM/yyyy") + Environment.NewLine;
                    tbProdutos.Text += @"Nome: " + EMPRESATy.NOMEFANTASIA + Environment.NewLine;
                    tbProdutos.Text += @"CNPJ: " + String.Format(@"{0:00\.000\.000\/0000\-00}", EMPRESATy.CNPJCPF) + Environment.NewLine;
                    tbProdutos.Text += @"-----------------------------------------------------" + Environment.NewLine;


                    //Dados Do Produto
                    string header    = String.Format("{0,12}{1,8}{2,12}\n", "Item", "Codigo", "Descrição");
                    string subheader = String.Format("{0,12}{1,12}{2,8}\n", "", "Unidade", "Valor");
                    tbProdutos.Text += @"-----------------------------------------------------" + Environment.NewLine;
                    tbProdutos.Text += header + Environment.NewLine;
                    tbProdutos.Text += subheader + Environment.NewLine;
                    int itemProduto = 1;


                    //for (int i = LIS_PRODUTONFCEColl.Count; i > LIS_PRODUTONFCEColl.Count; i--)
                    foreach (LIS_PRODUTONFCEEntity item in LIS_PRODUTONFCEColl)
                    {
                        tbProdutos.Text += Environment.NewLine;
                        tbProdutos.Text += String.Format("{0,6}{1,8}  {2,12}\n", itemProduto.ToString().PadLeft(3, '0'), item.IDPRODUTO.ToString(), item.NOMEPRODUTO);
                        tbProdutos.Text += String.Format("{0,12}{1,12}{2,8}\n", "      ", Convert.ToDecimal(item.QUANTIDADE).ToString("n4") + " x ", Convert.ToDecimal(item.VALORUNITARIO).ToString("n2"));
                        tbProdutos.Text += @"-----------------------------------------------------" + Environment.NewLine;
                        itemProduto++;
                    }

                    // tbProdutos.Select(tbProdutos.Text.Length, 0);
                    this.tbProdutos.Focus();
                    int textLength = tbProdutos.Text.Length;
                    tbProdutos.SelectionStart = textLength;
                    tbProdutos.ScrollToCaret();
                    // tbProdutos.SelectionLength = 0;
                    //
                    //this.tbProdutos.Focus();
                    //this.tbProdutos.SelectionStart = Strings.Len(this.tbProdutos.Text);
                    //this.tbProdutos.ScrollToCaret();
                }
                else
                {
                    MessageBox.Show("Cupom Eletrônico não localizado!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }