Esempio n. 1
0
        private void Delete()
        {
            if (_IDLOTE == -1)
            {
                MessageBox.Show(ConfigMessage.Default.MsgSelecRegistro);
                tabControlMarca.SelectTab(1);
            }
            else
            {
                DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete,
                                                  ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo);

                if (dr == DialogResult.Yes)
                {
                    try
                    {
                        LOTEPP.Delete(_IDLOTE);
                        Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                        Entity = null;
                        GetAllRegistros();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                        MessageBox.Show("Erro Técnico: " + ex.Message);
                    }
                }
            }
        }
Esempio n. 2
0
        private void FrmTipoRegiao_Load(object sender, EventArgs e)
        {
            CreaterCursor Cr = new CreaterCursor();

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

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

            bntDateSelec.Image      = Util.GetAddressImage(11);
            bntDateSelecFabri.Image = Util.GetAddressImage(11);
            btnpdf.Image            = Util.GetAddressImage(17);
            btnExcel.Image          = Util.GetAddressImage(18);
            btnPrint.Image          = Util.GetAddressImage(19);
            btnpdf2.Image           = Util.GetAddressImage(17);
            btnExcel2.Image         = Util.GetAddressImage(18);
            btnPrint2.Image         = Util.GetAddressImage(19);

            GetToolStripButtonCadastro();
            GetAllRegistros();

            if (_IDLOTE != -1)
            {
                Entity = LOTEPP.Read(_IDLOTE);
            }
            else
            {
                Entity = null;
            }

            VerificaAcesso();

            this.Cursor = Cursors.Default;
        }
Esempio n. 3
0
        private static LOTEEntity FillEntityObject(ref FbDataReader DataReader)
        {
            LOTEEntity entity = new LOTEEntity();

            FirebirdGetDbData getData = new FirebirdGetDbData();

            entity.IDLOTE         = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDLOTE"));
            entity.DESCRICAO      = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("DESCRICAO"));
            entity.DATAVALIDADE   = getData.ConvertDBValueToDateTimeNullable(DataReader, DataReader.GetOrdinal("DATAVALIDADE"));
            entity.OBSERVACAO     = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("OBSERVACAO"));
            entity.CODLOTE        = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("CODLOTE"));
            entity.DATAFABRICACAO = getData.ConvertDBValueToDateTimeNullable(DataReader, DataReader.GetOrdinal("DATAFABRICACAO"));

            return(entity);
        }
Esempio n. 4
0
        private void DataGriewDados_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowindex = e.RowIndex;

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

                if (ColumnSelecionada == 0)//Editar
                {
                    CodigoSelect = Convert.ToInt32(LOTEColl[rowindex].IDLOTE);

                    Entity = LOTEPP.Read(CodigoSelect);
                    tabControlMarca.SelectTab(0);
                    txtDescricao.Focus();
                }
                else if (ColumnSelecionada == 1)//Excluir
                {
                    if (Util.Apaga_Registro(this.Name, FrmLogin._IdNivel))
                    {
                        DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete,
                                                          ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo);

                        if (dr == DialogResult.Yes)
                        {
                            try
                            {
                                CodigoSelect = Convert.ToInt32(LOTEColl[rowindex].IDLOTE);
                                //Delete Pedido
                                LOTEPP.Delete(CodigoSelect);
                                GetAllRegistros();

                                Entity = null;
                                Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Erro técnico: " + ex.Message);
                                MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        private void DataGriewDados_KeyDown(object sender, KeyEventArgs e)
        {
            if (LOTEColl.Count > 0)
            {
                //Obter a linha da célula selecionada
                DataGridViewRow linhaAtual = DataGriewDados.CurrentRow;

                //Exibir o índice da linha atual
                int indice       = linhaAtual.Index;
                int CodigoSelect = Convert.ToInt32(LOTEColl[indice].IDLOTE);

                if (e.KeyCode == Keys.Enter)
                {
                    Entity = LOTEPP.Read(CodigoSelect);

                    tabControlMarca.SelectTab(0);
                    txtDescricao.Focus();
                }
                else if (e.KeyCode == Keys.Delete)
                {
                    DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete,
                                                      ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo);

                    if (dr == DialogResult.Yes)
                    {
                        try
                        {
                            LOTEPP.Delete(CodigoSelect);
                            Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue");
                            GetAllRegistros();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show(ConfigMessage.Default.MsgDeleteErro);
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        private void GetDropLote()
        {
            try
            {
                cbLote.DisplayMember = "CODLOTE";
                cbLote.ValueMember   = "IDLOTE";

                LOTEEntity LOTETy = new LOTEEntity();
                LOTETy.CODLOTE = ConfigMessage.Default.MsgDrop;
                LOTETy.IDLOTE  = -1;
                LOTEColl2.Add(LOTETy);

                Phydeaux.Utilities.DynamicComparer <LOTEEntity> comparer = new Phydeaux.Utilities.DynamicComparer <LOTEEntity>(cbLote.DisplayMember);

                LOTEColl2.Sort(comparer.Comparer);
                cbLote.DataSource = LOTEColl2;

                cbLote.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro técnico: " + ex.Message);
            }
        }
Esempio n. 7
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);
            }
        }
Esempio n. 8
0
        public LOTEEntity Read(int IDLOTE)
        {
            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_LOTE", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

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

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

                dbCommand.CommandType = CommandType.StoredProcedure;

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


                reader = dbCommand.ExecuteReader();

                LOTEEntity 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. 9
0
        public int Save(LOTEEntity 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_LOTE", dbCnn);
                    dbCommand.Transaction = ((FbTransaction)(dbTransaction));
                }
                else
                {
                    if (dbCnn == null)
                    {
                        dbCnn = ((FbConnection)GetConnectionDB());
                    }

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

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

                dbCommand.CommandType = CommandType.StoredProcedure;


                if (Entity.IDLOTE != -1)
                {
                    dbCommand.Parameters.AddWithValue("@IDLOTE", Entity.IDLOTE); //PrimaryKey
                }
                else
                {
                    dbCommand.Parameters.AddWithValue("@IDLOTE", DBNull.Value);              //PrimaryKey
                }
                dbCommand.Parameters.AddWithValue("@DESCRICAO", Entity.DESCRICAO);           //Coluna
                dbCommand.Parameters.AddWithValue("@DATAVALIDADE", Entity.DATAVALIDADE);     //Coluna
                dbCommand.Parameters.AddWithValue("@OBSERVACAO", Entity.OBSERVACAO);         //Coluna
                dbCommand.Parameters.AddWithValue("@CODLOTE", Entity.CODLOTE);               //Coluna
                dbCommand.Parameters.AddWithValue("@DATAFABRICACAO", Entity.DATAFABRICACAO); //Coluna



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

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


                //Executando consulta
                dbCommand.ExecuteNonQuery();

                result = int.Parse(dbCommand.Parameters["@IDLOTE"].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);
        }
Esempio n. 10
0
 private void TSBNovo_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlMarca.SelectTab(0);
     txtDescricao.Focus();
 }
Esempio n. 11
0
 private void novoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Entity = null;
     tabControlMarca.SelectTab(0);
     txtDescricao.Focus();
 }