private void ImageButton_Click(object sender, RoutedEventArgs e)
        {
            Textbox1.IsEnabled = false;
            Textbox1.Clear();

            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter = "jpg files (*.jpg)|*.jpg|png files (*.png)|*.png|All files (*.*)|*.*";

                openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

                if (openFileDialog.ShowDialog() == true)
                {
                    imageLocation = openFileDialog.FileName;
                    foreach (var item in messengersList)
                    {
                        images = item.GetImage();
                    }
                }
            }
            catch (Exception)
            {
            }



            AddImageList();
            listboxImage();

            Textbox1.IsEnabled = true;
        }
Exemplo n.º 2
0
 private void Textbox1_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (Textbox1.Text != null)
     {
         Textbox1.Select(Textbox1.Text.Length, 0);
         Textbox1.Text = Textbox1.Text.ToUpper();
     }
 }
Exemplo n.º 3
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Textbox1.Clear();
            Textbox2.Clear();
            Textbox3.Clear();

            radioButton1.IsChecked = false;
            radioButton2.IsChecked = false;
        }
 private void Equals_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         second = Convert.ToInt32(Textbox1.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show("That's not a valid number!");
         Textbox1.Clear();
         return;
     }
     if (method == "+")
     {
         int    result       = first + second;
         string stringResult = Convert.ToString(result);
         Textbox1.Text = stringResult;
         EnableButtons();
         firsttime = true;
         Lb1.Items.Add(stringResult);
     }
     if (method == "-")
     {
         int    result       = first - second;
         string stringResult = Convert.ToString(result);
         Textbox1.Text = stringResult;
         EnableButtons();
         firsttime = true;
         Lb1.Items.Add(stringResult);
     }
     if (method == "*")
     {
         int    result       = first * second;
         string stringResult = Convert.ToString(result);
         Textbox1.Text = stringResult;
         EnableButtons();
         firsttime = true;
         Lb1.Items.Add(stringResult);
     }
     if (method == "/")
     {
         if (second == 0)
         {
             MessageBox.Show("Cannot divide by Zero!");
             Textbox1.Clear();
             return;
         }
         int    result       = first / second;
         string stringResult = Convert.ToString(result);
         Textbox1.Text = stringResult;
         EnableButtons();
         firsttime = true;
         Lb1.Items.Add(stringResult);
     }
 }
Exemplo n.º 5
0
        private void button4_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (Textbox1.Text == "")
                {
                    MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Textbox1.Focus();
                    return;
                }
                else if (Textbox2.Text == "")
                {
                    MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Textbox2.Focus();
                    return;
                }
                else
                {
                    i = 0;
                    koneksi.Open();
                    MySqlCommand cmd = koneksi.CreateCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "select * from akun_siswa where username_siswa='" + Textbox1.Text + "'and password_siswa='" + Textbox2.Text + "'";
                    cmd.ExecuteNonQuery();
                    DataTable        dt = new DataTable();
                    MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                    da.Fill(dt);
                    i = Convert.ToInt32(dt.Rows.Count.ToString());

                    if (i == 0)
                    {
                        MessageBox.Show("you have entered invalid username or password", "Error");
                        Textbox1.Text = "";
                        Textbox2.Text = "";
                    }
                    else
                    {
                        save_data2();
                        MessageBox.Show("Welcome Student SMKN 10 Jakarta", "Login");
                        Form2 f2 = new Form2();
                        f2.Show();
                        this.Hide();
                        Textbox1.Text = "";
                        Textbox2.Text = "";
                    }
                    koneksi.Close();
                }
            }
            catch (Exception ex)
            {
                koneksi.Close();
                MessageBox.Show(ex.ToString(), ex.Message);
            }
        }
Exemplo n.º 6
0
        void pushLogToTextBox(string logMessage)
        {
            var linesLog = Textbox1.LineCount.CompareTo(20);

            if (linesLog > 0)
            {
                Dispatcher.BeginInvoke(
                    new ThreadStart(() => Textbox1.Clear()));
            }
            Dispatcher.BeginInvoke(
                new ThreadStart(() => Textbox1.Text += logMessage));
        }
        private async void CallNationalRegistryServiceButton_Click(object sender, RoutedEventArgs e)
        {
            var client      = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            string ocpApimSubscriptionKey = Constants.OcpApimSubscriptionKey;

            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", ocpApimSubscriptionKey);
            // Open service, not protected by AuthorizationServer:
            //client.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken);

            // Get all names starting with 'Gunnar':
            var uri = "https://arionapi-sandbox.azure-api.net/nationalregistry/v1/nationalRegistryParties/" + "Gunnar";

            // Get data from specific kennitala:
            //var uri = "https://arionapi-sandbox.azure-api.net/nationalregistry/v1/nationalRegistryParty/" + "111280XXXX";

            var response = await client.GetAsync(uri);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var json = await response.Content.ReadAsStringAsync();

                //var test = JObject.Parse(json);
                // We're getting array back, let's use JArray.Parse:
                var jsonArray = JArray.Parse(json);

                //JArray jarr = JArray.Parse(result);
                Textbox1.Text = string.Empty;
                foreach (JObject content in jsonArray.Children <JObject>())
                {
                    foreach (JProperty prop in content.Properties())
                    {
                        if (prop.Name == "Kennitala" || prop.Name == "FullName" || prop.Name == "Home")
                        {
                            string tempValue = prop.Value.ToString();
                            Textbox1.AppendText(tempValue + " - ");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show(response.StatusCode.ToString());
            }
        }
 public void IntConvert()
 {
     try
     {
         if (Convert.ToInt64(Textbox1.Text) > 2147483647)
         {
             MessageBox.Show("Number exceeds limits of a 32bit integer!");
             return;
         }
         first = Convert.ToInt32(Textbox1.Text);
         Textbox1.Clear();
         DisableButtons();
     }
     catch (Exception ex)
     {
         MessageBox.Show("That's not a valid number!");
         Textbox1.Clear();
         return;
     }
 }
        private void Square_Click(object sender, RoutedEventArgs e)
        {
            int square;

            try
            {
                square = Convert.ToInt32(Textbox1.Text);
                Textbox1.Clear();
                int squareResult;
                squareResult = square * square;
                string squareString;
                squareString  = Convert.ToString(squareResult);
                Textbox1.Text = squareString;
                Lb1.Items.Add(squareString);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Thats not a valid number!");
                Textbox1.Clear();
            }
        }
Exemplo n.º 10
0
        private void Delete1_Click(object sender, EventArgs e)//削除ボタンの処理 作品
        {
            string deletequery;
            int    counter = 0;

            counter = SQLiteConnect.counterID("origin", beforeListView1ID);
            if (counter != 0)
            {
                MessageBox.Show("データが" + counter + "件存在するため、削除できません。", "警告", MessageBoxButtons.OK);
                return;
            }
            DialogResult res = MessageBox.Show(beforeListview1Title + "を削除しますか?", "削除確認", MessageBoxButtons.YesNo);

            if (res == DialogResult.Yes)
            {
                deletequery = "delete from t_origin where origin_id =" + beforeListView1ID;
                SQLiteConnect.Excute(deletequery);
                Listview1.Items.Clear();
                SQLiteConnect.lording(ref Listview1, "select origin_ID,origin_title from t_origin", "origin_ID", "origin_title");
                Textbox1.Clear();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            String connection = "Provider=OraOLEDB.Oracle;Data Source=localhost;Workspace=Malcolm;User Id=MALCOLM;Password=madeira;OLEDB.NET=True";

            OleDbConnection obj1 = new OleDbConnection(connection);
            string          S3   = ComboBox1.SelectedItem.ToString(); //sex
            string          S1   = ComboBox2.SelectedItem.ToString();
            string          S2   = Textbox5.Text + 8;                 //For ID

            if (ComboBox2.SelectedItem.ToString() == "Employee")
            {
                if (Textbox6.Text == Textbox7.Text)
                {
                    String q2 = "insert into Login values ('" + Textbox5.Text + "','" + Textbox6.Text + "','" + S1 + "')";
                    obj1.Open();

                    try
                    {
                        OleDbCommand cm2 = new OleDbCommand(q2, obj1);
                        cm2.ExecuteNonQuery();
                    }
                    catch (Exception ee)
                    {
                        MessageBox.Show(ee.Message);
                    }
                }
                else
                {
                    MessageBox.Show("**********Password Don't Match\nPlease Re-ENTER*********");
                }
                //Employee details

                String q3 = "insert into EMPLOYEE values ('" + S2 + "','" + Textbox5.Text + "','" + Textbox2.Text + "','" + Textbox1.Text + "','" + Textbox3.Text + "','" + S3 + "')";


                try
                {
                    OleDbCommand cm2 = new OleDbCommand(q3, obj1);
                    cm2.ExecuteNonQuery();
                    MessageBox.Show("************Record Insert Successfully*********");
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
            }

            if (ComboBox2.SelectedItem.ToString() == "Customer")
            {
                if (Textbox6.Text == Textbox7.Text)
                {
                    String q4 = "insert into Login values ('" + Textbox5.Text + "','" + Textbox6.Text + "','" + ComboBox2.SelectedItem.ToString() + "')";
                    obj1.Open();

                    try
                    {
                        OleDbCommand cm2 = new OleDbCommand(q4, obj1);
                        cm2.ExecuteNonQuery();
                    }
                    catch (Exception ee)
                    {
                        MessageBox.Show(ee.Message);
                    }
                }
                else
                {
                    MessageBox.Show("**********Password Don't Match\nPlease Re-ENTER*********");
                }
                //Customer details

                String q3 = "insert into CUSTOMER values ('" + Textbox5.Text + "','" + S2 + "','" + Textbox2.Text + "','" + Textbox1.Text + "','" + Textbox3.Text + "','" + S3 + "')";


                try
                {
                    OleDbCommand cm2 = new OleDbCommand(q3, obj1);
                    cm2.ExecuteNonQuery();
                    MessageBox.Show("************Record Insert Successfully*********");
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
            }

            Textbox5.Clear();
            Textbox6.Clear();
            Textbox7.Clear();
            Textbox1.Clear();
            Textbox2.Clear();
            Textbox3.Clear();
        }
 private void button2_Click(object sender, EventArgs e)
 {
     Textbox1.Clear();
     Textbox2.Clear();
     Textbox3.Clear();
 }
Exemplo n.º 13
0
        private void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            string nombre, apellidos, dni, fechanac;

            int peso = 0, altura = 0;

            nombre    = Textbox1.Text;
            apellidos = Textbox2.Text;
            dni       = Textbox3.Text;

            fechanac = date.Text;
            if (!String.IsNullOrEmpty(Textbox5.Text))
            {
                peso = Convert.ToInt32(Textbox5.Text);
            }
            if (!String.IsNullOrEmpty(Textbox6.Text))
            {
                altura = Convert.ToInt32(Textbox6.Text);
            }


            Persona persona = new Persona(nombre, apellidos, dni, fechanac, peso, altura);

            int nope = 0;

            for (int i = 0; i < Personas.GetPersonas().Count; i++)
            {
                if (Personas.GetPersonas()[i].Dni == persona.Dni)
                {
                    nope = 1;
                    SoundPlayer My_JukeBox = new SoundPlayer(@"Sounds/nope.wav");
                    try
                    {
                        My_JukeBox.Play();
                    }
                    catch (FileNotFoundException ex)
                    {
                        Console.WriteLine(ex);
                    }
                    MessageBox.Show("Ya hay una persona con el mismo DNI");
                }
            }
            if (nope == 0)
            {
                SoundPlayer My_JukeBox2 = new SoundPlayer(@"Sounds/item.wav");
                try
                {
                    My_JukeBox2.Play();
                }
                catch (FileNotFoundException ex)
                {
                    // Write error.
                    Console.WriteLine(ex);
                }

                Personas.addPersona(persona);
                Task.Delay(700).Wait();
                this.Close();
            }
            else
            {
                Textbox1.Clear();
                Textbox2.Clear();
                Textbox3.Clear();
                Textbox6.Clear();
                Textbox5.Clear();
                date.ClearValue(DatePicker.SelectedDateProperty);
            }
        }
Exemplo n.º 14
0
        public void LoginClick(object parameter)
        {
            try
            {
                string ID       = Textbox1.ToString();
                string PASSWORD = Textbox2.ToString();

                if (string.IsNullOrEmpty(ID) || string.IsNullOrEmpty(PASSWORD))
                {
                    MessageBox.Show("아이디와 비밀번호를 모두 입력해주세요", "경고", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                bool result = LD.usersel(ID, PASSWORD);

                if (result)
                {
                    string       id = LoginViewModel.LD.user1.ID.ToString();
                    StreamWriter writer;
                    writer = File.AppendText("LoginLog.txt");
                    writer.WriteLine($"[{id}] LoginTime : " + System.DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss"));
                    writer.Close();

                    MainWindow MW = new MainWindow();
                    Application.Current.MainWindow.Close();
                    MW.ShowDialog();
                }
                else
                {
                    string Ip_check = Client_IP;

                    if (Ip_check != "192.168.0.10")
                    {
                        MessageBox.Show("접속이 허용되지 않은 IP입니다.", "보안 경고", MessageBoxButton.OK, MessageBoxImage.Stop);
                    }

                    if (count >= 2)
                    {
                        MessageBox.Show("의심스러운 로그인이 차단되었습니다.", "보안 경고", MessageBoxButton.OK, MessageBoxImage.Stop);
                        Application.Current.MainWindow.Close();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("아이디와 비밀번호를 확인해주세요", "경고", MessageBoxButton.OK, MessageBoxImage.Warning);
                        count++;
                    }
                }
            }
            catch (System.NullReferenceException)
            {
                MessageBox.Show("빈 항목이 있습니다.", "알림", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            catch (System.Exception)
            {
                MessageBox.Show("알 수 없는 오류가 발생했습니다.", "경고", MessageBoxButton.OK, MessageBoxImage.Warning);
                log.Error("LoginClick에서 오류 발생");
                return;
            }
        }
Exemplo n.º 15
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var std = new Zam();

                if (Textbox1.Text == "")
                {
                    throw new Exception("Проверьте ввода Краткое название");
                }
                else
                {
                    std.Kratkoe_nazvaniye = Textbox1.Text;
                }
                if (Textbox2.Text == "")
                {
                    throw new Exception("Проверьте ввода Катигория");
                }
                else
                {
                    std.Katigoria = Textbox2.Text;
                }
                if (Textbox3.Text == "")
                {
                    throw new Exception("Проверьте ввода Полное описание");
                }
                else
                {
                    std.Polnoe_opisanie = Textbox3.Text;
                }

                std.datetime = DateTime.Now;
                std.Status   = false;

                switch (radioButton1.IsChecked)
                {
                case true when radioButton2.IsChecked == false:
                    std.Preoritet = "Первый";
                    break;

                case false when radioButton2.IsChecked == true:
                    std.Preoritet = "Второй";
                    break;

                case false when radioButton2.IsChecked == false:
                    throw new Exception("Необходимо выбрать преоритет");
                }

                std_list.Add(std);

                MessageBox.Show("Задача сохранена");
                Textbox1.Clear();
                Textbox2.Clear();
                Textbox3.Clear();
                Textbox4.Clear();
                Textbox4.Text          = Convert.ToString(std.datetime);
                radioButton1.IsChecked = false;
                radioButton2.IsChecked = false;


                if (std_list.Count != 0)
                {
                    DataContractJsonSerializer jsonFormatter2 = new DataContractJsonSerializer(typeof(List <Zam>));
                    using (FileStream fs = new FileStream("D:\\фит\\ООП\\2 семестр лабы\\7_8\\doowr.json", FileMode.OpenOrCreate))
                    {
                        if (fs.Length != 0)
                        {
                            std_list3 = (List <Zam>)jsonFormatter2.ReadObject(fs);
                        }
                    }
                    // создаем объект Json
                    DataContractJsonSerializer jsonFormatter = new DataContractJsonSerializer(typeof(List <Zam>));
                    // получаем поток, куда будем записывать сериализованный объект

                    for (int i = 0; i < std_list3.Count; i++)
                    {
                        std_list.Add(std_list3[i]);
                    }
                    using (FileStream fs = new FileStream("D:\\фит\\ООП\\2 семестр лабы\\7_8\\doowr.json", FileMode.Create))
                    {
                        jsonFormatter.WriteObject(fs, std_list);
                    }
                    std_list.Clear();
                }
                else
                {
                    throw new Exception("Список пуст");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка: " + ex.Message, "Предупреждение!");
            }
        }