private void mskDtVenc_TypeValidationCompleted(object sender, TypeValidationEventArgs e) { if (!e.IsValidInput) { u.messageboxDataInv(); } }
private void maskedTextBoxDatacon_TypeValidationCompleted(object sender, TypeValidationEventArgs e) { if (!e.IsValidInput) { u.messageboxDataInv(); } }
private void btnSalvar_Click(object sender, EventArgs e) { if (txtCliente.Text == string.Empty || txtFuncionario.Text == string.Empty || cbSituação.Text == string.Empty || mskData.Text == string.Empty || mskHora.Text == string.Empty) { txtFuncionario.BackColor = Color.Gold; txtCliente.BackColor = Color.Gold; cbSituação.BackColor = Color.Gold; mskHora.BackColor = Color.Gold; mskData.BackColor = Color.Gold; u.messageboxDataInv(); } else { DateTime agdata = Convert.ToDateTime(mskData.Text); string aghora = mskHora.Text; string agconcluidos = cbSituação.Text; string agdescrisaun = txtObs.Text; int codfuncionario = Convert.ToInt32(txtFuncionario.Text); int codcliente = Convert.ToInt32(txtCliente.Text); if (novo) { string grava = " insert into agenda(age_data, age_hora, age_concluidos, age_descricao, cod_funcionario, cod_cliente)" + "values (@age_data, @age_hora, @age_concluidos, @age_descricao, @cod_funcionario, @cod_cliente)"; SqlConnection con = new SqlConnection(); con.ConnectionString = utils.ConexaoDb(); SqlCommand cmd = new SqlCommand(grava, con); cmd.Parameters.Add("@age_data", SqlDbType.Date).Value = agdata; cmd.Parameters.Add("@age_hora", SqlDbType.VarChar).Value = aghora; cmd.Parameters.Add("@age_concluidos", SqlDbType.VarChar).Value = agconcluidos; cmd.Parameters.Add("@age_descricao", SqlDbType.VarChar).Value = agdescrisaun; cmd.Parameters.Add("@cod_funcionario", SqlDbType.Int).Value = codfuncionario; cmd.Parameters.Add("@cod_cliente", SqlDbType.Int).Value = codcliente; con.Open(); try { int i = cmd.ExecuteNonQuery(); if (i > 0) { u.messageboxSucesso(); } } catch (Exception ex) { u.messageboxErro(ex.ToString()); } finally { con.Close(); } } else { string altera = " update agenda set age_data = @age_data, age_hora = @age_hora, age_concluido = @age_concluidos, age_descricao = @age_descricao, cod_funcionario = @cod_funcionario, cod_cliente = @cod_cliente where age_ccodigo = " + txtControle.Text; SqlConnection con = new SqlConnection(); con.ConnectionString = utils.ConexaoDb(); SqlCommand cmd = new SqlCommand(altera, con); cmd.Parameters.Add("@age_data", SqlDbType.Date).Value = agdata; cmd.Parameters.Add("@age_hora", SqlDbType.VarChar).Value = aghora; cmd.Parameters.Add("@age_concluidos", SqlDbType.VarChar).Value = agconcluidos; cmd.Parameters.Add("@age_descricao", SqlDbType.VarChar).Value = agdescrisaun; cmd.Parameters.Add("@cod_funcionario", SqlDbType.Int).Value = codfuncionario; cmd.Parameters.Add("@cod_cliente", SqlDbType.Int).Value = codcliente; con.Open(); try { int i = cmd.ExecuteNonQuery(); if (i > 0) { u.messageboxSucesso(); } } catch (Exception ex) { u.messageboxErro(ex.ToString()); } finally { con.Close(); } } this.MaximizeBox = false; u.limparTextBoxes(this); u.limparMTextBoxes(this); txtCliente.Enabled = false; txtFuncionario.Enabled = false; txtObs.Enabled = false; mskData.Enabled = false; mskHora.Enabled = false; cbSituação.Text = "Ocupado"; btnCancela.Enabled = false; btnExluir.Enabled = false; btnSalvar.Enabled = false; panelPCliente.Visible = false; panelPfunc.Visible = false; btnNovo.Enabled = true; btnLocalizar.Enabled = true; txtFuncionario.BackColor = SystemColors.Window; txtCliente.BackColor = SystemColors.Window; cbSituação.BackColor = SystemColors.Window; mskHora.BackColor = SystemColors.Window; mskData.BackColor = SystemColors.Window; } }