Esempio n. 1
0
        private void DGDadosProduto_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowindex = e.RowIndex;

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

                if (ColumnSelecionada == 0)//Excluir
                {
                    DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete,
                                                      ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo);

                    if (dr == DialogResult.Yes)
                    {
                        try
                        {
                            CodSelect = Convert.ToInt32(LIS_CONTROLEENTREGAColl[rowindex].IDCONTROLEENTREGA);

                            CONTROLEENTREGAP.Delete(CodSelect);
                            ListaProdutoEntrega(_IDPEDIDO);
                            Entity2 = null;

                            Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                        }
                        catch (Exception)
                        {
                            MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validacoes())
                {
                    decimal TotalEntregue = CalcEntregue(Convert.ToInt32(cbProduto.SelectedValue));
                    decimal totalpedido   = Convert.ToDecimal(txtQuantPedido.Text);
                    decimal rest          = totalpedido - TotalEntregue;

                    if (Convert.ToDecimal(txtQuanEntregue.Text) > rest)
                    {
                        string msgErro = "A quantidade de entrega está fora do limite!";
                        MessageBox.Show(msgErro,
                                        ConfigSistema1.Default.NomeEmpresa,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error,
                                        MessageBoxDefaultButton.Button1);

                        errorProvider1.SetError(txtQuanEntregue, msgErro);
                    }
                    else
                    {
                        CONTROLEENTREGAP.Save(Entity2);
                        ListaProdutoEntrega(_IDPEDIDO);
                        Entity2 = null;
                        Util.ExibirMSg(ConfigMessage.Default.MsgSave, "Blue");
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show(ConfigMessage.Default.MsgSaveErro);
            }
        }
Esempio n. 3
0
        private static CONTROLEENTREGAEntity FillEntityObject(ref FbDataReader DataReader)
        {
            CONTROLEENTREGAEntity entity = new CONTROLEENTREGAEntity();

            FirebirdGetDbData getData = new FirebirdGetDbData();

            entity.IDCONTROLEENTREGA = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDCONTROLEENTREGA"));
            entity.IDPEDIDO          = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDPEDIDO"));
            entity.DATAPEDIDO        = getData.ConvertDBValueToDateTimeNullable(DataReader, DataReader.GetOrdinal("DATAPEDIDO"));
            entity.IDFUNCIONARIO     = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDFUNCIONARIO"));
            entity.IDPRODUTO         = getData.ConvertDBValueToInt32Nullable(DataReader, DataReader.GetOrdinal("IDPRODUTO"));
            entity.QUANTPEDIDO       = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("QUANTPEDIDO"));
            entity.QUANTENTREGUE     = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("QUANTENTREGUE"));
            entity.QUANTRESTANTE     = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("QUANTRESTANTE"));
            entity.DATAENTREGA       = getData.ConvertDBValueToDateTimeNullable(DataReader, DataReader.GetOrdinal("DATAENTREGA"));


            return(entity);
        }
Esempio n. 4
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     Entity2 = null;
 }
Esempio n. 5
0
        public CONTROLEENTREGAEntity Read(int IDCONTROLEENTREGA)
        {
            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_CONTROLEENTREGA", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

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

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

                dbCommand.CommandType = CommandType.StoredProcedure;

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


                reader = dbCommand.ExecuteReader();

                CONTROLEENTREGAEntity 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;
            }
        }
Esempio n. 6
0
        public int Save(CONTROLEENTREGAEntity 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_CONTROLEENTREGA", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

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

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

                dbCommand.CommandType = CommandType.StoredProcedure;


                if (Entity.IDCONTROLEENTREGA != -1)
                {
                    dbCommand.Parameters.AddWithValue("@IDCONTROLEENTREGA", Entity.IDCONTROLEENTREGA); //PrimaryKey
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDCONTROLEENTREGA", DBNull.Value); //PrimaryKey
                }
                dbCommand.Parameters.AddWithValue("@IDPEDIDO", Entity.IDPEDIDO);           //Coluna
                dbCommand.Parameters.AddWithValue("@DATAPEDIDO", Entity.DATAPEDIDO);       //Coluna
                dbCommand.Parameters.AddWithValue("@IDFUNCIONARIO", Entity.IDFUNCIONARIO); //Coluna
                dbCommand.Parameters.AddWithValue("@IDPRODUTO", Entity.IDPRODUTO);         //Coluna
                dbCommand.Parameters.AddWithValue("@QUANTPEDIDO", Entity.QUANTPEDIDO);     //Coluna
                dbCommand.Parameters.AddWithValue("@QUANTENTREGUE", Entity.QUANTENTREGUE); //Coluna
                dbCommand.Parameters.AddWithValue("@QUANTRESTANTE", Entity.QUANTRESTANTE); //Coluna
                dbCommand.Parameters.AddWithValue("@DATAENTREGA", Entity.DATAENTREGA);     //Coluna



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

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


                //Executando consulta
                dbCommand.ExecuteNonQuery();

                result = int.Parse(dbCommand.Parameters["@IDCONTROLEENTREGA"].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);
        }