Exemple #1
0
        public List<cervice> GetServiceOrder(int order)
        {
            SqlConnection con = new SqlConnection(connectionString);
                SqlCommand cmd = new SqlCommand("GetOrderServices", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@orderid", SqlDbType.Int, 6));
                cmd.Parameters["@orderid"].Value = order;
                List<cervice> news = new List<cervice>();

                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {

                        cervice emp = new cervice(
                      1,
                        (string)reader["name"],
                        (int)reader["cost"],

                       ""
                        );
                        news.Add(emp);

                    }
                    reader.Close();
                    return (news);

                }
                catch
                {
                    throw new ApplicationException("Ошибка данныx.");
                }
                finally
                {
                    con.Close();
                }
        }
Exemple #2
0
        //
        public List<cervice> GetServicesTurCost(int turID)
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand("GetServicesByTur", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@tur", SqlDbType.Int, 4));
            cmd.Parameters["@tur"].Value = turID;
            // Создать коллекцию для всех записей
            List<cervice> services = new List<cervice>();

            try
            {
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    cervice emp = new cervice(
                    (int)reader["serviceID"],
                    (string)reader["name"] + " Цена:" + Convert.ToString((int)reader["cost"]),
                    (int)reader["cost"],
                    "");
                    services.Add(emp);
                }
                reader.Close();
                return services;
            }
            catch
            {
                throw new ApplicationException("Ошибка данныx.");
            }
            finally
            {
                con.Close();
            }
        }
Exemple #3
0
        public int InsertService(cervice emp1)
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand("Insertservice", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@name", SqlDbType.NVarChar, 50));
            cmd.Parameters["@name"].Value = emp1.Name;
            cmd.Parameters.Add(new SqlParameter("@cost", SqlDbType.Int, 6));
            cmd.Parameters["@cost"].Value = emp1.Cost;
            cmd.Parameters.Add(new SqlParameter("@comment", SqlDbType.NVarChar, 200));
            cmd.Parameters["@comment"].Value = emp1.Comment;
            cmd.Parameters.Add(new SqlParameter("@serviceID", SqlDbType.Int, 6));
            cmd.Parameters["@serviceID"].Direction = ParameterDirection.Output;

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                return (int)cmd.Parameters["@serviceID"].Value;
            }
            catch
            {
                return 0;
                throw new ApplicationException("Ошибка данныx.");

            }
            finally
            {
                con.Close();
            }
        }
Exemple #4
0
        public List<cervice> GetAllServices()
        {
            SqlConnection con = new SqlConnection(connectionString);
            SqlCommand cmd = new SqlCommand("GetAllservices", con);
            cmd.CommandType = CommandType.StoredProcedure;

            // Создать коллекцию для всех записей
            List<cervice> services = new List<cervice>();

            try
            {
                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    cervice emp = new cervice(
                    (int)reader["serviceID"],
                    (string)reader["name"],
                    (int)reader["cost"],
                    (string)reader["comment"]);
                    services.Add(emp);
                }
                reader.Close();
                return services;
            }
            catch
            {
                throw new ApplicationException("Ошибка данныx.");
            }
            finally
            {
                con.Close();
            }
        }