private void LoadClothesList(string idClothesRub = "0") { comboBoxClothes.Items.Clear(); clothesList.Clear(); var cList = ModelOrderItems.I().GetClothesList(orderId); var i = 0; foreach (var item in cList) { if (int.Parse(item.Value.Count) > 0) { comboBoxClothes.Items.Add(item.Value.Name + " ( " + item.Value.Price + " )"); clothesList.Add(item.Key, item.Value); if (item.Key == orderClothesId) { comboBoxClothes.SelectedIndex = i; } } i++; } if (comboBoxClothes.SelectedIndex < 0) { comboBoxClothes.SelectedIndex = 0; } comboBoxClothes.SelectedIndex = 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(); } } }
private void buttonDel_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count > 0) { var resault = MessageBox.Show( "Вы уверенны что хотите удалить выбранные строки?", "Подтверждение удаления", MessageBoxButtons.YesNo ); if (resault == DialogResult.Yes) { { for (int i = 0; i < dataGridView.SelectedRows.Count; i++) { ModelOrderItems.I().DeleteById(dataGridView.SelectedRows[i].Cells[0].Value.ToString()); } } LoadItems(itemId); } } else { MessageBox.Show("Выберите одну запись"); } }
public static ModelOrderItems I() { if (Instanse == null) { Instanse = new ModelOrderItems(); } return(Instanse); }
public FormOrderItemEdit(int item_id, string order_id, FormOrderItem f_parent) { InitializeComponent(); fParent = f_parent; itemId = item_id.ToString(); orderId = order_id.ToString(); if (item_id > 0) { var orderItem = ModelOrderItems.I().GetItem(item_id.ToString()); orderCount = orderItem.Count; orderClothesId = orderItem.IdClothes; } else { orderCount = "0"; orderClothesId = "0"; } }
public OrderItem GetItemForOtchet(string id) { { var data = GetById(id); if (data != null) { data.Read(); var item = new OrderItem() { Id = data["id"].ToString(), IdChild = data["id_child"].ToString(), Date = data["date"].ToString() }; item.Child = ModelChildren.I().GetItem(item.IdChild); item.Fio = item.Child.Fio; item.Items = ModelOrderItems.I().GetClothesList(id).Values.ToList(); return(item); } return(null); } }
private void Save_Click(object sender, EventArgs e) { if (itemId == "0") { Console.WriteLine("Добавление записи:" + orderId + ":" + clothesList.ElementAt(comboBoxClothes.SelectedIndex).Value.Count + ":" + comboBoxCount.SelectedIndex.ToString()); if (ModelOrderItems.I().Insert( orderId, clothesList.ElementAt(comboBoxClothes.SelectedIndex).Value.Id, comboBoxCount.SelectedIndex.ToString() )) { itemId = ModelOrderItems.I().GetLustId().ToString(); MessageBox.Show("Запись успешно добавлена"); fParent.LoadItems(orderId); } else { MessageBox.Show("Запись не добавлена, попробуйте еще раз или обратитесь к админестратору"); } } else { if (ModelOrderItems.I().Update( itemId, orderId, clothesList.ElementAt(comboBoxClothes.SelectedIndex).Value.Id, comboBoxCount.SelectedIndex.ToString() )) { MessageBox.Show("Запись успешно обновлена"); fParent.LoadItems(orderId); } else { MessageBox.Show("Запись не обновлена, попробуйте еще раз или обратитесь к админестратору"); } } }