Exemple #1
0
        private void GetProdutoLote()
        {
            try
            {
                RowRelatorio.Clear();

                LIS_ESTOQUELOTECollection LIS_ESTOQUELOTEColl_2 = new LIS_ESTOQUELOTECollection();
                LIS_ESTOQUELOTEColl_2 = LIS_ESTOQUELOTEP.ReadCollectionByParameter(RowRelatorio, "DATA");

                ProdutoColl.Clear();
                foreach (var item in LIS_ESTOQUELOTEColl_2)
                {
                    PRODUTOSEntity PRODUTOSTy = new PRODUTOSEntity();
                    PRODUTOSTy.IDPRODUTO   = Convert.ToInt32(item.IDPRODUTO);
                    PRODUTOSTy.NOMEPRODUTO = item.NOMEPRODUTO;
                    ProdutoColl.Add(PRODUTOSTy);
                }

                //Remove Produto Repetido
                PRODUTOSCollection PRODUTOSColl_2 = new PRODUTOSCollection();
                foreach (PRODUTOSEntity item in ProdutoColl)
                {
                    if (PRODUTOSColl_2.Find(delegate(PRODUTOSEntity item2) { return(item2.IDPRODUTO == item.IDPRODUTO); }) == null)
                    {
                        PRODUTOSColl_2.Add(item);
                    }
                }
                ProdutoColl = PRODUTOSColl_2;
                GetDropProduto();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Exemple #2
0
        private void PreencherGrid(string CodLote, int?IdProduto, Decimal SaldoLote)
        {
            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("CODLOTE", "System.String", "=", CodLote.ToString()));
                RowRelatorio.Add(new RowsFiltro("IdProduto", "System.Int32", "=", IdProduto.ToString()));
                RowRelatorio.Add(new RowsFiltro("FLAGTIPO", "System.String", "=", "E"));
                RowRelatorio.Add(new RowsFiltro("FLAGATIVO", "System.String", "=", "S"));

                LIS_ESTOQUELOTECollection LIS_ESTOQUELOTEColl2 = new LIS_ESTOQUELOTECollection();
                LIS_ESTOQUELOTEColl2 = LIS_ESTOQUELOTEP.ReadCollectionByParameter(RowRelatorio, "DATAVALIDADE");

                foreach (var item in LIS_ESTOQUELOTEColl2)
                {
                    string _CodLote      = item.CODLOTE;
                    string _ValidadeLote = Convert.ToDateTime(item.DATAVALIDADE).ToString("dd/MM/yyyy");
                    string _NomeProduto  = item.NOMEPRODUTO;
                    string _CodProduto   = item.IDPRODUTO.ToString();

                    DataGridViewRow row1 = new DataGridViewRow();
                    row1.CreateCells(DataGriewDados, _CodLote, _ValidadeLote, SaldoLote.ToString("n2"), _NomeProduto, _CodProduto);
                    row1.DefaultCellStyle.Font = new Font("Arial", 8);
                    DataGriewDados.Rows.Add(row1);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico : " + ex.Message);
            }
        }
Exemple #3
0
        private void SaldoProdutoLote(int?IdProduto, decimal?quantidadeV, int?IDPRODPEDIDO)
        {
            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", IdProduto.ToString()));
                LIS_ESTOQUELOTECollection LIS_ESTOQUELOTEColl_2 = new LIS_ESTOQUELOTECollection();
                LIS_ESTOQUELOTEColl_2 = LIS_ESTOQUELOTEP.ReadCollectionByParameter(RowRelatorio, "DATAVALIDADE");

                decimal QuantVendida = Convert.ToDecimal(quantidadeV);

                foreach (var item in LIS_ESTOQUELOTEColl_2)
                {
                    decimal SaldoPorlote = 0;
                    SaldoPorlote = ConsultaSaldoLote(item.IDPRODUTO, item.IDLOTE);

                    if (QuantVendida > 0 && SaldoPorlote > 0)
                    {
                        //Salva ESTOQUELOTE
                        ESTOQUELOTEEntity ESTOQUELOTETy = new ESTOQUELOTEEntity();
                        ESTOQUELOTETy.IDESTOQUELOTE = -1;

                        if (QuantVendida > SaldoPorlote)
                        {
                            QuantVendida            -= SaldoPorlote;
                            ESTOQUELOTETy.QUANTIDADE = SaldoPorlote;
                        }
                        else if (QuantVendida <= SaldoPorlote)
                        {
                            ESTOQUELOTETy.QUANTIDADE = QuantVendida;
                            QuantVendida            -= QuantVendida;
                        }

                        ESTOQUELOTETy.IDLOTE     = item.IDLOTE;
                        ESTOQUELOTETy.IDPRODUTO  = Convert.ToInt32(item.IDPRODUTO);
                        ESTOQUELOTETy.NUMERODOC  = "PD" + _IDPEDIDO.ToString().PadLeft(6, '0');
                        ESTOQUELOTETy.DATA       = Convert.ToDateTime(LIS_PRODUTOSPEDIDOColl[0].DTEMISSAO);
                        ESTOQUELOTETy.FLAGTIPO   = "S"; //SAIDA
                        ESTOQUELOTETy.FLAGATIVO  = "S"; //ATIVO SIM
                        ESTOQUELOTETy.OBSERVACAO = "";
                        ESTOQUELOTEP.Save(ESTOQUELOTETy);
                        SalvaInfoProdutoPedido(IDPRODPEDIDO, "Lote:" + item.CODLOTE + " Quant.:" + ESTOQUELOTETy.QUANTIDADE + " ");
                        Util.ExibirMSg(ConfigMessage.Default.MsgSave, "Blue");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ténico: " + ex.Message);
            }
        }
Exemple #4
0
        private void GetAllRegistros()
        {
            try
            {
                LIS_ESTOQUELOTEColl = LIS_ESTOQUELOTEP.ReadCollectionByParameter(null, "DATA DESC");
                DataGriewDados.AutoGenerateColumns = false;

                DataGriewDados.DataSource = LIS_ESTOQUELOTEColl;

                lblTotalPesquisa.Text = LIS_ESTOQUELOTEColl.Count.ToString();
            }
            catch (Exception EX)
            {
                MessageBox.Show("Erro técnico: " + EX.Message);
            }
        }
Exemple #5
0
        private void GetAllRegistros(string NUMERODOC)
        {
            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("NUMERODOC", "System.String", "=", NUMERODOC));
                LIS_ESTOQUELOTEColl = LIS_ESTOQUELOTEP.ReadCollectionByParameter(RowRelatorio, "DATAVALIDADE");

                DataGriewDados.AutoGenerateColumns = false;
                DataGriewDados.DataSource          = LIS_ESTOQUELOTEColl;

                lblTotalPesquisa.Text = LIS_ESTOQUELOTEColl.Count.ToString();
            }
            catch (Exception EX)
            {
                MessageBox.Show("Erro técnico: " + EX.Message);
            }
        }
Exemple #6
0
        private void PesquisaRapida()
        {
            CreaterCursor Cr = new CreaterCursor();

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

            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("NUMERODOC", "System.String", "collate pt_br like", "%" + txtPesquisaRapida.Text.Replace("'", "") + "%", "or"));
                RowRelatorio.Add(new RowsFiltro("CODLOTE", "System.String", "collate pt_br like", "%" + txtPesquisaRapida.Text.Replace("'", "") + "%", "or"));
                RowRelatorio.Add(new RowsFiltro("NOMEPRODUTO", "System.String", "collate pt_br like", "%" + txtPesquisaRapida.Text.Replace("'", "") + "%", "or"));

                if (txtPesquisaRapida.Text.Trim() != string.Empty)
                {
                    LIS_ESTOQUELOTEColl = LIS_ESTOQUELOTEP.ReadCollectionByParameter(RowRelatorio, "DATA DESC");
                    DataGriewDados.AutoGenerateColumns = false;
                    DataGriewDados.DataSource          = LIS_ESTOQUELOTEColl;

                    lblTotalPesquisa.Text = LIS_ESTOQUELOTEColl.Count.ToString();
                }
                else
                {
                    LIS_ESTOQUELOTEColl = LIS_ESTOQUELOTEP.ReadCollectionByParameter(null, "DATA DESC");
                    DataGriewDados.AutoGenerateColumns = false;
                    DataGriewDados.DataSource          = LIS_ESTOQUELOTEColl;

                    lblTotalPesquisa.Text = LIS_ESTOQUELOTEColl.Count.ToString();
                }


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

                MessageBox.Show("Erro técnico: " + ex.Message,
                                ConfigSistema1.Default.NomeEmpresa,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);
            }
        }
Exemple #7
0
        private void HistoricoLote(string CodLote)
        {
            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("CODLOTE", "System.String", "=", CodLote.ToString()));
                LIS_ESTOQUELOTEColl = LIS_ESTOQUELOTEP.ReadCollectionByParameter(RowRelatorio, "DATA DESC");
                DataGriewHistorico.AutoGenerateColumns = false;
                DataGriewHistorico.DataSource          = LIS_ESTOQUELOTEColl;

                label4.Text = "Total da pesquisa: " + LIS_ESTOQUELOTEColl.Count.ToString();

                PaintGrid();
            }
            catch (Exception EX)
            {
                MessageBox.Show("Erro técnico: " + EX.Message);
            }
        }
Exemple #8
0
        private void Pesquisa()
        {
            CreaterCursor Cr = new CreaterCursor();

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

            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("CODLOTE", "System.String", "=", txtNumeroLote.Text));
                RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", cbProduto.SelectedValue.ToString()));
                RowRelatorio.Add(new RowsFiltro("FLAGATIVO", "System.String", "=", "S"));

                LIS_ESTOQUELOTEColl = LIS_ESTOQUELOTEP.ReadCollectionByParameter(RowRelatorio, "DATA");

                //Busca Saldo
                Decimal SaldoLote = SaldoProduto();
                LIS_ESTOQUELOTEEntity LIS_ESTOQUELOTETy = new LIS_ESTOQUELOTEEntity();
                LIS_ESTOQUELOTETy.CODLOTE    = "Saldo: ";
                LIS_ESTOQUELOTETy.QUANTIDADE = SaldoLote;
                LIS_ESTOQUELOTEColl.Add(LIS_ESTOQUELOTETy);

                DataGriewDados.AutoGenerateColumns = false;
                DataGriewDados.DataSource          = LIS_ESTOQUELOTEColl;

                lblTotalPesquisa.Text = LIS_ESTOQUELOTEColl.Count.ToString();

                PaintGrid();

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

                MessageBox.Show("Erro técnico: " + ex.Message,
                                ConfigSistema1.Default.NomeEmpresa,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);
            }
        }
Exemple #9
0
        private void PesquisasLotes()
        {
            CreaterCursor Cr = new CreaterCursor();

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

            try
            {
                //Pesquisa Todos os Estoques de Lote
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("FLAGTIPO", "System.String", "=", "E"));
                RowRelatorio.Add(new RowsFiltro("FLAGATIVO", "System.String", "=", "S"));

                LIS_ESTOQUELOTEColl = LIS_ESTOQUELOTEP.ReadCollectionByParameter(RowRelatorio, "DATAVALIDADE");

                //Limpa Grid
                DataGriewDados.Rows.Clear();
                foreach (var item in LIS_ESTOQUELOTEColl)
                {
                    Decimal SaldoEstoqueLote = SaldoProduto(item.CODLOTE, Convert.ToInt32(item.IDPRODUTO));

                    if (SaldoEstoqueLote > 0)
                    {
                        PreencherGrid(item.CODLOTE, item.IDPRODUTO, SaldoEstoqueLote);
                    }
                }

                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Erro técnico: " + ex.Message,
                                ConfigSistema1.Default.NomeEmpresa,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);
            }
        }
Exemple #10
0
        private decimal SaldoProduto(string CodLote, int CodProduto)
        {
            decimal result = 0;

            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("CODLOTE", "System.String", "=", CodLote.ToString()));
                RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", CodProduto.ToString()));
                RowRelatorio.Add(new RowsFiltro("FLAGATIVO", "System.String", "=", "S"));

                LIS_ESTOQUELOTEColl = LIS_ESTOQUELOTEP.ReadCollectionByParameter(RowRelatorio);

                decimal Entrada = 0;
                decimal Saida   = 0;
                decimal Saldo   = 0;
                foreach (var item in LIS_ESTOQUELOTEColl)
                {
                    if (item.FLAGATIVO == "S" && item.FLAGTIPO == "E")
                    {
                        Entrada += Convert.ToDecimal(item.QUANTIDADE);
                    }
                    else if (item.FLAGATIVO == "S" && item.FLAGTIPO == "S")
                    {
                        Saida += Convert.ToDecimal(item.QUANTIDADE);
                    }
                }

                Saldo  = Entrada - Saida;
                result = Saldo;
                return(result);
            }
            catch (Exception ex)
            {
                return(result);

                MessageBox.Show("Erro técnico : " + ex.Message);
            }
        }
Exemple #11
0
        private static LIS_ESTOQUELOTECollection ExecuteReader(ref LIS_ESTOQUELOTECollection collection, ref FbDataReader dataReader, FbCommand dbCommand)
        {
            using (dataReader = dbCommand.ExecuteReader())
            {
                collection = new LIS_ESTOQUELOTECollection();

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

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

            return(collection);
        }
Exemple #12
0
        private void GetLoteProduto(int CodProduto)
        {
            try
            {
                RowRelatorio.Clear();
                RowRelatorio.Add(new RowsFiltro("IDPRODUTO", "System.Int32", "=", CodProduto.ToString()));

                LIS_ESTOQUELOTECollection LIS_ESTOQUELOTEColl_2 = new LIS_ESTOQUELOTECollection();
                LIS_ESTOQUELOTEColl_2 = LIS_ESTOQUELOTEP.ReadCollectionByParameter(RowRelatorio, "DATAVALIDADE");

                LOTEColl2.Clear();
                foreach (var item in LIS_ESTOQUELOTEColl_2)
                {
                    LOTEEntity LOTETy = new LOTEEntity();
                    LOTETy.IDLOTE  = Convert.ToInt32(item.IDLOTE);
                    LOTETy.CODLOTE = item.CODLOTE;
                    LOTEColl2.Add(LOTETy);
                }

                //Remove Produto Repetido
                LOTECollection LOTEColl3 = new LOTECollection();
                foreach (LOTEEntity item in LOTEColl2)
                {
                    if (LOTEColl3.Find(delegate(LOTEEntity item2) { return(item2.IDLOTE == item.IDLOTE); }) == null)
                    {
                        LOTEColl3.Add(item);
                    }
                }
                LOTEColl2 = LOTEColl3;
                GetDropLote();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Exemple #13
0
        public LIS_ESTOQUELOTECollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder)
        {
            FbDataReader dataReader = null;
            LIS_ESTOQUELOTECollection collection = null;

            string strSqlCommand = String.Empty;

            try
            {
                if (RowsFiltro != null)
                {
                    if (RowsFiltro.Count > 0)
                    {
                        strSqlCommand = "SELECT * FROM LIS_ESTOQUELOTE 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_ESTOQUELOTE  order by  " + FieldOrder;
                    }
                }
                else
                {
                    strSqlCommand = "SELECT * FROM LIS_ESTOQUELOTE  order by " + FieldOrder;
                }

                //Verificando a existência de um transação
                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;
            }
        }