Esempio n. 1
0
 private void btnAddUser_Click(object sender, EventArgs e)
 {
     connect.Users.Add(new User()
     {
         Name = "test1"
     });
     connect.SaveChanges();
 }
Esempio n. 2
0
 public IActionResult Create(PortfolioAccount portfolio)
 {
     if (ModelState.IsValid)
     {
         _connectDb.Add(portfolio);
         _connectDb.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
 public IActionResult Create(Stock stock)
 {
     if (ModelState.IsValid)
     {
         _connectDb.Add(stock);
         _connectDb.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 4
0
 /// <summary>
 /// Метод для добавлення предмету
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click_1(object sender, EventArgs e)
 {
     if (textBox1.Text != string.Empty && comboBox1.SelectedIndex != -1)
     {
         if (db.Subjects.Where(name => name.Name == textBox1.Text).FirstOrDefault() == null)
         {
             int semestr = int.Parse(comboBox1.SelectedItem.ToString());
             db.Subjects.Add(new Subject()
             {
                 Name = textBox1.Text, Semesters = db.Semesters.Where(sem => sem.SemesterNumber == semestr).FirstOrDefault()
             });
             db.SaveChanges();
             textBox1.Text = string.Empty; comboBox1.Text = string.Empty;  comboBox1.SelectedIndex = -1;
             MessageBox.Show("Subject added", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("This subject already exists", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Enter subject or choise semester", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 5
0
 public bool AddStudentToGrup(List <KeyValuePair <int, string> > grups, List <KeyValuePair <int, string> > students)
 {
     foreach (var item in grups)
     {
         var grop = dataBase.Groups.Where(x => x.GroupId == item.Key).FirstOrDefault();
         foreach (var item1 in students)
         {
             if (grop.Students.Count < grop.Audiences.NumberOfSeats)
             {
                 if (item.Value == item1.Value)
                 {
                     var stud = dataBase.Students.Where(x => x.StudentId == item1.Key).FirstOrDefault();
                     stud.Groups = grop;
                     grop.Students.Add(stud);
                     dataBase.SaveChanges();
                 }
             }
         }
     }
     return(true);
 }
Esempio n. 6
0
 /// <summary>
 /// Добавлення компютера
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button3_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != string.Empty && textBox2.Text != string.Empty && textBox3.Text != string.Empty)
     {
         dataBase.Computers.Add(new Computer
         {
             GraphicsCard = textBox1.Text,
             Processor    = textBox2.Text,
             RAM          = int.Parse(textBox3.Text),
             Softwares    = softwares
         });
         dataBase.SaveChanges();
         textBox1.Text = textBox2.Text = textBox3.Text = string.Empty;
         UpdateSoftwares(); listBox2.Items.Clear();
         MessageBox.Show("PC added", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Enter all fields", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Метод для зберігання відредактованого вчителя
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button3_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != string.Empty && textBox2.Text != string.Empty && textBox3.Text != string.Empty && textBox4.Text != string.Empty && textBox5.Text != string.Empty && textBox6.Text != string.Empty)
     {
         int i       = teachers[comboBox1.SelectedIndex].TeacherId;
         var teacher = dataBase.Teachers.Where((x) => x.TeacherId == i).FirstOrDefault();
         teacher.FirstName   = textBox1.Text;
         teacher.LastName    = textBox2.Text;
         teacher.Age         = Convert.ToInt32(textBox3.Text);
         teacher.PhoneNumber = textBox4.Text;
         teacher.Email       = textBox5.Text;
         teacher.Salary      = Convert.ToDouble(textBox6.Text);
         teacher.Subjects    = subjects;
         dataBase.SaveChanges(); listBox1.Items.Clear(); listBox2.Items.Clear(); UpdateTeachers();
         textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = textBox6.Text = string.Empty;
         MessageBox.Show("Teacher edited", "information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Enter all fields", "information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 8
0
 public IActionResult Create(StockReceiveMastViewModel stockReceiveMastViewModel)
 {
     if (ModelState.IsValid)
     {
         StockReceiveMast mast = new StockReceiveMast
         {
             EntryDate     = DateTime.Now,
             EntryUserId   = 2,
             PortfolioAcId = stockReceiveMastViewModel.PortfolioAcId,
             Remarks       = stockReceiveMastViewModel.Remarks,
             ValueDate     = DateTime.Now,
             Detail        = stockReceiveMastViewModel.details.Select(a => new StockReceiveDetl
             {
                 OwnershipDate = a.OwnerShipDate,
                 Quantity      = a.Quantity,
                 Rate          = a.Rate,
                 StockId       = a.StockId
             }).ToList()
         };
         _connectDb.Add(mast);
         _connectDb.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 9
0
 public void Delete(BookHistory item)
 {
     _connectDb.BookHistory.Remove(item);
     _connectDb.SaveChanges();
 }
Esempio n. 10
0
 public void Delete(Reader item)
 {
     _connectDb.Reader.Remove(item);
     _connectDb.SaveChanges();
 }
Esempio n. 11
0
 public void Delete(Author item)
 {
     _connectDb.Author.Remove(item);
     _connectDb.SaveChanges();
 }