Beispiel #1
0
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                OrderSet order = new OrderSet();

                if (comboBoxOrder.SelectedItem != null)
                {
                    order.IdClient = Convert.ToInt32(comboBoxOrder.SelectedItem.ToString().Split('.')[0]);
                }
                else
                {
                    throw new Exception("Обязательные данные не заполнены");
                }

                if (comboBoxStatus.SelectedItem != null)
                {
                    order.Status = comboBoxStatus.SelectedItem.ToString();
                }
                else
                {
                    order.Status = null;
                }


                Program.litRes.OrderSet.Add(order);
                Program.litRes.SaveChanges();
                ShowOrder();
            }
            catch (Exception ex) { MessageBox.Show("" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); }
        }
Beispiel #2
0
        private void ListViewOrder_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewOrder.SelectedItems.Count == 1)
            {
                OrderSet orderSet = listViewOrder.SelectedItems[0].Tag as OrderSet;

                comboBoxOrder.Text = orderSet.IdClient.ToString() + " " + orderSet.ClientSet.LastName +
                                     " " + orderSet.ClientSet.FirstName + " " + orderSet.ClientSet.MiddleName + " " +
                                     orderSet.ClientSet.IdBook.ToString() + " " + orderSet.ClientSet.BookSet.Title;
                comboBoxStatus.Text = orderSet.Status;
            }
            else
            {
                comboBoxOrder.SelectedItem  = null;
                comboBoxStatus.SelectedItem = null;
            }
        }
Beispiel #3
0
        private void ButtonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (listViewOrder.SelectedItems.Count == 1)
                {
                    OrderSet order = listViewOrder.SelectedItems[0].Tag as OrderSet;

                    Program.litRes.OrderSet.Remove(order);
                    Program.litRes.SaveChanges();
                    ShowOrder();
                }
                comboBoxStatus.Text = "";
                comboBoxOrder.Text  = "";
            }
            catch
            {
                MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);;
            }
        }