示例#1
0
 public void SetDefaultFieldValues()
 {
     textBoxName.Text         = "";
     textBoxEdIzm.Text        = "";
     textBoxSrok.Text         = "";
     textBoxNormaVidachi.Text = "";
     if (itemId == 0)
     {
         return;
     }
     clothesItem = ModelClothes.I().GetItem(itemId.ToString());
     if (clothesItem != null)
     {
         Console.WriteLine(itemId);
         textBoxName.Text         = clothesItem.Name;
         textBoxEdIzm.Text        = clothesItem.EdIzm;
         textBoxSrok.Text         = clothesItem.SrokNoski;
         textBoxNormaVidachi.Text = clothesItem.NormaVidachi;
     }
     else
     {
         MessageBox.Show("Произошла ошибка, обратитесь к админестратоору");
         itemId           = 0;
         textBoxName.Text = "";
     }
     SetRubs();
 }
示例#2
0
        public void LoadItems(String idOrder)
        {
            dataGridView.Rows.Clear();
            OleDbDataReader items = ModelOrderItems.I().GetItems("id_order = " + idOrder + " order by id ASC");

            if (items != null)
            {
                int rowNumber;
                while (items.Read())
                {
                    string group_name = "";
                    if (items["id_clothes"].ToString() != "0")
                    {
                        foreach (var clothesRub in ModelClothes.I().ClothesTree)
                        {
                            if (clothesRub.Value.ContainsKey(items["id_clothes"].ToString()))
                            {
                                group_name = " / " + clothesRub.Value[items["id_clothes"].ToString()].Name;
                                group_name = ModelClothes.I().ClothesTree["0"][clothesRub.Value[items["id_clothes"].ToString()].PId].Name + group_name;
                            }
                        }
                    }
                    rowNumber = dataGridView.Rows.Add();
                    dataGridView.Rows[rowNumber].Cells["id"].Value      = items["id"].ToString();
                    dataGridView.Rows[rowNumber].Cells["clothes"].Value = group_name;
                    dataGridView.Rows[rowNumber].Cells["count"].Value   = items["count"].ToString();
                }
            }
        }
示例#3
0
        //Список доступной одежды
        public Dictionary <string, OrderClothesItem> GetClothesList(string idOrder)
        {
            var res   = new Dictionary <string, OrderClothesItem>();
            var items = QueryResult(
                "select tn.id, tn.price, tn.name, tn.id_clothes,tn.count, " +
                "( " +
                "select sum(oi.count) from order_items as oi  " +
                "where oi.id_clothes=tn.id_clothes and oi.id_order<>" + idOrder +
                " )" +
                " as `count_use`" +
                "from `tovar_nakladnaya_ed` as tn");

            while (items.Read())
            {
                var count = items["count"].ToString();
                if (items["count_use"].ToString() != "")
                {
                    count = (Int32.Parse(items["count"].ToString()) - Int32.Parse(items["count_use"].ToString())).ToString();
                }
                res.Add(
                    items["id_clothes"].ToString(),
                    new OrderClothesItem()
                {
                    Id      = items["id_clothes"].ToString(),
                    Name    = items["name"].ToString(),
                    Price   = items["price"].ToString(),
                    Count   = count.ToString(),
                    Clothes = ModelClothes.I().GetItemForOrder(items["id_clothes"].ToString())
                }
                    );
            }
            return(res);
        }
        public Dictionary <string, NaklodnayaClothesItem> GetItems(string nId)
        {
            var items = base.GetItems("id_naklad=" + nId);

            if (items != null)
            {
                var rez = new Dictionary <string, NaklodnayaClothesItem>();
                String[,] rubs_list     = ModelClothes.I().GetRubs();
                String[,] sub_rubs_list = ModelClothes.I().GetSubRubs();
                int rowNumber;
                while (items.Read())
                {
                    string group_name = "";
                    if (items["id_clothes"].ToString() != "0")
                    {
                        for (int i = 0; i < sub_rubs_list.Length; i++)
                        {
                            if (sub_rubs_list[i, 0] == items["id_clothes"].ToString())
                            {
                                group_name = "/" + sub_rubs_list[i, 2];
                                for (int j = 0; j < rubs_list.Length; j++)
                                {
                                    if (sub_rubs_list[i, 1] == rubs_list[j, 0])
                                    {
                                        group_name = rubs_list[j, 1] + group_name;
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    rez.Add(
                        items["id"].ToString(),
                        new NaklodnayaClothesItem()
                    {
                        Id        = items["id"].ToString(),
                        IdClothes = items["id_clothes"].ToString(),
                        IdNaklad  = items["id_naklad"].ToString(),
                        Count     = items["count"].ToString(),
                        Name      = items["name"].ToString(),
                        GroupName = group_name,
                        Price     = items["price"].ToString(),
                    }
                        );
                }
                return(rez);
            }
            return(null);
        }
示例#5
0
 public void SetRubs()
 {
     comboBoxParent.Items.Clear();
     rubList.Clear();
     rubList.Add(new ClothesTreeItem()
     {
         Id = "0", Name = "Пусто"
     });
     comboBoxParent.Items.Add("Пусто");
     foreach (var rubsList in ModelClothes.I().ClothesTree["0"])
     {
         comboBoxParent.Items.Add(rubsList.Value.Name);
         rubList.Add(rubsList.Value);
     }
     comboBoxParent.SelectedIndex = 0;
 }
示例#6
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (ValidateFormFields())
            {
                if (itemId == 0)
                {
                    var     rubId = comboBoxParent.SelectedIndex > 0?rubList[comboBoxParent.SelectedIndex].Id:"0";
                    Boolean t     = ModelClothes.I().Insert(
                        textBoxName.Text,
                        rubId,
                        textBoxEdIzm.Text,
                        textBoxSrok.Text,
                        textBoxNormaVidachi.Text
                        );

                    if (t)
                    {
                        MessageBox.Show("Запись успешно добавленна");
                    }
                    else
                    {
                        MessageBox.Show("Запись не добавленна, обратитесь к админестратору");
                    }
                }
                else
                {
                    Boolean t = ModelClothes.I().Update(
                        itemId.ToString(),
                        textBoxName.Text,
                        rubList[comboBoxParent.SelectedIndex].Id,
                        textBoxEdIzm.Text,
                        textBoxSrok.Text,
                        textBoxNormaVidachi.Text
                        );
                    if (t)
                    {
                        MessageBox.Show("Запись успешно добавленна");
                    }
                    else
                    {
                        MessageBox.Show("Запись не добавленна, обратитесь к админестратору");
                    }
                }
                fParent.Search();
            }
        }
示例#7
0
        public ClothesItem GetItem(string id)
        {
            OleDbDataReader item = ModelClothes.I().GetById(id.ToString());

            if (item != null)
            {
                item.Read();
                var rez = new ClothesItem()
                {
                    Id           = id.ToString(),
                    PId          = item["p_id"].ToString(),
                    Name         = item["name"].ToString(),
                    EdIzm        = item["ed_izm"].ToString(),
                    SrokNoski    = item["srok_noski"].ToString(),
                    NormaVidachi = item["norma_vidachi"].ToString()
                };
                return(rez);
            }
            return(null);
        }
示例#8
0
 protected void LoadValues()
 {
     comboBoxParent.Items.Clear();
     rubList = ModelClothes.I().GetRubs();
     if (itemId != 0)
     {
         OleDbDataReader it = ModelPrihodnayaNakladnayaIt.I().GetById(itemId.ToString());
         if (it != null)
         {
             it.Read();
             textName.Text  = it["name"].ToString();
             textCount.Text = it["count"].ToString();
             textCena.Text  = it["price"].ToString();
             clothesId      = it["id_clothes"].ToString();
             LoadComboBoxValue(it["id_clothes"].ToString());
         }
     }
     else
     {
         LoadComboBoxValue("0");
     }
 }
示例#9
0
 protected void LoadComboBoxValue(String id_clothes)
 {
     if (id_clothes != "0")
     {
         OleDbDataReader clothes = ModelClothes.I().GetById(id_clothes);
         if (clothes != null)
         {
             clothes.Read();
             for (int i = 0; i < rubList.Length / 2; i++)
             {
                 if (rubList[i, 1] != "")
                 {
                     comboBoxParent.Items.Add(rubList[i, 1]);
                     if (rubList[i, 0] == clothes["p_id"].ToString())
                     {
                         comboBoxParent.SelectedIndex = i;
                     }
                 }
             }
             if (comboBoxParent.SelectedIndex < 0)
             {
                 comboBoxParent.SelectedIndex = 0;
             }
         }
     }
     else
     {
         for (int i = 0; i < rubList.Length / 2; i++)
         {
             if (rubList[i, 1] != "")
             {
                 comboBoxParent.Items.Add(rubList[i, 1]);
             }
         }
         comboBoxParent.SelectedIndex = 0;
     }
     LoadSubRub(rubList[comboBoxParent.SelectedIndex, 0]);
 }
示例#10
0
 public void SetRubs()
 {
     comboBoxParent.Items.Clear();
     rubList.Clear();
     rubList.Add(new ClothesTreeItem()
     {
         Id = "0", Name = "Пусто"
     });
     comboBoxParent.Items.Add("Пусто");
     foreach (var rubsList in ModelClothes.I().ClothesTree["0"])
     {
         comboBoxParent.Items.Add(rubsList.Value.Name);
         rubList.Add(rubsList.Value);
         if (clothesItem != null && clothesItem.PId == rubsList.Value.Id)
         {
             comboBoxParent.SelectedIndex = comboBoxParent.Items.Count - 1;
         }
     }
     if (comboBoxParent.SelectedIndex < 0)
     {
         comboBoxParent.SelectedIndex = 0;
     }
 }
示例#11
0
        public void Search()
        {
            dataGridViewClothesSearch.Rows.Clear();
            if (rubList.Count < comboBoxParent.SelectedIndex)
            {
                Console.WriteLine("Неправильный индекс рубрики");
                return;
            }

            var clothesList = ModelClothes.I().Search(textBoxSearch.Text, rubList[comboBoxParent.SelectedIndex].Id.ToString());

            if (clothesList.Count == 0)
            {
                return;
            }
            for (var i = 0; i < clothesList.Count; i++)
            {
                dataGridViewClothesSearch.Rows.Add();
                dataGridViewClothesSearch.Rows[i].Cells["id"].Value     = clothesList[i].Id;
                dataGridViewClothesSearch.Rows[i].Cells["parent"].Value = clothesList[i].ParentName;
                dataGridViewClothesSearch.Rows[i].Cells["name"].Value   = clothesList[i].Name;
            }
        }
示例#12
0
 private void LoadSubRub(String id_rub)
 {
     comboBoxClothes.Items.Clear();
     if (id_rub != "0")
     {
         subRubList       = ModelClothes.I().GetSubRubs(id_rub);
         subRubCurentList = new String[subRubList.Length / 3, 3];
         for (int i = 0; i < subRubList.Length / 3; i++)
         {
             subRubCurentList[i, 0] = subRubList[i, 0];
             subRubCurentList[i, 1] = subRubList[i, 1];
             subRubCurentList[i, 2] = subRubList[i, 2];
             comboBoxClothes.Items.Add(subRubList[i, 2]);
             if (subRubList[i, 0] == clothesId)
             {
                 comboBoxClothes.SelectedIndex = i;
             }
         }
         if (comboBoxClothes.SelectedIndex < 0)
         {
             comboBoxClothes.SelectedIndex = 0;
         }
     }
 }
示例#13
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            Int32 selectedRowCount = dataGridViewClothesSearch.SelectedRows.Count;

            if (selectedRowCount > 0)
            {
                var resault = MessageBox.Show(
                    "Вы уверенны что хотите удалить выбранные строки?",
                    "Подтверждение удаления",
                    MessageBoxButtons.YesNo
                    );
                if (resault == DialogResult.Yes)
                {
                    String delet_id_str = GetIdSetFromSelectedRows();

                    ModelClothes.I().DeleteByIdSet(delet_id_str);
                    buttonSearch.PerformClick();
                }
            }
            else
            {
                MessageBox.Show("Выберите хотя бы одну строку");
            }
        }