Пример #1
0
        private void StartRead_Click(object sender, EventArgs e)
        {
            TxtData.Clear();
            if (FileList.SelectedNode != null && FileList.SelectedNode != FileList.Nodes[0])
            {
                TreeNode nowNode = FileList.SelectedNode;
                String   DirPath = Path.Combine(directory_.Text, nowNode.Text);

                if (nowNode.Text.Contains(".txt"))
                {
                    try
                    {
                        FileStream file   = new FileStream(DirPath, FileMode.Open, FileAccess.Read);
                        byte[]     byData = new byte[file.Length];
                        file.Seek(0, SeekOrigin.Begin);
                        int readbyte = file.Read(byData, 0, byData.Length);
                        TxtData.AppendText(new string(Encoding.ASCII.GetChars(byData, 0, readbyte)));

                        file.Close();
                    }
                    catch (IOException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Пример #2
0
        private void ToolsSpellingHints_Click(object sender, RoutedEventArgs e)
        {
            var spellingHints = string.Empty;
            var error         = TxtData.GetSpellingError(TxtData.CaretIndex);

            if (error != null)
            {
                foreach (var s in error.Suggestions)
                {
                    spellingHints += $"{s}\n";
                }

                LblSpellingHints.Content    = spellingHints;
                ExpanderSpelling.IsExpanded = true;
            }
        }
Пример #3
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();
            }
        }
Пример #4
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);
            }
        }
Пример #5
0
 // EXAMPLE #2 *****************************************************
 private void BtnAddToList_Click(object sender, EventArgs e)
 {
     LBoxData.Items.Add(TxtData.Text);
     TxtData.Clear();
     TxtData.Focus();
 }