Exemplo n.º 1
0
        private void Insert_Model()
        {
            ModelInsert f = new ModelInsert(ModelInsert.FormType.Insert);

            if (f.ShowDialog() == DialogResult.OK)
            {
                using (ModelCarRental MRC = new ModelCarRental())
                {
                    Модели Item = new Модели();
                    Item.Название_модели = f.CModel;
                    Item.Код_марки       = f.CMarka;
                    Item.Код_типа        = f.CType;

                    MRC.Модели.Add(Item);
                    MRC.SaveChanges();

                    ListViewItem lvi = new ListViewItem(new[]
                    {
                        MRC.Марки.Find(Item.Код_марки).Название_марки,
                        MRC.Модели.Find(Item.Код_модели).Название_модели,
                        MRC.Типы.Find(Item.Код_типа).Название_типа,
                    });
                    lvi.Tag = Item;
                    this.LView.Items.Add(lvi);
                }
            }
        }
Exemplo n.º 2
0
        private void Insert_CarRental()
        {
            CarRentalInsert f = new CarRentalInsert(CarRentalInsert.FormType.Insert);

            if (f.ShowDialog() == DialogResult.OK)
            {
                using (ModelCarRental MRC = new ModelCarRental())
                {
                    Автопрокаты Item = new Автопрокаты();
                    Item.Название_автопроката    = f.CName;
                    Item.Собственник_автопроката = f.COwner;
                    Item.Адрес_автопроката       = f.CAddress;
                    Item.асчетный_счет           = f.CAccount;
                    Item.Код_банка = f.CBank;

                    MRC.Автопрокаты.Add(Item);
                    MRC.SaveChanges();

                    ListViewItem lvi = new ListViewItem(new[]
                    {
                        Item.Название_автопроката,
                        Item.Собственник_автопроката,
                        Item.Адрес_автопроката,
                        Item.асчетный_счет,
                        MRC.Банки.Find(Item.Код_банка).Название_банка,
                    });
                    lvi.Tag = Item;
                    this.LView.Items.Add(lvi);
                    LView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    LView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                }
            }
        }
Exemplo n.º 3
0
        private void Update_Model()
        {
            foreach (ListViewItem selectedItem in LView.SelectedItems)
            {
                Модели      Item = (Модели)selectedItem.Tag;
                ModelInsert f    = new ModelInsert(ModelInsert.FormType.Update)
                {
                    LastModel  = Item.Название_модели,
                    indexMarka = Item.Код_марки,
                    CModel     = Item.Название_модели,
                    indexType  = Item.Код_типа,
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    using (ModelCarRental MRC = new ModelCarRental())
                    {
                        MRC.Модели.Attach(Item);
                        Item.Код_марки       = f.CMarka;
                        Item.Название_модели = f.CModel;
                        Item.Код_типа        = f.CType;
                        MRC.SaveChanges();

                        selectedItem.SubItems[0].Text = MRC.Марки.Find(Item.Код_марки).Название_марки;
                        selectedItem.SubItems[1].Text = f.CModel;
                        selectedItem.SubItems[2].Text = MRC.Типы.Find(Item.Код_типа).Название_типа;

                        selectedItem.Tag = Item;

                        LView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                        LView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                    }
                }
            }
        }
Exemplo n.º 4
0
 private void Delete_Model()
 {
     try
     {
         foreach (ListViewItem selectedItem in LView.SelectedItems)
         {
             using (ModelCarRental MRC = new ModelCarRental())
             {
                 Модели n = (Модели)selectedItem.Tag;
                 if (MRC.Автомобили.Find(n.Код_модели) != null)
                 {
                     throw new Exception("error");
                 }
                 ;
                 MRC.Модели.Attach(n);
                 MRC.Модели.Remove(n);
                 MRC.SaveChanges();
                 LView.Items.Remove(selectedItem);
             }
         }
     }
     catch
     {
         MessageBox.Show("Ошибка удаления. Сначала удалите все привязанные объекты!");
     }
 }
Exemplo n.º 5
0
        private void Update_Car()
        {
            foreach (ListViewItem selectedItem in LView.SelectedItems)
            {
                Автомобили Item = (Автомобили)selectedItem.Tag;
                CarInsert  f    = new CarInsert(CarInsert.FormType.Update)
                {
                    //LastName = Item.Название_автопроката,
                    indexCarRental = Item.Код_автопроката,
                    indexMarka     = Item.Модели.Марки.Код_марки,
                    indexModel     = Item.Код_модели,
                    indexColor     = Convert.ToInt32(Item.Основной_цвет),
                    LastCondition  = Item.Состояние,
                    indexDealer    = Item.Код_диллера,
                    CPrice         = Item.Цена_за_сутки.ToString(),
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    using (ModelCarRental MRC = new ModelCarRental())
                    {
                        MRC.Автомобили.Attach(Item);
                        Item.Код_модели      = f.Model;
                        Item.Код_автопроката = f.CCarRental;
                        Item.Основной_цвет   = f.CColor.ToString();
                        Item.Состояние       = f.CСondition;
                        Item.Код_диллера     = f.CDealer;
                        Item.Цена_за_сутки   = Convert.ToInt32(f.CPrice);
                        MRC.SaveChanges();

                        selectedItem.SubItems[1].Text        = MRC.Автопрокаты.Find(Item.Код_автопроката).Название_автопроката;
                        selectedItem.SubItems[2].Text        = MRC.Марки.Find(f.CMarka).Название_марки;
                        selectedItem.SubItems[3].Text        = MRC.Модели.Find(Item.Код_модели).Название_модели;
                        selectedItem.UseItemStyleForSubItems = false;
                        selectedItem.SubItems[4].BackColor   = System.Drawing.Color.FromArgb(f.CColor);
                        selectedItem.SubItems[5].Text        = f.CСondition;
                        selectedItem.SubItems[6].Text        = MRC.Дилеры.Find(Item.Код_диллера).Название_фирмы;
                        selectedItem.SubItems[7].Text        = Convert.ToString(f.CPrice);

                        selectedItem.Tag = Item;

                        LView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                        LView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void Insert_Car()
        {
            CarInsert f = new CarInsert(CarInsert.FormType.Insert);

            if (f.ShowDialog() == DialogResult.OK)
            {
                using (ModelCarRental MRC = new ModelCarRental())
                {
                    Автомобили Item = new Автомобили();
                    foreach (Автомобили c in MRC.Автомобили)
                    {
                        ;
                    }
                    int count = MRC.Автомобили.Local.Count;
                    Item.Номер_автомобиля = count + 1;
                    Item.Код_автопроката  = f.CCarRental;
                    Item.Код_модели       = f.Model;
                    Item.Основной_цвет    = f.CColor.ToString();
                    Item.Состояние        = f.CСondition;
                    Item.Код_диллера      = f.CDealer;
                    Item.Цена_за_сутки    = Convert.ToInt32(f.CPrice);

                    MRC.Автомобили.Add(Item);
                    MRC.SaveChanges();

                    ListViewItem lvi = new ListViewItem(new[]
                    {
                        Item.Номер_автомобиля.ToString(),
                        MRC.Автопрокаты.Find(Item.Код_автопроката).Название_автопроката,
                        MRC.Марки.Find(f.CMarka).Название_марки,
                        MRC.Модели.Find(Item.Код_модели).Название_модели,
                        "",
                        Item.Состояние,
                        MRC.Дилеры.Find(Item.Код_диллера).Название_фирмы,
                        Item.Цена_за_сутки.ToString(),
                    });
                    lvi.Tag = Item;
                    lvi.UseItemStyleForSubItems = false;
                    lvi.SubItems[4].BackColor   = System.Drawing.Color.FromArgb(f.CColor);
                    this.LView.Items.Add(lvi);
                }
            }
        }
Exemplo n.º 7
0
        private void Update_CarRental()
        {
            foreach (ListViewItem selectedItem in LView.SelectedItems)
            {
                Автопрокаты     Item = (Автопрокаты)selectedItem.Tag;
                CarRentalInsert f    = new CarRentalInsert(CarRentalInsert.FormType.Update)
                {
                    LastName = Item.Название_автопроката,
                    CName    = Item.Название_автопроката,
                    COwner   = Item.Собственник_автопроката,
                    CAddress = Item.Адрес_автопроката,
                    CAccount = Item.асчетный_счет,
                    index    = Item.Банки.Код_банка,
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    using (ModelCarRental MRC = new ModelCarRental())
                    {
                        MRC.Автопрокаты.Attach(Item);
                        Item.Название_автопроката    = f.CName;
                        Item.Собственник_автопроката = f.COwner;
                        Item.Адрес_автопроката       = f.CAddress;
                        Item.асчетный_счет           = f.CAccount;
                        Item.Код_банка = f.CBank;
                        MRC.SaveChanges();

                        selectedItem.SubItems[0].Text = f.CName;
                        selectedItem.SubItems[1].Text = f.COwner;
                        selectedItem.SubItems[2].Text = f.CAddress;
                        selectedItem.SubItems[3].Text = f.CAccount;
                        selectedItem.SubItems[4].Text = MRC.Банки.Find(f.CBank).Название_банка;

                        selectedItem.Tag = Item;

                        LView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                        LView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void Delete_Car()
        {
            try
            {
                foreach (ListViewItem selectedItem in LView.SelectedItems)
                {
                    using (ModelCarRental MRC = new ModelCarRental())
                    {
                        Автомобили n = (Автомобили)selectedItem.Tag;

                        MRC.Автомобили.Attach(n);
                        MRC.Автомобили.Remove(n);
                        MRC.SaveChanges();
                        LView.Items.Remove(selectedItem);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Ошибка удаления. Сначала удалите все привязанные объекты!");
            }
        }