Example #1
0
        private void log_in_account_Click(object sender, RoutedEventArgs e)
        {
            DateTime      date         = DateTime.Today;
            string        sqlformatter = date.ToString("yyyy-MM-dd");
            SqlConnection connection   = new SqlConnection(strconnect);

            connection.Open();
            if (connection.State == System.Data.ConnectionState.Open)
            {
                string     k   = log.Text;
                string     p   = password.Password;
                string     ins = "select Id from USERS where  LOGIN=@k and PASSWORD=@p ";//, PASSWORD=@p; " ; //+ log.Text + "', PASSWORD='******'";
                SqlCommand com = new SqlCommand(ins, connection);
                com.Parameters.Add("@p", SqlDbType.NVarChar).Value = p;
                com.Parameters.Add("@k", SqlDbType.NVarChar).Value = k;
                object res = com.ExecuteScalar();
                com.ExecuteNonQuery();
                string     select  = "select NAME_US from USERS where  LOGIN=@k and PASSWORD=@p ";
                SqlCommand command = new SqlCommand(select, connection);
                command.Parameters.Add("@p", SqlDbType.NVarChar).Value = p;
                command.Parameters.Add("@k", SqlDbType.NVarChar).Value = k;
                object sel = command.ExecuteScalar();
                command.ExecuteNonQuery();
                if (res != null)
                {
                    try {
                        if (res.ToString() == "1")
                        {
                            Admin_log adm = new Admin_log();
                            adm.Show();
                            this.Close();
                        }
                        if (res.ToString() != "1")
                        {
                            User_log us = new User_log(sel.ToString());
                            us.Show();
                            this.Close();
                        }
                    }

                    catch {
                        log.Text          = "";
                        password.Password = "";
                        MessageBox.Show("Все поля должны быть заполнены!");
                    }
                }
                else
                {
                    MessageBox.Show("такого пользователя не существует");
                }
            }
            else
            {
                MessageBox.Show("Попробуйте ещё раз");
            }
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.menulog = ((кп.Admin_log)(target));
                return;

            case 2:
                this.grid = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.menu = ((System.Windows.Controls.Menu)(target));
                return;

            case 4:
                this.m1 = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 5:
                this.m3 = ((System.Windows.Controls.MenuItem)(target));
                return;

            case 6:
                this.edit_users = ((System.Windows.Controls.MenuItem)(target));

            #line 17 "..\..\Admin_log.xaml"
                this.edit_users.Click += new System.Windows.RoutedEventHandler(this.edit_users_Click);

            #line default
            #line hidden
                return;

            case 7:
                this.recipes = ((System.Windows.Controls.MenuItem)(target));

            #line 18 "..\..\Admin_log.xaml"
                this.recipes.Click += new System.Windows.RoutedEventHandler(this.recipes_Click);

            #line default
            #line hidden
                return;

            case 8:
                this.add_prod = ((System.Windows.Controls.MenuItem)(target));

            #line 19 "..\..\Admin_log.xaml"
                this.add_prod.Click += new System.Windows.RoutedEventHandler(this.add_prod_Click);

            #line default
            #line hidden
                return;

            case 9:
                this.exit = ((System.Windows.Controls.MenuItem)(target));

            #line 20 "..\..\Admin_log.xaml"
                this.exit.Click += new System.Windows.RoutedEventHandler(this.exit_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }