コード例 #1
0
        private void BtnGravar_Click(object sender, EventArgs e)
        {
            if (TxtCodCliente.Text.Trim() != "0")
            {
                MvInstalacao.Data       = TxtData.Value;
                MvInstalacao.IdPessoa   = int.Parse(TxtCodCliente.Text);
                MvInstalacao.IdVenda    = int.Parse(TxtNumVenda.Value.ToString());
                MvInstalacao.DtPrevista = TxtDtPrevisao.Value;
                MvInstalacao.IdVendedor = int.Parse(LstVendedor.SelectedValue.ToString());
                MvInstalacao.Observacao = TxtObservacao.Text;
                MvInstalacao.Servico    = TxtServico.Text;
                MvInstalacao.Endereco   = TxtEndereco.Text;
                MvInstalacao.Contato    = TxtContato.Text;
                MvInstalacao.Telefone   = TxtTelefone.Text;
                MvInstalacao.QtdeEquip  = int.Parse(TxtQtdeEquip.Value.ToString());
                if (Chk_Concluido.Checked)
                {
                    MvInstalacao.Status = 1;
                }
                else
                {
                    MvInstalacao.Status = 0;
                }
                MvInstalacao.GravarDados();

                if (MvInstalacao.Status == 0)
                {
                    Controle.ExecutaSQL("UPDATE ControleInstalacao SET DTConcluido=NULL WHERE ID_LANC=" + MvInstalacao.IdLanc.ToString());
                }
                else
                {
                    Controle.ExecutaSQL("UPDATE ControleInstalacao SET DTConcluido=CONVERT(DATETIME,'" + TxtDtConcluido.Value.Date.ToShortDateString() + "',103) WHERE ID_LANC=" + MvInstalacao.IdLanc.ToString());
                }
                PopularGrid();
                PopularCampos(MvInstalacao.IdLanc);
                StaFormEdicao = false;
                FrmPrincipal.ControleBotoes(false);
            }
            else
            {
                MessageBox.Show("Favor informar o Cliente", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                TxtData.Focus();
            }
        }
コード例 #2
0
        //button register
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(rezult);

            if (TxtFirstname.Text == "")
            {
                MessageBox.Show("Please enter confirm password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtFirstname.Focus();
                return;
            }
            if (TxtFamilyname.Text == "")
            {
                MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtFamilyname.Focus();
                return;
            }

            if (TxtData.Text == "")
            {
                MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtData.Focus();
                return;
            }
            if (TxtNumber.Text == "")
            {
                MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtNumber.Focus();
                return;
            }
            try
            {
                SqlConnection myConnection = default(SqlConnection);
                myConnection = new SqlConnection(@"Data Source=DESKTOP-NP1RDM2\BAZALUIMARIAN;Initial Catalog=task;Persist Security Info=True;User ID=sa; Password = 0299");
                String query = "INSERT INTO dbo.Clientapp (family_name,first_name,clientappdate,number) VALUES (@family_name,@first_name,@clientappdate,@number)";

                using (SqlCommand command = new SqlCommand(query, con))
                {
                    command.Parameters.AddWithValue("@family_name", TxtFamilyname.Text);
                    command.Parameters.AddWithValue("@first_name", TxtFirstname.Text);
                    command.Parameters.AddWithValue("@clientappdate", TxtData.Text);
                    command.Parameters.AddWithValue("@number", TxtNumber.Text);

                    MessageBox.Show("Register successfully !We will call you back today !", "Register Successfully", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    con.Open();
                    int result = command.ExecuteNonQuery();
                    Hide();

                    // Check Error
                    if (result < 0)
                    {
                        MessageBox.Show("Register Denied", "Register Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        TxtNumber.Clear();
                        TxtFirstname.Clear();
                        TxtFamilyname.Clear();
                        TxtData.Clear();
                        TxtFamilyname.Focus();
                        Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
 // EXAMPLE #2 *****************************************************
 private void BtnAddToList_Click(object sender, EventArgs e)
 {
     LBoxData.Items.Add(TxtData.Text);
     TxtData.Clear();
     TxtData.Focus();
 }