Example #1
0
        public bool OtrOcenZakaz(int id_zakaz)
        {
            connection.Open();

            string     con = "Select * From  MyTableZakazNews Where ID_zakaz=@id_zakaz ";
            SqlCommand com = new SqlCommand(con, connection);

            com.Parameters.Add("@id_zakaz", SqlDbType.Int).Value = id_zakaz;

            SqlDataReader reader = com.ExecuteReader();

            TableZakazNews News = new TableZakazNews();

            while (reader.Read())
            {
                News.otr_ozaenk = (int)reader["otr_ozaenk"];
            }
            reader.Close();
            int otrOc = News.otr_ozaenk;

            otrOc--;


            string     query   = @"UPDATE MyTableZakazNews
                             SET [otr_ozaenk] = @otr_ozaenk             
                             WHERE [ID_zakaz] = @id";
            SqlCommand command = new SqlCommand(query, connection);

            command.Parameters.AddWithValue("@id", id_zakaz);
            command.Parameters.AddWithValue("@otr_ozaenk", otrOc);
            command.ExecuteNonQuery();

            return(true);
        }
Example #2
0
        public List <TableZakazNews> SelectZakazNews()
        {
            connection.Open();
            string     query   = "SELECT * FROM MyTableZakazNews ";
            SqlCommand command = new SqlCommand(query, connection);

            SqlDataReader         reader = command.ExecuteReader();
            List <TableZakazNews> list   = new List <TableZakazNews>();

            while (reader.Read())
            {
                TableZakazNews zakaz = new TableZakazNews();
                zakaz.Id_zakaz   = (int)reader["ID_zakaz"];
                zakaz.user_name  = reader["user_nam"].ToString();
                zakaz.email      = reader["email"].ToString();
                zakaz.name_news  = reader["name_news"].ToString();
                zakaz.date_zakaz = (DateTime)reader["date_zakaz"];
                zakaz.pol_ozenk  = (int)reader["pol_ozenk"];
                zakaz.otr_ozaenk = (int)reader["otr_ozaenk"];


                list.Add(zakaz);
            }

            return(list);
        }
Example #3
0
        public bool GreateNews(string name_news, string content, string image, string typess)
        {
            string user_nam = HttpContext.Current.User.Identity.Name.ToString();

            DateTime date      = DateTime.Today;
            int      pol_ozenk = 0;
            int      otr_ocenk = 0;

            connection.Open();
            string     query   = "INSERT INTO [MyTableAddNews]([user_nam],[name_news],[date_publich],[content],[img],[typess],[pol_ozenk],[otr_ozaenk]) VALUES(@user_nam , @name, @date,@content,@img,@typess, @pol_ozenk, @otr_ocenk)";
            SqlCommand command = new SqlCommand(query, connection);

            command.Parameters.Add("@user_nam", SqlDbType.VarChar, 50).Value = user_nam;

            command.Parameters.Add("@name", SqlDbType.VarChar, 100).Value   = name_news;
            command.Parameters.Add("@date", SqlDbType.DateTime).Value       = date;
            command.Parameters.Add("@content", SqlDbType.VarChar).Value     = content;
            command.Parameters.Add("@img", SqlDbType.VarChar).Value         = image;
            command.Parameters.Add("@typess", SqlDbType.VarChar, 100).Value = typess;
            command.Parameters.Add("@pol_ozenk", SqlDbType.Int).Value       = pol_ozenk;
            command.Parameters.Add("@otr_ocenk", SqlDbType.Int).Value       = otr_ocenk;
            command.ExecuteNonQuery();


            string     con = "Select * From  MyTableZakazNews ";
            SqlCommand com = new SqlCommand(con, connection);


            SqlDataReader reader = com.ExecuteReader();

            while (reader.Read())
            {
                TableZakazNews News = new TableZakazNews();
                string         news = News.name_news = (string)reader["name_news"];
                if (news.Equals(name_news))
                {
                    SendMailMessage(name_news, user_nam);
                }
            }
            return(true);
        }