예제 #1
0
파일: Sell.xaml.cs 프로젝트: Konversys/ATT
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (int.Parse(count.Text) > product.count)
     {
         MessageBox.Show("Введите меньшее количество для продажи", "Ошибка");
     }
     else
     {
         if (int.Parse(count.Text) == 0)
         {
             MainWindow.sellList.RemoveAll(x => x.id == product.id);
         }
         else if (MainWindow.sellList.Where(x => x.id == product.id).Count() == 0)
         {
             product.sell = int.Parse(count.Text);
             MainWindow.sellList.Add(product);
         }
         else
         {
             for (int i = 0; i < MainWindow.sellList.Count; i++)
             {
                 var item = MainWindow.sellList[i];
                 if (item.id == product.id)
                 {
                     ProductATT temp = item;
                     temp.sell = int.Parse(count.Text);
                     MainWindow.sellList[i] = temp;
                     break;
                 }
             }
         }
     }
     this.Close();
 }
예제 #2
0
파일: Sell.xaml.cs 프로젝트: Konversys/ATT
 public Sell()
 {
     InitializeComponent();
     table.Items.Clear();
     product = DBQueries.GetProductATT(MainWindow.att, MainWindow.product.id);
     table.Items.Add(product);
     count.Text = MainWindow.product.sell.ToString();
 }
예제 #3
0
파일: DBQueries.cs 프로젝트: Konversys/ATT
        public static List <ProductATT> GetProductsATT(int att)
        {
            List <ProductATT> products = new List <ProductATT>();
            string            query    =
                "SELECT att_list.id, product.title, active.title as active, box.title as box, " +
                "product.count as inside, measures.title as measures, creator.title as creator, " +
                "form.title as form, type.title as type, product.recipe as recipe, att_list.count as count, " +
                "att_list.price as price, att_list.date as date, ADDDATE(att_list.date, product.valid) as valid, att_list.arrival as arrival " +
                "FROM att_list, product, box, creator, form, type, active, measures " +
                "WHERE att_list.product = product.id AND product.active = active.id " +
                "AND product.box = box.id AND product.creator = creator.id " +
                "AND product.measures = measures.id AND product.form = form.id " +
                "AND product.type = type.id AND NOT ISNULL(ADDDATE(att_list.date, product.valid)) AND att_list.att = " + att;

            DBHelper.GetConnect().Open();
            MySqlCommand command = DBHelper.GetConnect().CreateCommand();

            command.CommandText = query;
            DbDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                ProductATT product = new ProductATT()
                {
                    id       = reader.GetInt32(0),
                    title    = reader.GetString(1),
                    active   = reader.GetString(2),
                    box      = reader.GetString(3),
                    inside   = reader.GetString(4),
                    measures = reader.GetString(5),
                    creator  = reader.GetString(6),
                    form     = reader.GetString(7),
                    type     = reader.GetString(8),
                    count    = reader.GetInt32(10),
                    price    = reader.GetDouble(11),
                    date     = reader.GetString(12).Split(' ')[0],
                    valid    = reader.GetString(13).Split(' ')[0],
                    arrival  = reader.GetString(14).Split(' ')[0],
                };
                if (reader.GetBoolean(9))
                {
                    product.recipe = "Да";
                }
                else
                {
                    product.recipe = "Нет";
                }
                products.Add(product);
            }
            DBHelper.GetConnect().Close();
            return(products);
        }
예제 #4
0
파일: DBQueries.cs 프로젝트: Konversys/ATT
        public static ProductATT GetProductATT(int att, int product_id)
        {
            ProductATT product = new ProductATT();
            string     query   = "SELECT att_list.id, product.title, active.title as active, box.title as box, " +
                                 "product.count as inside, measures.title as measures, creator.title as creator, " +
                                 "form.title as form, type.title as type, product.recipe as recipe, att_list.count as count, " +
                                 "att_list.price as price, att_list.date as date, ADDDATE(att_list.date, product.valid) as valid, att_list.arrival as arrival " +
                                 "FROM att_list, product, box, creator, form, type, active, measures " +
                                 "WHERE att_list.product = product.id AND product.active = active.id " +
                                 "AND product.box = box.id AND product.creator = creator.id " +
                                 "AND product.measures = measures.id AND product.form = form.id " +
                                 $"AND product.type = type.id AND att_list.att = {att} " +
                                 $"AND att_list.id = {product_id}";

            DBHelper.GetConnect().Open();
            MySqlCommand command = DBHelper.GetConnect().CreateCommand();

            command.CommandText = query;
            DbDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                product.id       = reader.GetInt32(0);
                product.title    = reader.GetString(1);
                product.active   = reader.GetString(2);
                product.box      = reader.GetString(3);
                product.inside   = reader.GetString(4);
                product.measures = reader.GetString(5);
                product.creator  = reader.GetString(6);
                product.form     = reader.GetString(7);
                product.type     = reader.GetString(8);
                product.count    = reader.GetInt32(10);
                product.price    = reader.GetDouble(11);
                product.date     = reader.GetString(12).Split(' ')[0];
                product.valid    = reader.GetString(13).Split(' ')[0];
                product.arrival  = reader.GetString(14).Split(' ')[0];
                if (reader.GetBoolean(9))
                {
                    product.recipe = "Да";
                }
                else
                {
                    product.recipe = "Нет";
                }
            }
            DBHelper.GetConnect().Close();
            return(product);
        }