Ejemplo n.º 1
0
 private void numericUpDown1_ValueChanged(object sender, EventArgs e)
 {
     using (Restaurant_businessEntities rb = new Restaurant_businessEntities(s))
     {
         agent agent = rb.agent.Where(x => x.id == numericIDAgent.Value).FirstOrDefault();
         if (agent == null)
         {
             MessageBox.Show("Ошибка");
         }
         else
         {
             fnameAgent.Text   = agent.lastmane;
             nameAgent.Text    = agent.firstname;
             onameAgent.Text   = agent.midname;
             label19.Text      = Convert.ToString(agent.id_company);
             CompanuAgent.Text = rb.company.Find(Convert.ToInt32(label19.Text)).name;
         }
     }
 }
Ejemplo n.º 2
0
 private void button5_Click(object sender, EventArgs e)
 {
     using (Restaurant_businessEntities rb = new Restaurant_businessEntities(s))
     {
         agent agent = rb.agent.Where(x => x.id == numericIDAgent.Value).FirstOrDefault();
         if (agent == null)
         {
             MessageBox.Show("Ошибка");
         }
         else
         {
             rb.agent.Where(x => x.id == numericIDAgent.Value).FirstOrDefault().lastmane  = fnameAgent.Text;
             rb.agent.Where(x => x.id == numericIDAgent.Value).FirstOrDefault().firstname = nameAgent.Text;
             rb.agent.Where(x => x.id == numericIDAgent.Value).FirstOrDefault().midname   = onameAgent.Text;
             rb.SaveChanges();
             MessageBox.Show("Запись изменена");
         }
     }
 }
Ejemplo n.º 3
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            string str = Tabls.Text;

            if (str == "Агент")
            {
                using (Restaurant_businessEntities rb = new Restaurant_businessEntities(s))
                {
                    try
                    {
                        int          a     = Convert.ToInt32(numericUpDownMain.Value);
                        List <agent> lists = rb.agent.ToList();
                        agent        agent = rb.agent.Where(x => x.id == a).FirstOrDefault();
                        if (agent == null)
                        {
                            MessageBox.Show("Нет такого значения");
                        }
                        else
                        {
                            rb.agent.Remove(agent);
                            rb.SaveChanges();
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Нет прав");
                    }
                }
            }
            else if (str == "Компания")
            {
                using (Restaurant_businessEntities rb = new Restaurant_businessEntities(s))
                {
                    company company = rb.company.Where(x => x.id == numericUpDownMain.Value).FirstOrDefault();
                    if (company == null)
                    {
                        MessageBox.Show("Нет такого значения");
                    }
                    else
                    {
                        rb.company.Remove(company);
                        rb.SaveChanges();
                    }
                }
            }
            else if (str == "Заказ")
            {
                using (Restaurant_businessEntities rb = new Restaurant_businessEntities(s))
                {
                    order order = rb.order.Where(x => x.id == numericUpDownMain.Value).FirstOrDefault();
                    if (order == null)
                    {
                        MessageBox.Show("Нет такого значения");
                    }
                    else
                    {
                        rb.order.Remove(order);
                        rb.SaveChanges();
                    }
                }
            }
            else if (str == "Продукт")
            {
                using (Restaurant_businessEntities rb = new Restaurant_businessEntities(s))
                {
                    product product = rb.product.Where(x => x.id == numericUpDownMain.Value).FirstOrDefault();
                    if (product == null)
                    {
                        MessageBox.Show("Нет такого значения");
                    }
                    else
                    {
                        rb.product.Remove(product);
                        rb.SaveChanges();
                    }
                }
            }
            //Агент
        }