Пример #1
0
        public static void JsonCon(string message)
        {
            PersonsData data = new PersonsData();

            data = JsonConvert.DeserializeObject <PersonsData>(message);
            PutPersonsData(data);
        }
Пример #2
0
        public static void PutPersonsData(PersonsData data)
        {
            string sConnStr = new SqlConnectionStringBuilder
            {
                DataSource         = @"LAPTOP-1GAL0TI1\SQLEXPRESS",
                InitialCatalog     = "FinishDB",
                IntegratedSecurity = true,
            }.ConnectionString;

            ClearTable(sConnStr);
            WriteDataMS(sConnStr, @"INSERT INTO CategoryProduct (name_categ) VALUES(@name_categ)", "@name_categ", "", "", "", "", data.categor_product);
            WriteDataMS(sConnStr, @"INSERT INTO CategoryCustomer (name_category) VALUES(@name_category)", "@name_category", "", "", "", "", data.categor_customer);
            WriteDataMS2(sConnStr, @"INSERT INTO InfProducts (name_product, price, id_categ) VALUES(@name_product, @price, @id_categ)", "@name_product",
                         "@price", "@id_categ", "", @" SELECT id FROM CategoryProduct WHERE name_categ = '", data.name_product);
            WriteDataMS(sConnStr, @"INSERT INTO Customer (name_customer, categoryid) 
                                        VALUES(@name_customer,  @id_category)",
                        "@name_customer", "@id_category", "", @" SELECT id FROM CategoryCustomer WHERE name_category = '", "", data.name_customer);
            WriteDataMS(sConnStr, @"INSERT INTO NameOrder (id_order, id_product, customerid) 
                                        VALUES(@id_order,  @id_product, @id_customer)",
                        "@id_order", "@id_product", "@id_customer", @"select id from InfProducts where name_product = '", @"select id from Customer where name_customer = '", data.id_order);
        }