Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class for_compra : Form
- {
- conexao resultado = new conexao();
- public for_compra()
- {
- InitializeComponent();
- }
- private void for_compra_Load(object sender, EventArgs e)
- {
- cbox_tipo.SelectedIndex = 0;
- cbox_pagamento.SelectedIndex = 0;
- }
- private void cbox_pagamento_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (cbox_pagamento.SelectedItem.ToString() == "a vista")
- {
- lbl_fiado.Text = "P";
- txt_dpagamento.Text = "";
- txt_dpagamento.Text = DateTime.Now.ToShortDateString();
- txt_dpagamento.Enabled = true;
- }
- else
- {
- lbl_fiado.Text = "F";
- txt_dpagamento.Enabled = false;
- txt_dpagamento.Text = "";
- }
- }
- private void btn_cadastrar_Click(object sender, EventArgs e)
- {
- try
- {
- if (cbox_pagamento.SelectedItem.ToString() == "a vista")
- {
- btn_avista.PerformClick();
- }
- else
- {
- btn_aprazo.PerformClick();
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("Falha ao salvar no banco de dados :" + ex);
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void txt_valor_KeyPress(object sender, KeyPressEventArgs e)
- {
- txt_valor.MaxLength = 7;
- }
- private void btn_avista_Click(object sender, EventArgs e)
- {
- var mo = new Modelo();
- var con = new conexao();
- try
- {
- if (Decimal.TryParse(txt_valor.Text.Replace(',','.'), out var valor))
- {
- mo.Data_Compra = txt_dcompra.Text;
- mo.Data_Alvo = txt_dalvo.Text;
- mo.Fornecedor = txt_fornecedor.Text;
- mo.Valor = valor;
- mo.Tipo = cbox_tipo.Text;
- mo.Pagamento = lbl_fiado.Text;
- mo.Data_Pagamento = txt_dpagamento.Text;
- con.cadastro(mo);
- txt_fornecedor.Text = "";
- txt_valor.Text = "";
- MessageBox.Show("Dados gravados com sucesso!");
- }
- }
- catch (MySqlException ex)
- {
- MessageBox.Show("Falha ao salvar no banco de dados :" + ex);
- }
- }
- private void btn_aprazo_Click(object sender, EventArgs e)
- {
- var mo = new Modelo();
- var con = new conexao();
- try
- {
- if (Decimal.TryParse(txt_valor.Text.Replace(',', '.'), out var valor))
- {
- mo.Data_Compra = txt_dcompra.Text;
- mo.Data_Alvo = txt_dalvo.Text;
- mo.Fornecedor = txt_fornecedor.Text;
- mo.Valor = valor;
- mo.Tipo = cbox_tipo.Text;
- mo.Pagamento = lbl_fiado.Text;
- mo.Data_Pagamento = txt_dpagamento.Text;
- con.cadastro_aprazo(mo);
- txt_fornecedor.Text = "";
- txt_valor.Text = "";
- MessageBox.Show("Dados gravados com sucesso!");
- }
- }
- catch (MySqlException ex)
- {
- MessageBox.Show("Falha ao salvar no banco de dados :" + ex);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement