Last active
July 22, 2019 13:26
-
-
Save MirandinhaKL/4d040b37ec9528fa5b4e621035f59a4d to your computer and use it in GitHub Desktop.
Interface gráfica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Carrega a combo box com os departamentos dos produtos; | |
/// </summary> | |
private void carrega_combo_box_departamento() | |
{ | |
banco_departamento conexao_departamento = new banco_departamento(); | |
lista_departamento = conexao_departamento.carrega_departamentos().OrderBy(c => c.cod_departamento).ToList(); | |
metodo.informa_erro_banco_dados(lista_departamento, 77); | |
if (cb_departamento.Items.Count == 0) | |
{ | |
foreach (depto_produto item in lista_departamento) | |
{ | |
cb_departamento.Items.Add(item.des_departamento); | |
} | |
} | |
cb_departamento.AutoCompleteMode = AutoCompleteMode.None; | |
} | |
/// <summary> | |
/// Carrega o combo box com os itens previamente definidos. | |
/// </summary> | |
private void carrega_combobox_sitaucao() | |
{ | |
string[] lista_situacao = new string[]{"ANDAMENTO", "CONCLUÍDO, " + | |
"NÃO CONCLUÍDO/REPROVADO", "NOVO"}; | |
if (combo_situacao.Items.Count == 0) | |
{ | |
foreach (string item in lista_situacao) | |
{ | |
combo_situacao.Items.Add(item); | |
} | |
} | |
} | |
/// <summary> | |
/// Carrega o combobox com um item em específico selecionado. | |
/// </summary> | |
/// <param name="sender"></param> | |
/// <param name="e"></param> | |
private void Btn_edita_setor_Click(object sender, EventArgs e) | |
{ | |
if (validacao.linha_foi_selecionada_na_list_view(lv_setor, "editar")) | |
{ | |
btn_edita_setor.Enabled = false; | |
this.Cursor = Cursors.WaitCursor; | |
var linha_selecionada = lv_setor.SelectedItems[0]; | |
int codigo_setor = Convert.ToInt32(linha_selecionada.SubItems[0].Text); | |
Banco_setor conexao_setor = new Banco_setor(); | |
setor_retornado = conexao_setor.obtem_dados_de_um_setor(codigo_setor); | |
txt_cod_setor.Text = setor_retornado.codigo_setor.ToString(); | |
txt_nome_setor.Text = setor_retornado.nome; | |
txt_respon_setor.Text = setor_retornado.responsavel; | |
combo_empresa_setor.SelectedIndex = lista_empresas.FindIndex(k => k.id_empresa == setor_retornado.id_setor); | |
this.Cursor = Cursors.Default; | |
habilita_campos_setor(false); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Obtendo o caminho do save file dialog. | |
string caminho = saveFileDialog1.FileName; | |
// Obtendo o caminho de uma pasta selecionada pelo usuário. | |
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) | |
{ | |
string caminho = folderBrowserDialog1.SelectedPath; | |
} | |
} | |
// Configurando o valor de um combobox estará exibindo. | |
int departamento = lista_departamento.FindIndex(k => k.des_departamento == produto_retornado.des_departamento); | |
cb_departamento.SelectedIndex = departamento; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mensagem de confirmação para o usuário | |
string mensagem = "Você realmente deseja remover o produto \"" + nome_produto + "\"?"; | |
string titulo = "Atenção!"; | |
MessageBoxButtons botoes = MessageBoxButtons.YesNo; | |
MessageBoxIcon icone = MessageBoxIcon.Question; | |
DialogResult resultado = MessageBox.Show(mensagem, titulo, botoes, icone); | |
if (resultado == DialogResult.Yes) | |
{} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Carrega os dados da tabela produto do banco de dados, para a listview produto. | |
/// </summary> | |
private void carrega_listview_produto() | |
{ | |
this.Cursor = Cursors.WaitCursor; | |
lv_produto.Items.Clear(); | |
banco_produto banco_produto = new banco_produto(); | |
lista_produtos_banco = banco_produto.carrega_produtos(); | |
metodo.informa_erro_banco_dados(lista_produtos_banco, 70); | |
if (lista_produtos_banco.Count != 0) | |
{ | |
lv_produto.Enabled = true; | |
foreach (var item in lista_produtos_banco) | |
{ | |
double valor_unitario = Convert.ToDouble(item.valor_unitario.ToString()); | |
string valor_unitario_formatado = validacao.ajusta_casa_decimal(valor_unitario); | |
ListViewItem lvi_produtos = new ListViewItem(); | |
lvi_produtos.Text = item.nome_produto.ToString(); | |
lvi_produtos.SubItems.Add(item.codigo_produto.ToString()); | |
lvi_produtos.SubItems.Add(valor_unitario_formatado); | |
lvi_produtos.SubItems.Add(item.codigo_barras); | |
lvi_produtos.SubItems.Add(item.descricao_subgrupo); | |
lv_produto.Items.Add(lvi_produtos); | |
} | |
} | |
else | |
{ | |
MessageBox.Show("Nenhum produto cadastrado no banco de dados.", "Status da ação", | |
MessageBoxButtons.OK, MessageBoxIcon.Information); | |
} | |
this.Cursor = Cursors.Default; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment