private void Delete() { if (_IDESTOQUELOTE == -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 { ESTOQUELOTEP.Delete(_IDESTOQUELOTE); Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue"); Entity = null; GetAllRegistros(); } catch (Exception ex) { MessageBox.Show(ConfigMessage.Default.MsgDeleteErro); MessageBox.Show("Erro Técnico: " + ex.Message); } } } }
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); } }
private void FrmTipoRegiao_Load(object sender, EventArgs e) { tabControlMarca.SelectTab(1); CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); this.MinimizeBox = false; this.FormBorderStyle = FormBorderStyle.FixedDialog; bntDateSelec.Image = Util.GetAddressImage(11); btnpdf.Image = Util.GetAddressImage(17); btnExcel.Image = Util.GetAddressImage(18); btnPrint.Image = Util.GetAddressImage(19); btnCadProdutos.Image = Util.GetAddressImage(6); btnLote.Image = Util.GetAddressImage(6); GetToolStripButtonCadastro(); GetAllRegistros(); GetDropProduto(); if (_IDESTOQUELOTE != -1) { Entity = ESTOQUELOTEP.Read(_IDESTOQUELOTE); } else { Entity = null; } if (_NumeroDoc != string.Empty) { txtPesquisaRapida.Text = _NumeroDoc; PesquisaRapida(); tabControlMarca.SelectTab(1); tabControlMarca.SelectTab(0); tabControlMarca.SelectTab(1); } else { tabControlMarca.SelectTab(0); } VerificaAcesso(); this.Cursor = Cursors.Default; }
private void DataGriewDados_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int rowindex = e.RowIndex; if (LIS_ESTOQUELOTEColl.Count > 0 && rowindex > -1) { int ColumnSelecionada = e.ColumnIndex; int CodigoSelect = -1; if (ColumnSelecionada == 0)//Editar { CodigoSelect = Convert.ToInt32(LIS_ESTOQUELOTEColl[rowindex].IDESTOQUELOTE); Entity = ESTOQUELOTEP.Read(CodigoSelect); tabControlMarca.SelectTab(0); txtNotaFiscal.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(LIS_ESTOQUELOTEColl[rowindex].IDESTOQUELOTE); //Delete Pedido ESTOQUELOTEP.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); } } } } } }
private static ESTOQUELOTEEntity FillEntityObject(ref FbDataReader DataReader) { ESTOQUELOTEEntity entity = new ESTOQUELOTEEntity(); FirebirdGetDbData getData = new FirebirdGetDbData(); entity.IDESTOQUELOTE = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDESTOQUELOTE")); entity.QUANTIDADE = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("QUANTIDADE")); entity.IDLOTE = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDLOTE")); entity.IDPRODUTO = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("IDPRODUTO")); entity.NUMERODOC = getData.ConvertDBValueToString(DataReader, DataReader.GetOrdinal("NUMERODOC")); entity.DATA = getData.ConvertDBValueToDateTimeNullable(DataReader, DataReader.GetOrdinal("DATA")); entity.FLAGTIPO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("FLAGTIPO")); entity.FLAGATIVO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("FLAGATIVO")); entity.FLAGATIVO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("FLAGATIVO")); entity.OBSERVACAO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("OBSERVACAO")); return(entity); }
private void DataGriewDados_KeyDown(object sender, KeyEventArgs e) { if (LIS_ESTOQUELOTEColl.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(LIS_ESTOQUELOTEColl[indice].IDESTOQUELOTE); if (e.KeyCode == Keys.Enter) { Entity = ESTOQUELOTEP.Read(CodigoSelect); tabControlMarca.SelectTab(0); txtNotaFiscal.Focus(); } else if (e.KeyCode == Keys.Delete) { DialogResult dr = MessageBox.Show(ConfigMessage.Default.MsgDelete, ConfigSistema1.Default.NameSytem, MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { try { ESTOQUELOTEP.Delete(CodigoSelect); Util.ExibirMSg(ConfigMessage.Default.MsgDelete2, "Blue"); GetAllRegistros(); } catch (Exception) { MessageBox.Show(ConfigMessage.Default.MsgDeleteErro); } } } } }
private void TSBNovo_Click(object sender, EventArgs e) { Entity = null; tabControlMarca.SelectTab(0); txtNotaFiscal.Focus(); }
private void novoToolStripMenuItem_Click(object sender, EventArgs e) { Entity = null; tabControlMarca.SelectTab(0); txtNotaFiscal.Focus(); }
public ESTOQUELOTEEntity Read(int IDESTOQUELOTE) { 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_ESTOQUELOTE", dbCnn); dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = ((FbConnection)GetConnectionDB()); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Rea_ESTOQUELOTE", dbCnn); dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.Parameters.AddWithValue("@IDESTOQUELOTE", IDESTOQUELOTE); //PrimaryKey reader = dbCommand.ExecuteReader(); ESTOQUELOTEEntity 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; } }
public int Save(ESTOQUELOTEEntity 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_ESTOQUELOTE", dbCnn); dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = ((FbConnection)GetConnectionDB()); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Sav_ESTOQUELOTE", 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.IDESTOQUELOTE == -1) { dbCommand.Parameters.AddWithValue("@IDESTOQUELOTE", DBNull.Value); } else { dbCommand.Parameters.AddWithValue("@IDESTOQUELOTE", Entity.IDESTOQUELOTE); } dbCommand.Parameters.AddWithValue("@QUANTIDADE", Entity.QUANTIDADE); //Coluna dbCommand.Parameters.AddWithValue("@IDLOTE", Entity.IDLOTE); //Coluna dbCommand.Parameters.AddWithValue("@IDPRODUTO", Entity.IDPRODUTO); //Coluna dbCommand.Parameters.AddWithValue("@NUMERODOC", Entity.NUMERODOC); //Coluna dbCommand.Parameters.AddWithValue("@DATA", Entity.DATA); //Coluna dbCommand.Parameters.AddWithValue("@FLAGTIPO", Entity.FLAGTIPO); //Coluna dbCommand.Parameters.AddWithValue("@FLAGATIVO", Entity.FLAGATIVO); //Coluna dbCommand.Parameters.AddWithValue("@OBSERVACAO", Entity.OBSERVACAO); //Coluna //Retorno da Procedure FbParameter returnValue; returnValue = dbCommand.CreateParameter(); dbCommand.Parameters["@IDESTOQUELOTE"].Direction = ParameterDirection.InputOutput; //Executando consulta dbCommand.ExecuteNonQuery(); result = int.Parse(dbCommand.Parameters["@IDESTOQUELOTE"].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); }