private void lbox_Entregas_Click(object sender, EventArgs e) { if (lbox_Entregas.SelectedIndex != -1) { EntregaBD obj_EntregaBD = new EntregaBD(); string sLinha = lbox_Entregas.Items[lbox_Entregas.SelectedIndex].ToString(); int ipos = 0; for (int t = 0; t <= sLinha.Length; t++) { if (sLinha.Substring(t, 1) == "-") { ipos = t; break; } } Entrega_Principal.COD_ENTREGA = Convert.ToInt16(sLinha.Substring(0, ipos)); Entrega_Principal = obj_EntregaBD.FindByCodEntrega(Entrega_Principal); PopulaTela(Entrega_Principal); obj_FuncGeral.StatusBtn(this, 2); } }
/********************************************************************************** * NOME: PopulaLista * PROCEDIMENTO: Preenche o ListBox com os dados que estão na TB_Entrega * DT CRIAÇÃO: 02/12/2019 * DT ALTERAÇÃO: - * ESCRITA POR: Mfacine (Monstro) * OBSERVAÇÕES: * ********************************************************************************/ private void PopulaLista() { string sPer = null; string sSem = null; // Instância do objeto EntregaBD EntregaBD obj_EntregaBD = new EntregaBD(); // Instância do objeto Lista List <Entrega> Lista = new List <Entrega>(); // Limpando o ListBox lbox_Entregas.Items.Clear(); Lista = obj_EntregaBD.FindAllEntrega(); if (Lista != null) { for (int i = 0; i <= Lista.Count - 1; i++) { //(02/12/2019 - Mfacine) - PERIODOS// sPer = obj_FuncGeral.TrazPeriodo(Lista[i].PER_ENTREGA); //(02/12/2019 - Mfacine) - DIAS SEMANA// sSem = obj_FuncGeral.TrazSemana(Lista[i].SEM_ENTREGA); lbox_Entregas.Items.Add(Lista[i].COD_ENTREGA.ToString() + "-" + sPer + "-" + sSem); } } }
private void btn_Excluir_Click(object sender, EventArgs e) { EntregaBD obj_EntregaBD = new EntregaBD(); DialogResult varResp = MessageBox.Show("Confirma a Exclusão?", "Exclusão da Entrega", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (varResp == DialogResult.Yes) { if (obj_EntregaBD.Excluir(Entrega_Principal)) { MessageBox.Show("Entrega excluida com sucesso. ", "Exclusão da Entrega", MessageBoxButtons.OK, MessageBoxIcon.Information); } obj_FuncGeral.LimpaTela(this); obj_FuncGeral.HabilitaTela(this, false); obj_FuncGeral.StatusBtn(this, 1); PopulaLista(); } }
private void btn_Confirmar_Click(object sender, EventArgs e) { EntregaBD obj_EntregaBD = new EntregaBD(); Entrega_Principal = PopulaObjeto(); if (Entrega_Principal.COD_ENTREGA != -1) { obj_EntregaBD.Alterar(Entrega_Principal); MessageBox.Show("Entrega alterada com sucesso. ", "Alteração da Entrega", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Entrega_Principal.COD_ENTREGA = obj_EntregaBD.Incluir(Entrega_Principal); MessageBox.Show("Entrega Incluida com sucesso. ", "Inclusão da Entrega", MessageBoxButtons.OK, MessageBoxIcon.Information); PopulaTela(Entrega_Principal); } obj_FuncGeral.StatusBtn(this, 2); obj_FuncGeral.HabilitaTela(this, false); PopulaLista(); }