예제 #1
0
        static Role GetRole(string login, string password)
        {
            Role          role = Role.Failed;
            SqlConnection con  = Сonnection.AzureConnection();

            con.Open();
            var command = new SqlCommand("SELECT RoleId FROM Users WHERE email=@email and password=@password", con);

            command.Parameters.AddWithValue("@email", login);
            command.Parameters.AddWithValue("@password", password);

            using (var dataReader = command.ExecuteReader())
            {
                if (dataReader.Read())
                {
                    switch ((string)dataReader["RoleId"])
                    {
                    case "R": role = Role.R; break;

                    case "A": role = Role.A; break;

                    case "C": role = Role.C; break;

                    case "O": role = Role.A; break;

                    default: role = Role.Failed; break;
                    }
                }
            }
            con.Close();
            return(role);
        }
예제 #2
0
        private void Greting()
        {
            SqlConnection con = Сonnection.AzureConnection();

            con.Open();
            string strSQL;

            strSQL = ("SELECt @FirstName=FirstName,@LastName=LastName FROM Users WHERE email=@email and password=@password");
            SqlCommand command = con.CreateCommand();

            command.CommandText = strSQL;
            SqlParameter FirstName, LastName;

            FirstName           = command.Parameters.Add("@FirstName", SqlDbType.VarChar, 20);
            FirstName.Direction = ParameterDirection.Output;
            LastName            = command.Parameters.Add("@LastName", SqlDbType.VarChar, 20);
            LastName.Direction  = ParameterDirection.Output;
            command.Parameters.AddWithValue("@email", Сonnection.Mail);
            command.Parameters.AddWithValue("@password", Сonnection.Password);
            command.ExecuteNonQuery();
            fname = Convert.ToString(FirstName.Value);
            lname = Convert.ToString(LastName.Value);
        }
예제 #3
0
        private void TimerTick(object sender, EventArgs e)
        {
            var counter = new Сonnection();      // Создание экземпляра класса Connection

            timerLabel.Text = counter.GetTime(); // Для доступа к публичному методу возвращаемого типа string
        }