예제 #1
0
        // user login button
        private void first_Click(object sender, RoutedEventArgs e)
        {
            //validate data from user-input
            if (username.Text.Length == 0)
            {
                errormessage.Text = "Enter an username.";
                username.Focus();
            }
            else if (pd.Password.Length == 0)
            {
                errormessage1.Text = "Enter an password.";
                pd.Focus();
            }
            //   MessageBox.Show(password.ToString());
            dc = new DataClasses1DataContext();
            Table tb = new Table();


            //fetching value from database
            var q1 = from a in dc.logins where a.type == firstname.Text && a.username == username.Text && a.password == pd.Password.ToString() select a;

            foreach (var b in q1)
            {
                if (b.type == "Admin" && b.username == username.Text && b.password == pd.Password.ToString())
                {
                    MessageBox.Show("Welcome " + username.Text);
                    string  value = username.Text;
                    Window3 w2    = new Window3();
                    w2.fetch(value.ToString());
                    w2.Show();
                    this.Close();
                }
                else if (b.type == "Manager" && b.username == username.Text && b.password == pd.Password.ToString())
                {
                    //MessageBox.Show("Welcome Manager");
                    MessageBox.Show("Welcome " + username.Text);
                    string     value = username.Text;
                    MainWindow w2    = new MainWindow();
                    w2.fetch(value.ToString());
                    w2.Show();
                    this.Close();
                }
                else if (b.type == "Employee" && b.username == username.Text && b.password == pd.Password.ToString())
                {
                    MessageBox.Show("Welcome " + username.Text);
                    string  value = username.Text;
                    Window2 w2    = new Window2();
                    w2.fetch(value.ToString());
                    w2.Show();
                    this.Close();
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Timer_Tick метод осуществляющий тик и проверку окончания тайминга
 /// Так же идет вызов разблокировки, закрытие существующей формы и вызов формы windows1,
 /// когда конечный пользователь не нарушил условия тайминга
 /// </summary>
 /// <param name="sender"></param> переменная для связки таймера
 /// <param name="e"></param> параметр не содержит данных
 private void Timer_Tick(object sender, EventArgs e)
 {
     if (--TickCounter <= 0)
     {
         var timer = (DispatcherTimer)sender;
         timer.Stop();
         Unlock();
         Window2 window2 = new Window2();
         window2.Show();
         this.Close();
     }
 }
예제 #3
0
        private void Button_Click3(object sender, RoutedEventArgs e)
        {
            Window2 reg = new Window2();

            reg.ShowDialog();
            CurrentUser          = reg.user;
            Title                = "Cuurent User: " + CurrentUser.Name;
            Add_Button.IsEnabled = true;
            if (CurrentUser != null)
            {
                Reg_Button.IsEnabled = false;
            }
        }
예제 #4
0
 private void acceptButton_Click2(object sender, RoutedEventArgs e)
 {
     if (otvet == "Лампочка")
     {
         Hide();
         Window2 Готово = new Window2();
         Готово.ShowDialog();
         Close();
     }
     else
     {
         Hide();
         Close();
     }
 }
예제 #5
0
        private void Buttonlogin_Click(object sender, RoutedEventArgs e)
        {
            Window2 windo2  = new Window2();
            Window3 window3 = new Window3();

            if (pass.Text == "step")
            {
                windows2.Close();
                window3.ShowDialog();
            }
            else
            {
                MessageBox.Show("Пароль не пiдходить, спробуйте звернутися до викладача.");
            }
        }
예제 #6
0
        public Connexion()
        {
            //Install_DB();
            Lecture_BDD();
            Window2.charger_option();
            user_name     = Window2.user_name;
            user_paswword = Window2.user_Password;
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            InitializeComponent();
            verification.Close();
            verification.Visibility = Visibility.Hidden;
            DoubleAnimation a = new DoubleAnimation();

            a.From     = 0.0; a.To = 1.0;
            a.Duration = new Duration(TimeSpan.FromSeconds(3));
        }
예제 #7
0
        private void buttonTreeView_Click(object sender, RoutedEventArgs e)
        {
            Window2 window = new Window2();

            window.ShowDialog();
        }
예제 #8
0
        public void work(int i)
        {
            if (checkForInternetConnection())
            {
                if (tasktype == "find")
                {
                    WebClient site = new WebClient();
                    Uri       uriResult;
                    bool      result = Uri.TryCreate(this.url, UriKind.Absolute, out uriResult) &&
                                       (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
                    if (result)
                    {
                        string linkToImage = FindImage(site);
                        if (linkToImage == "")
                        {
                            errorStr = "image";
                            return;
                        }
                        if (responsetype == "saveas")
                        {
                            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                            dlg.FileName   = this.text;
                            dlg.DefaultExt = ".png";
                            dlg.Filter     = "Image (.png)|*.png";

                            Nullable <bool> resultBool = dlg.ShowDialog();

                            if (resultBool == true)
                            {
                                this.filename = dlg.FileName;
                            }
                            if (filename != "")
                            {
                                using (WebClient client = new WebClient())
                                {
                                    client.DownloadFile(linkToImage, this.filename);
                                }

                                errorStr = "complete";
                            }
                        }
                        this.filename = "meme" + i.ToString() + ".png";
                        if (responsetype == "mail")
                        {
                            using (WebClient client = new WebClient())
                            {
                                client.DownloadFile(linkToImage, this.filename);
                            }
                            if (!SendMail(linkToImage))
                            {
                                errorStr = "address";
                            }
                        }
                        this.filename = "meme" + i.ToString() + ".png";
                        if (responsetype == "display")
                        {
                            Window2 win2         = new Window2();
                            var     image        = new Image();
                            var     fullFilePath = linkToImage;

                            BitmapImage bitmap = new BitmapImage();
                            bitmap.BeginInit();
                            bitmap.UriSource = new Uri(fullFilePath, UriKind.Absolute);
                            bitmap.EndInit();

                            image.Source = bitmap;

                            win2.canvas.Children.Add(image);

                            using (WebClient client = new WebClient())
                            {
                                client.DownloadFile(linkToImage, this.filename);
                            }

                            win2.ShowDialog();

                            errorStr = "complete";
                        }
                    }
                }
                else if (tasktype == "weather")
                {
                    try
                    {
                        using (WebClient client = new WebClient())
                        {
                            string fullcityname = city[0].ToString().ToUpper() + city.Substring(1).ToLower();

                            city = fullcityname;

                            string weatherJson = client.DownloadString(findweather(city));
                            var    wth         = JsonConvert.DeserializeObject <jsonClass.RootObject>(weatherJson);

                            this.name  = wth.name;
                            this.temp  = wth.main.temp;
                            this.press = wth.main.pressure;
                            this.humid = wth.main.humidity;
                            this.desc  = wth.weather[0].description;
                            int tmpInd = weatherJson.IndexOf("\"icon\":\"");
                            this.wetid = weatherJson.Substring(tmpInd + "\"icon\":\"".Length, 3);
                        }
                        if (tempCase < this.temp)
                        {
                            if (responsetype == "mail")
                            {
                                if (!SendWeather())
                                {
                                    errorStr = "address";
                                }
                            }

                            else if (responsetype == "saveas")
                            {
                                string content = "Oto dzisiejsza pogoda w mieście: " + name + "\n" +
                                                 " Temperatura powietrza wynosi " + temp + " stopni.\n" +
                                                 "Ciśnienie wynosi " + press + " hektopaskali.\n" +
                                                 "Wilgotność powietrza na poziomie " + humid + ".\n" +
                                                 "Ogólnie pogodę można opisać słowami: " + desc + ".";
                                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                                dlg.FileName   = "pogoda";
                                dlg.DefaultExt = ".txt";
                                dlg.Filter     = "txt files (*.txt)|*.txt";

                                Nullable <bool> resultBool = dlg.ShowDialog();

                                if (resultBool == true)
                                {
                                    StreamWriter writer = new StreamWriter(dlg.OpenFile());
                                    writer.Write(content);
                                    writer.Dispose();
                                    writer.Close();
                                    this.filename = dlg.FileName;
                                }
                                errorStr = "complete";
                            }
                            else if (responsetype == "display")
                            {
                                string content = "Oto dzisiejsza pogoda w mieście: " + name + "\n" +
                                                 "Temperatura powietrza wynosi " + temp + " stopni.\n" +
                                                 "Ciśnienie wynosi " + press + " hektopaskali.\n" +
                                                 "Wilgotność powietrza na poziomie " + humid + ".\n" +
                                                 "Ogólnie pogodę można opisać słowami: " + desc + ".";
                                Window3 win3 = new Window3();
                                win3.label.Content = content;

                                var image = new Image();

                                var fullFilePath = @"http://openweathermap.org/img/w/" + this.wetid + ".png";
                                Console.WriteLine(this.wetid);

                                BitmapImage bitmap = new BitmapImage();
                                bitmap.BeginInit();
                                bitmap.UriSource = new Uri(fullFilePath, UriKind.Absolute);
                                bitmap.EndInit();

                                image.Source = bitmap;

                                win3.weatherIcon.Children.Add(image);

                                win3.ShowDialog();
                                errorStr = "complete";
                            }
                        }

                        else
                        {
                            errorStr = "temp";
                        }
                    }
                    catch (Exception ex)
                    {
                        errorStr = "weather";
                    }
                }
            }
            else
            {
                errorStr = "internet"; return;
            }
        }
예제 #9
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Window2 window2 = new Window2();

            window2.Show();
        }