Ejemplo n.º 1
0
        private Boolean VerificaProdutoReserva2()
        {
            Boolean result = false;

            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", cbProduto.SelectedValue.ToString()));
            RowRelatorio.Add(new RowsFiltro("IDCLIENTE", "System.Int32", "<>", cbCliente.SelectedValue.ToString()));
            RowRelatorio.Add(new RowsFiltro("DATAENTREGA", "System.DateTime", ">=", Util.ConverStringDateSearch(dateTimePickerRetirada.Text)));
            RowRelatorio.Add(new RowsFiltro("FLAGNOVARESERVA", "System.String", "=", "N"));

            LIS_PRODUTORESERVACollection LIS_PRODUTORESERVAColl2 = new LIS_PRODUTORESERVACollection();

            LIS_PRODUTORESERVAColl2 = LIS_PRODUTORESERVAP.ReadCollectionByParameter(RowRelatorio);

            if (LIS_PRODUTORESERVAColl2.Count > 0)
            {
                MessageBox.Show("O produto: " + cbProduto.Text + ", está reservado exclusivamente até a data de entrega: " + Convert.ToDateTime(LIS_PRODUTORESERVAColl2[0].DATAENTREGA).ToString("dd/MM/yyyy") + " - Controle nº: " + LIS_PRODUTORESERVAColl2[0].IDRESERVA.ToString().PadLeft(6, '0') + "!",
                                ConfigSistema1.Default.NomeEmpresa,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);


                result = true;
            }

            return(result);
        }
Ejemplo n.º 2
0
        private void DataGriewDados_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowindex = e.RowIndex;

            if (LIS_RESERVAColl.Count > 0 && rowindex > -1)
            {
                int ColumnSelecionada = e.ColumnIndex;
                int CodSelect         = -1;

                if (ColumnSelecionada == 0)//Editar
                {
                    CodSelect = Convert.ToInt32(LIS_RESERVAColl[rowindex].IDRESERVA);
                    Entity    = RESERVAP.Read(CodSelect);
                    tabControlMarca.SelectTab(0);
                }
                else if (ColumnSelecionada == 1)//Excluir
                {
                    DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete,
                                                      ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo);

                    if (dr == DialogResult.Yes)
                    {
                        try
                        {
                            CodSelect = Convert.ToInt32(LIS_RESERVAColl[rowindex].IDRESERVA);
                            //Excluir Produto da reserva
                            RowRelatorio.Clear();
                            RowRelatorio.Add(new RowsFiltro("IDRESERVA", "System.Int32", "=", CodSelect.ToString()));
                            LIS_PRODUTORESERVAColl = LIS_PRODUTORESERVAP.ReadCollectionByParameter(RowRelatorio);
                            foreach (LIS_PRODUTORESERVAEntity item in LIS_PRODUTORESERVAColl)
                            {
                                PRODUTORESERVAP.Delete(Convert.ToInt32(item.IDPRODUTORESERVA));
                            }

                            RESERVAP.Delete(CodSelect);
                            Entity = null;
                            btnPesquisa_Click(null, null);
                            Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                            MessageBox.Show("Erro Técnico: " + ex.Message);
                        }
                    }
                }
                else if (ColumnSelecionada == 2)//Imprimir
                {
                    CreaterCursor Cr = new CreaterCursor();
                    this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0);

                    CodSelect = Convert.ToInt32(LIS_RESERVAColl[rowindex].IDRESERVA);
                    Entity    = RESERVAP.Read(CodSelect);
                    reservaDeRoupaToolStripMenuItem_Click(null, null);
                    this.Cursor = Cursors.Default;
                }
            }
        }
Ejemplo n.º 3
0
        private void ListaReservaProduto(int IDRESERVA)
        {
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDRESERVA", "System.Int32", "=", IDRESERVA.ToString()));
            LIS_PRODUTORESERVAColl = LIS_PRODUTORESERVAP.ReadCollectionByParameter(RowRelatorio);

            DGDadosProduto.AutoGenerateColumns = false;
            DGDadosProduto.DataSource          = LIS_PRODUTORESERVAColl;
            lblNumProdutos.Text = "Nº de Produtos: " + LIS_PRODUTORESERVAColl.Count.ToString();

            SomaTotalProduto();
        }
Ejemplo n.º 4
0
        private void btnConsulta_Click(object sender, EventArgs e)
        {
            try
            {
                RowRelatorio.Clear();

                string DataInicial = Util.ConverStringDateSearch(dateTimePickerInicio.Text);
                string DataFinal   = Util.ConverStringDateSearch(dateTimePickerFim.Text);

                if (rbDataRetirada.Checked)
                {
                    RowRelatorio.Clear();
                    RowRelatorio.Add(new RowsFiltro("DATARETIRADA", "System.DateTime", ">=", DataInicial));
                    RowRelatorio.Add(new RowsFiltro("DATARETIRADA", "System.DateTime", "<=", DataFinal));
                }
                else if (rbDataEntrega.Checked)
                {
                    RowRelatorio.Clear();
                    RowRelatorio.Add(new RowsFiltro("DATAENTREGA", "System.DateTime", ">=", DataInicial));
                    RowRelatorio.Add(new RowsFiltro("DATAENTREGA", "System.DateTime", "<=", DataFinal));
                }

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

                LIS_PRODUTORESERVAColl = LIS_PRODUTORESERVAP.ReadCollectionByParameter(RowRelatorio);
                lblNumProdutos.Text    = "Nº de Produtos: " + LIS_PRODUTORESERVAColl.Count.ToString();

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

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

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

            return(collection);
        }
Ejemplo n.º 6
0
        public LIS_PRODUTORESERVACollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder)
        {
            FbDataReader dataReader    = null;
            string       strSqlCommand = String.Empty;
            LIS_PRODUTORESERVACollection collection = null;

            try
            {
                if (RowsFiltro != null)
                {
                    if (RowsFiltro.Count > 0)
                    {
                        strSqlCommand = "SELECT * FROM LIS_PRODUTORESERVA 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_PRODUTORESERVA  order by  " + FieldOrder;
                    }
                }
                else
                {
                    strSqlCommand = "SELECT * FROM LIS_PRODUTORESERVA 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.º 7
0
        public LIS_PRODUTORESERVACollection ReadCollection()
        {
            FbDataReader dataReader = null;

            try
            {
                LIS_PRODUTORESERVACollection 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_PRODUTORESERVA", 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_PRODUTORESERVA", 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.º 8
0
        private void FrmRelaReserva_2_Load(object sender, EventArgs e)
        {
            EMPRESAProvider   EMPRESAP    = new EMPRESAProvider();
            EMPRESACollection EMPRESAColl = new EMPRESACollection();

            EMPRESAColl = EMPRESAP.ReadCollectionByParameter(null);

            //Logomarca
            CONFISISTEMAProvider CONFISISTEMAP  = new CONFISISTEMAProvider();
            CONFISISTEMAEntity   CONFISISTEMAty = CONFISISTEMAP.Read(1);

            if (CONFISISTEMAty.FLAGLOGORELATORIO == "S")
            {
                if (CONFISISTEMAty.IDARQUIVOBINARIO1 != null)
                {
                    ARQUIVOBINARIOProvider   ARQUIVOBINARIOP    = new ARQUIVOBINARIOProvider();
                    ARQUIVOBINARIOCollection ARQUIVOBINARIOColl = new ARQUIVOBINARIOCollection();
                    RowRelatorio.Clear();
                    RowRelatorio.Add(new RowsFiltro("IDARQUIVOBINARIO", "System.Int32", "=", CONFISISTEMAty.IDARQUIVOBINARIO1.ToString()));
                    ARQUIVOBINARIOColl = ARQUIVOBINARIOP.ReadCollectionByParameter(RowRelatorio);
                    this.ARQUIVOBINARIOCollectionBindingSource.DataSource = ARQUIVOBINARIOColl;
                }
            }


            nomeempresa = EMPRESAColl[0].NOMEFANTASIA;

            //Dados do Cliente
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDCLIENTE", "System.Int32", "=", codclienteSelec.ToString()));
            LIS_CLIENTEProvider LIS_CLIENTEP = new LIS_CLIENTEProvider();

            LIS_CLIENTEColl = LIS_CLIENTEP.ReadCollectionByParameter(RowRelatorio);
            string cpfcnpjPar = (LIS_CLIENTEColl[0].CNPJ == "  .   .   /    -" || LIS_CLIENTEColl[0].CNPJ == string.Empty) ? LIS_CLIENTEColl[0].CPF : LIS_CLIENTEColl[0].CNPJ;

            //Dados do Reserva
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDRESERVA", "System.Int32", "=", IDRESERVASELEC.ToString()));
            LIS_RESERVAProvider LIS_RESERVAP = new LIS_RESERVAProvider();

            LIS_RESERVAColl = LIS_RESERVAP.ReadCollectionByParameter(RowRelatorio);

            //Dados do Produto Reserva
            RowRelatorio.Clear();
            RowRelatorio.Add(new RowsFiltro("IDRESERVA", "System.Int32", "=", IDRESERVASELEC.ToString()));
            LIS_PRODUTORESERVAProvider LIS_PRODUTORESERVAP = new LIS_PRODUTORESERVAProvider();

            LIS_PRODUTORESERVAColl = LIS_PRODUTORESERVAP.ReadCollectionByParameter(RowRelatorio);

            Microsoft.Reporting.WinForms.ReportParameter[] p = new Microsoft.Reporting.WinForms.ReportParameter[5];
            p[0] = new Microsoft.Reporting.WinForms.ReportParameter("cpfcnpj", cpfcnpjPar);
            p[1] = new Microsoft.Reporting.WinForms.ReportParameter("controle", controleSelec);
            p[2] = new Microsoft.Reporting.WinForms.ReportParameter("vlpago", vlpagoSelec);
            p[3] = new Microsoft.Reporting.WinForms.ReportParameter("nomeempresa", nomeempresa);
            p[4] = new Microsoft.Reporting.WinForms.ReportParameter("titulo", IDRESERVASELEC.ToString().PadLeft(6, '0'));


            reportViewer1.LocalReport.SetParameters(p);

            this.EMPRESACollectionBindingSource.DataSource            = EMPRESAColl;
            this.LIS_CLIENTECollectionBindingSource.DataSource        = LIS_CLIENTEColl;
            this.LIS_RESERVAEntityBindingSource.DataSource            = LIS_RESERVAColl;
            this.LIS_PRODUTORESERVACollectionBindingSource.DataSource = LIS_PRODUTORESERVAColl;

            this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            this.reportViewer1.ZoomMode = ZoomMode.Percent;
            this.reportViewer1.RefreshReport();
        }