Пример #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     using (Restaurant_businessEntities rb = new Restaurant_businessEntities(s))
     {
         company company = rb.company.Where(x => x.index_company == maskedTextIndexCompany.Text).FirstOrDefault();
         if (company == null)
         {
             MessageBox.Show("Ошибка");
         }
         else
         {
             rb.company.Where(x => x.index_company == maskedTextIndexCompany.Text).FirstOrDefault().name          = textNameCompany.Text;
             rb.company.Where(x => x.index_company == maskedTextIndexCompany.Text).FirstOrDefault().index_company = maskedTextIndexCompany.Text;
             rb.SaveChanges();
             MessageBox.Show("Запись изменена");
         }
     }
 }
Пример #2
0
 private void button10_Click(object sender, EventArgs e)
 {
     using (Restaurant_businessEntities rb = new Restaurant_businessEntities(s))
     {
         try
         {
             company company = rb.company.Where(x => x.name == CompanuAgent.Text).FirstOrDefault();
             if (company == null)
             {
                 label19.Text = "";
                 MessageBox.Show("нет такой компании");
             }
             else
             {
                 label19.Text = Convert.ToString(company.id);
             }
         }
         catch
         {
             MessageBox.Show("Ошибка");
         }
     }
 }
Пример #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();
                    }
                }
            }
            //Агент
        }