private void AlterarItem_Load(object sender, EventArgs e) { //Lista depositos cbDeposito.DisplayMember = "TextoExibicao"; cbDeposito.ValueMember = "IdDeposito"; IList <IDepositoEntity> lstDepositos = DepositoDao.RetornarDepositos(); foreach (IDepositoEntity deposito in lstDepositos) { cbDeposito.Items.Add(deposito); } //Lista tipo itens cbTipoItem.DisplayMember = "TextoExibicao"; cbTipoItem.ValueMember = "IdTipoItem"; IList <ITipoItemEntity> lstTipoItens = TipoItemDao.RetornarTipoItem(); foreach (ITipoItemEntity tipoitem in lstTipoItens) { cbTipoItem.Items.Add(tipoitem); } //Preenche todos os campos IList <IItemEntity> itens = ItemDao.ConsultarById(this.CodigoItem); foreach (IItemEntity item in itens) { txtNomeItem.Text = item.Nome.ToString(); txtDescricaoItem.Text = item.DescricaoItem.ToString(); cbTipoItem.Text = item.TipoItem.TextoExibicao.ToString(); cbDeposito.Text = item.deposito.TextoExibicao.ToString(); } }
private void btnConsultarDeposito_Click(object sender, EventArgs e) { IList <IDepositoEntity> depositos = DepositoDao.ConsultarDeposito(txtConsultarDeposito.Text); dtgridConsultarDeposito.Rows.Clear(); if (depositos.Count <= 0) { MessageBox.Show("A busca não retornou resultado."); return; } int rowId = 0; foreach (IDepositoEntity depo in depositos) { rowId = dtgridConsultarDeposito.Rows.AddCopy(0); dtgridConsultarDeposito.Rows[rowId].Cells["CodigoDeposito"].Value = depo.IdDeposito; dtgridConsultarDeposito.Rows[rowId].Cells["Descricao"].Value = depo.DescricaoDeposito; dtgridConsultarDeposito.Rows[rowId].Cells["Estado"].Value = depo.Estado; dtgridConsultarDeposito.Rows[rowId].Cells["CEP"].Value = depo.CEP; dtgridConsultarDeposito.Rows[rowId].Cells["Cidade"].Value = depo.Cidade; dtgridConsultarDeposito.Rows[rowId].Cells["Bairro"].Value = depo.Bairro; dtgridConsultarDeposito.Rows[rowId].Cells["Logradouro"].Value = depo.Logradouro; dtgridConsultarDeposito.Rows[rowId].Cells["Numero"].Value = depo.Numero; dtgridConsultarDeposito.Rows[rowId].Cells["Complemento"].Value = depo.Complemento; } }
private void AlterarDeposito_Load(object sender, EventArgs e) { IList <IDepositoEntity> depositos = DepositoDao.ConsultarDepositoById(this.CodigoDeposito); foreach (IDepositoEntity depo in depositos) { txtDescricaoDeposito.Text = depo.DescricaoDeposito.ToString(); txtEstadoDeposito.Text = depo.Estado.ToString(); txtCidadeDeposito.Text = depo.Cidade.ToString(); mkdtxtCEP.Text = depo.CEP.ToString(); txtBairroDeposito.Text = depo.Bairro.ToString(); txtLogradouroDeposito.Text = depo.Logradouro.ToString(); mkdtxtNumero.Text = depo.Numero.ToString(); txtComplementoDeposito.Text = depo.Complemento.ToString(); } }
private void btnExcluirDeposito_Click(object sender, EventArgs e) { int codigoDeposito = 0; DialogResult result = MessageBox.Show("Deseja realmente excluir o Deposito?", "Confirma exclusão ", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { foreach (DataGridViewRow row in dtgridConsultarDeposito.SelectedRows) { int codigoDepositoSelecionado = Convert.ToInt32(row.Cells["CodigoDeposito"].Value); codigoDeposito = codigoDepositoSelecionado; } DepositoDao.ExcluirDeposito(codigoDeposito); MessageBox.Show("Deposito excluido com sucesso."); IList <IDepositoEntity> depositos = DepositoDao.ConsultarDeposito(txtConsultarDeposito.Text); dtgridConsultarDeposito.Rows.Clear(); int rowId = 0; foreach (IDepositoEntity depo in depositos) { rowId = dtgridConsultarDeposito.Rows.AddCopy(0); dtgridConsultarDeposito.Rows[rowId].Cells["CodigoDeposito"].Value = depo.IdDeposito; dtgridConsultarDeposito.Rows[rowId].Cells["Descricao"].Value = depo.DescricaoDeposito; dtgridConsultarDeposito.Rows[rowId].Cells["Estado"].Value = depo.Estado; dtgridConsultarDeposito.Rows[rowId].Cells["CEP"].Value = depo.CEP; dtgridConsultarDeposito.Rows[rowId].Cells["Cidade"].Value = depo.Cidade; dtgridConsultarDeposito.Rows[rowId].Cells["Bairro"].Value = depo.Bairro; dtgridConsultarDeposito.Rows[rowId].Cells["Logradouro"].Value = depo.Logradouro; dtgridConsultarDeposito.Rows[rowId].Cells["Numero"].Value = depo.Numero; dtgridConsultarDeposito.Rows[rowId].Cells["Complemento"].Value = depo.Complemento; } } }
private void CadastroItem_Load(object sender, EventArgs e) { //Lista depositos cbDeposito.DisplayMember = "TextoExibicao"; cbDeposito.ValueMember = "IdDeposito"; IList <IDepositoEntity> lstDepositos = DepositoDao.RetornarDepositos(); foreach (IDepositoEntity deposito in lstDepositos) { cbDeposito.Items.Add(deposito); } //Lista tipo itens cbTipoItem.DisplayMember = "TextoExibicao"; cbTipoItem.ValueMember = "IdTipoItem"; IList <ITipoItemEntity> lstTipoItens = TipoItemDao.RetornarTipoItem(); foreach (ITipoItemEntity tipoitem in lstTipoItens) { cbTipoItem.Items.Add(tipoitem); } }
private void btnSalvarDeposito_Click(object sender, EventArgs e) { string erros = ""; //Validações if (txtDescricaoDeposito.Text == "") { erros += "- Preencha o campo Descrição;\n"; } if (txtEstadoDeposito.Text == "") { erros += "- Preencha o campo Estado;\n"; } if (txtCidadeDeposito.Text == "") { erros += "- Preencha o campo Cidade;\n"; } mkdtxtCEP.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; if (mkdtxtCEP.Text == "") { erros += "- Preencha o campo CEP;\n"; } if (txtBairroDeposito.Text == "") { erros += "- Preencha o campo Bairro;\n"; } if (txtLogradouroDeposito.Text == "") { erros += "- Preencha o campo Logradouro;\n"; } if (mkdtxtNumero.Text == "") { erros += "- Preencha o campo Numero;\n"; } mkdtxtCEP.TextMaskFormat = MaskFormat.IncludePromptAndLiterals; mkdtxtNumero.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; if (!string.IsNullOrEmpty(erros)) { MessageBox.Show(erros); } else { DepositoEntity deposito = new DepositoEntity(); { deposito.DescricaoDeposito = txtDescricaoDeposito.Text; deposito.Estado = txtEstadoDeposito.Text; deposito.CEP = mkdtxtCEP.Text; deposito.Cidade = txtCidadeDeposito.Text; deposito.Bairro = txtBairroDeposito.Text; deposito.Logradouro = txtLogradouroDeposito.Text; deposito.Numero = int.Parse(mkdtxtNumero.Text); deposito.Complemento = txtComplementoDeposito.Text; } DepositoDao.IncluirDeposito(deposito); MessageBox.Show("Incluido com sucesso!"); this.Close(); } }