Beispiel #1
0
        private void PesquisaDuplicatasReceber()
        {
            try
            {
                RowRelatorio.Clear();

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

                if (rbVencimento.Checked)
                {
                    RowRelatorio.Add(new RowsFiltro("DATAVECTO", "System.DateTime", ">=", Util.ConverStringDateSearch(mkDtInicial.Text)));
                    RowRelatorio.Add(new RowsFiltro("DATAVECTO", "System.DateTime", "<=", Util.ConverStringDateSearch(mkdatafinal.Text)));

                    if (rbPaga.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "=", "3"));//3 - Pago
                    }
                    else if (rbVencidasVencer.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "<>", "3"));//3 - Pago
                    }
                }
                else if (rbEmissao.Checked)
                {
                    RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", ">=", Util.ConverStringDateSearch(mkDtInicial.Text)));
                    RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", "<=", Util.ConverStringDateSearch(mkdatafinal.Text)));

                    if (rbPaga.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "=", "3"));//3 - Pago
                    }
                    else if (rbVencidasVencer.Checked)
                    {
                        RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "<>", "3"));//3 - Pago
                    }
                }
                else if (rdPagamento.Checked)
                {
                    RowRelatorio.Add(new RowsFiltro("DATAPAGTO", "System.DateTime", ">=", Util.ConverStringDateSearch(mkDtInicial.Text)));
                    RowRelatorio.Add(new RowsFiltro("DATAPAGTO", "System.DateTime", "<=", Util.ConverStringDateSearch(mkdatafinal.Text)));
                }

                LIS_DUPLICATARECEBERColl = LIS_DUPLICATARECEBERP.ReadCollectionByParameter(RowRelatorio, "DATAPAGTO");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Beispiel #2
0
        private void VerificaExisteDuplicata(string NumeroDuplicata)
        {
            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("NUMERO", "System.String", "like", NumeroDuplicata.ToString()));
                LIS_DUPLICATARECEBERColl = LIS_DUPLICATARECEBERP.ReadCollectionByParameter(RowRelatorio);

                if (LIS_DUPLICATARECEBERColl.Count > 0)
                {
                    LIS_DUPLICATARECEBERColl2.AddRange(LIS_DUPLICATARECEBERColl);
                    PreencheGrid();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Beispiel #3
0
        private void GridDuplicatasCliente(int IDCLIENTE, string numero)
        {
            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("IDCLIENTE", "System.Int32", "=", cbCliente.SelectedValue.ToString(), "and"));
                RowRelatorio.Add(new RowsFiltro("NOTAFISCAL", "System.String", "=", txtDuplicata.Text));

                LIS_DUPLICATARECEBERColl = LIS_DUPLICATARECEBERP.ReadCollectionByParameter(RowRelatorio, "DATAVECTO");
                dataGridDuplFornecedor.AutoGenerateColumns = false;
                dataGridDuplFornecedor.DataSource          = LIS_DUPLICATARECEBERColl;

                lblTotalPesquisa.Text = LIS_DUPLICATARECEBERColl.Count.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Beispiel #4
0
        private void FrmBaixar_Load(object sender, EventArgs e)
        {
            try
            {
                CreaterCursor Cr = new CreaterCursor();
                this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0);

                this.MinimizeBox     = false;
                this.FormBorderStyle = FormBorderStyle.FixedDialog;

                GetDropTipoDuplicata();//
                GetDropCentroCusto();
                GetDropContaCorrente();
                GetDropMoviConta();

                btnCadTipo.Image        = Util.GetAddressImage(6);
                btnAddCentroCusto.Image = Util.GetAddressImage(6);
                btnCadContCorrent.Image = Util.GetAddressImage(6);
                btnNomeMoviment.Image   = Util.GetAddressImage(6);

                RowsFiltroCollection RowRelatorio = new RowsFiltroCollection();
                RowRelatorio.Add(new RowsFiltro("IDCLIENTE", "System.Int32", "=", _idCliente.ToString(), "and"));
                RowRelatorio.Add(new RowsFiltro("VALORDEVEDOR", "System.Decimal", "<>", "0"));
                LIS_DUPLICATARECEBERColl = LIS_DUPLICATARECEBERP.ReadCollectionByParameter(RowRelatorio, "DATAVECTO");
                msktDataPagto.Text       = DateTime.Now.ToString("dd/MM/yyyy");
                SumTotalPesquisada();
                txtValorPago.Focus();

                this.Cursor = Cursors.Default;
            }
            catch (Exception)
            {
                this.Cursor = Cursors.Default;

                MessageBox.Show("Erro ao abrir a duplicata!",
                                ConfigSistema1.Default.NomeEmpresa,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);
            }
        }
Beispiel #5
0
        private static LIS_DUPLICATARECEBERCollection ExecuteReader(ref LIS_DUPLICATARECEBERCollection collection, ref FbDataReader dataReader, FbCommand dbCommand)
        {
            using (dataReader = dbCommand.ExecuteReader())
            {
                collection = new LIS_DUPLICATARECEBERCollection();

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

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

            return(collection);
        }
Beispiel #6
0
        private void PesquisaDuplicatasReceber()
        {
            RowsFiltroCollection RowRelatorio = new RowsFiltroCollection();

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


            if (rbVencimento.Checked)
            {
                RowRelatorio.Add(new RowsFiltro("DATAVECTO", "System.DateTime", ">=", Util.ConverStringDateSearch(mkDtInicial.Text)));
                RowRelatorio.Add(new RowsFiltro("DATAVECTO", "System.DateTime", "<=", Util.ConverStringDateSearch(mkdatafinal.Text)));

                if (rbPaga.Checked)
                {
                    RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "=", "3"));//3 - Pago
                }
                else if (rbVencidasVencer.Checked)
                {
                    RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "<>", "3"));//3 - Pago
                }
                LIS_DUPLICATARECEBERColl = LIS_DUPLICATARECEBERP.ReadCollectionByParameter(RowRelatorio, "DATAVECTO");
            }
            else if (rbEmissao.Checked)
            {
                RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", ">=", Util.ConverStringDateSearch(mkDtInicial.Text)));
                RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", "<=", Util.ConverStringDateSearch(mkdatafinal.Text)));

                if (rbPaga.Checked)
                {
                    RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "=", "3"));//3 - Pago
                }
                else if (rbVencidasVencer.Checked)
                {
                    RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "<>", "3"));//3 - Pago
                }
                LIS_DUPLICATARECEBERColl = LIS_DUPLICATARECEBERP.ReadCollectionByParameter(RowRelatorio, "DATAEMISSAO");
            }
            else if (rdPagamento.Checked)
            {
                RowRelatorio.Add(new RowsFiltro("DATAPAGTO", "System.DateTime", ">=", Util.ConverStringDateSearch(mkDtInicial.Text)));
                RowRelatorio.Add(new RowsFiltro("DATAPAGTO", "System.DateTime", "<=", Util.ConverStringDateSearch(mkdatafinal.Text)));

                LIS_DUPLICATARECEBERColl = LIS_DUPLICATARECEBERP.ReadCollectionByParameter(RowRelatorio, "DATAPAGTO");
            }


            //Colocando somatorio no final da lista
            LIS_DUPLICATARECEBEREntity LIS_DUPLICATARECEBERTy = new LIS_DUPLICATARECEBEREntity();

            LIS_DUPLICATARECEBERTy.VALORDUPLICATA = SumTotalPesquisa("VALORDUPLICATA");
            LIS_DUPLICATARECEBERTy.VALORPAGO      = SumTotalPesquisa("VALORPAGO");

            LIS_DUPLICATARECEBERColl.Add(LIS_DUPLICATARECEBERTy);


            DataGridRelaDupl.AutoGenerateColumns = false;
            DataGridRelaDupl.DataSource          = LIS_DUPLICATARECEBERColl;

            lblTotalreceber.Text = "Total de registros: " + (LIS_DUPLICATARECEBERColl.Count - 1).ToString();
        }
Beispiel #7
0
        public LIS_DUPLICATARECEBERCollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder)
        {
            FbDataReader dataReader    = null;
            string       strSqlCommand = String.Empty;
            LIS_DUPLICATARECEBERCollection collection = null;

            try
            {
                if (RowsFiltro != null)
                {
                    if (RowsFiltro.Count > 0)
                    {
                        strSqlCommand = "SELECT * FROM LIS_DUPLICATARECEBER 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_DUPLICATARECEBER  order by  " + FieldOrder;
                    }
                }
                else
                {
                    strSqlCommand = "SELECT * FROM LIS_DUPLICATARECEBER 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;
            }
        }
Beispiel #8
0
        public LIS_DUPLICATARECEBERCollection ReadCollection()
        {
            FbDataReader dataReader = null;

            try
            {
                LIS_DUPLICATARECEBERCollection 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_DUPLICATARECEBER", 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_DUPLICATARECEBER", 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;
            }
        }
Beispiel #9
0
        private void FrmBaixar_Load(object sender, EventArgs e)
        {
            try
            {
                this.MinimizeBox = false; this.FormBorderStyle = FormBorderStyle.FixedDialog;
                GetDropTipoDuplicata();//
                GetDropCentroCusto();
                btnCadTipo.Image        = Util.GetAddressImage(6);
                btnAddCentroCusto.Image = Util.GetAddressImage(6);
                btnNomeMoviment.Image   = Util.GetAddressImage(6);
                btnCadContCorrent.Image = Util.GetAddressImage(6);
                btnSair.Image           = Util.GetAddressImage(21);

                //Armazena na classe de transporte para efetuar a baixa
                if (_idDuplicata != -1)
                {
                    DUPLICATARECEBERTy = DUPLICATARECEBERP.Read(_idDuplicata);

                    if (DUPLICATARECEBERTy != null && DUPLICATARECEBERTy.IDCENTROCUSTO != null)
                    {
                        cbCentroCusto.SelectedValue = DUPLICATARECEBERTy.IDCENTROCUSTO;
                    }

                    ////Efetua a consulta para exibir dados da duplicata selecionada
                    RowsFiltroCollection RowRelatorio = new RowsFiltroCollection();
                    RowRelatorio.Add(new RowsFiltro("IDDUPLICATARECEBER", "System.Int32", "=", _idDuplicata.ToString()));

                    LIS_DUPLICATARECEBERColl = LIS_DUPLICATARECEBERP.ReadCollectionByParameter(RowRelatorio);
                    if (LIS_DUPLICATARECEBERColl.Count > 0)
                    {
                        txtDuplicatas.Text = LIS_DUPLICATARECEBERColl[0].NUMERO;
                        txtValorPago.Text  = Convert.ToDecimal(LIS_DUPLICATARECEBERColl[0].VALORDEVEDOR).ToString("n2");
                    }
                }
                else
                {
                    decimal totalPago = 0;
                    foreach (var item in LIS_DUPLICATARECEBERColl)
                    {
                        txtDuplicatas.Text += item.NUMERO + " / ";
                        totalPago          += Convert.ToDecimal(item.VALORDEVEDOR);
                        txtValorPago.Text   = totalPago.ToString("n2");

                        if (item.IDCENTROCUSTO != null)
                        {
                            cbCentroCusto.SelectedValue = item.IDCENTROCUSTO;
                        }
                    }

                    txtDuplicatas.Text = txtDuplicatas.Text.Substring(0, txtDuplicatas.Text.Length - 3);
                }

                msktDataPagto.Text = DateTime.Now.ToString("dd/MM/yyyy");

                GetDropContaCorrente();
                GetDropMoviConta();

                if (LIS_DUPLICATARECEBERColl[0].IDSTATUS == 3)
                {
                    MessageBox.Show("Duplicata já baixada!",
                                    ConfigSistema1.Default.NomeEmpresa,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error,
                                    MessageBoxDefaultButton.Button1);
                    this.Close();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Erro ao abrir a duplicata!",
                                ConfigSistema1.Default.NomeEmpresa,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);
            }
        }