Exemplo n.º 1
0
        private void FrmConfigPedBalcao_Load(object sender, EventArgs e)
        {
            CreaterCursor Cr = new CreaterCursor();

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

            btnFormPagamento.Image  = Util.GetAddressImage(6);
            btnCadTipo.Image        = Util.GetAddressImage(6);
            btnCadCentroCusto.Image = Util.GetAddressImage(6);
            cadTransportadora.Image = Util.GetAddressImage(6);
            btnCadLocaPagto.Image   = Util.GetAddressImage(6);

            btnSalvar.Image = Util.GetAddressImage(15);
            btnSair.Image   = Util.GetAddressImage(21);

            GetDropFormaPgto();
            GetDropCentroCusto();
            GetDropTipoDuplicata();
            GetTransporte();
            GetDropLocalCobranca();

            rbCodigoProduto.Checked            = true;
            rbPesquisaCodigoBarra.Checked      = BmsSoftware.ConfigPedidoBalcao.Default.FlagPesquisaCodBarra.Trim() == "S" ? true : false;
            rbPesquisaCodigoReferencia.Checked = BmsSoftware.ConfigPedidoBalcao.Default.FlagPesquisaCodReferencia.Trim() == "S" ? true : false;
            chAbreGaveta.Checked = BmsSoftware.ConfigPedidoBalcao.Default.AbreGaveta.Trim() == "S" ? true : false;

            Entity = CONFIGPEDBALCAOP.Read(1);


            this.Cursor = Cursors.Default;
        }
Exemplo n.º 2
0
        private static CONFIGPEDBALCAOEntity FillEntityObject(ref FbDataReader DataReader)
        {
            CONFIGPEDBALCAOEntity entity = new CONFIGPEDBALCAOEntity();

            FirebirdGetDbData getData = new FirebirdGetDbData();

            entity.IDCONFIGPEDBALCAO = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDCONFIGPEDBALCAO"));
            entity.FLAGENTRADACAIXA  = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("FLAGENTRADACAIXA"));
            entity.IDTIPOPAGTO       = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDTIPOPAGTO"));
            entity.IDCENTROCUSTO     = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDCENTROCUSTO"));
            entity.IDFORMAPAGTO      = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDFORMAPAGTO"));
            entity.IDTRANSPORTE      = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDTRANSPORTE"));
            entity.IDLOCALCOBRANCA   = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDLOCALCOBRANCA"));
            entity.TIPOMODELOTICKET  = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("TIPOMODELOTICKET"));


            return(entity);
        }
Exemplo n.º 3
0
        public CONFIGPEDBALCAOEntity Read(int IDCONFIGPEDBALCAO)
        {
            FbDataReader reader = null;

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

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

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

                    dbCommand             = new FbCommand("Rea_CONFIGPEDBALCAO", dbCnn);
                    dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted);
                }

                dbCommand.CommandType = CommandType.StoredProcedure;

                dbCommand.Parameters.AddWithValue("@IDCONFIGPEDBALCAO", IDCONFIGPEDBALCAO);                //PrimaryKey


                reader = dbCommand.ExecuteReader();

                CONFIGPEDBALCAOEntity entity = null;
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        entity = FillEntityObject(ref reader);
                    }
                }

                // Deleta reader
                if (reader != null)
                {
                    reader.Close();
                    reader.Dispose();
                }

                // Fecha conexão
                if (dbTransaction == null)
                {
                    dbCommand.Transaction.Commit();
                    if (dbCnn.State == ConnectionState.Open)
                    {
                        dbCnn.Close();
                    }
                }

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

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

                throw ex;
            }
        }
Exemplo n.º 4
0
        public int Save(CONFIGPEDBALCAOEntity Entity)
        {
            int result = 0;

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

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

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

                    dbCommand             = new FbCommand("Sav_CONFIGPEDBALCAO", dbCnn);
                    dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted);
                }

                dbCommand.CommandType = CommandType.StoredProcedure;

                //PrimaryKey com valor igual a null, indica um novo registro,
                //o valor da chave será fornecido pelo banco. Qualquer outro valor indicará edição do registro.
                if (Entity.IDCONFIGPEDBALCAO == -1)
                {
                    dbCommand.Parameters.AddWithValue("@IDCONFIGPEDBALCAO", DBNull.Value);
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDCONFIGPEDBALCAO", Entity.IDCONFIGPEDBALCAO);
                }

                dbCommand.Parameters.AddWithValue("@FLAGENTRADACAIXA", Entity.FLAGENTRADACAIXA);                         //Coluna

                if (Entity.IDTIPOPAGTO != null)
                {
                    dbCommand.Parameters.AddWithValue("@IDTIPOPAGTO", Entity.IDTIPOPAGTO);                             //ForeignKey
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDTIPOPAGTO", DBNull.Value);                             //ForeignKey 5
                }
                if (Entity.IDCENTROCUSTO != null)
                {
                    dbCommand.Parameters.AddWithValue("@IDCENTROCUSTO", Entity.IDCENTROCUSTO);                             //ForeignKey
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDCENTROCUSTO", DBNull.Value);                             //ForeignKey 5
                }
                if (Entity.IDFORMAPAGTO != null)
                {
                    dbCommand.Parameters.AddWithValue("@IDFORMAPAGTO", Entity.IDFORMAPAGTO);                             //ForeignKey
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDFORMAPAGTO", DBNull.Value);                             //ForeignKey 5
                }
                if (Entity.IDTRANSPORTE != null)
                {
                    dbCommand.Parameters.AddWithValue("@IDTRANSPORTE", Entity.IDTRANSPORTE);                             //ForeignKey
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDTRANSPORTE", DBNull.Value);                             //ForeignKey 5
                }
                if (Entity.IDLOCALCOBRANCA != null)
                {
                    dbCommand.Parameters.AddWithValue("@IDLOCALCOBRANCA", Entity.IDLOCALCOBRANCA);                             //ForeignKey
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDLOCALCOBRANCA", DBNull.Value);                             //ForeignKey 5
                }
                dbCommand.Parameters.AddWithValue("@TIPOMODELOTICKET", Entity.TIPOMODELOTICKET);                     //Coluna



                //Retorno da Procedure
                FbParameter returnValue;
                returnValue = dbCommand.CreateParameter();

                dbCommand.Parameters["@IDCONFIGPEDBALCAO"].Direction = ParameterDirection.InputOutput;


                //Executando consulta
                dbCommand.ExecuteNonQuery();

                result = int.Parse(dbCommand.Parameters["@IDCONFIGPEDBALCAO"].Value.ToString());


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

                throw ex;
            }

            return(result);
        }