Exemplo n.º 1
0
 public void AddEmployee(Employee emp)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         ent.Employees.Add(emp);
         ent.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void AddAbonement(Abonement abonement)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         ent.Abonements.Add(abonement);
         ent.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public void AddTrainingGroup(TrainingGroup tg)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         ent.TrainingGroups.Add(tg);
         ent.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public void AddClient(Client client)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         ent.Clients.Add(client);
         ent.SaveChanges();
     }
 }
Exemplo n.º 5
0
 //trash
 public void SaveCalendarTimeRows(DataGridView dgv, DateTime currDate)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         bool isColumnNotEmpty = false;
         for (int i = 0; i < dgv.RowCount; i++)
         {
             isColumnNotEmpty = false;
             for (int j = 1; j < dgv.ColumnCount; j++)
             {
                 if ((dgv[j, i] as DataGridViewComboBoxCell).Value != null)
                 {
                     isColumnNotEmpty = true;
                     break;
                 }
             }
             if (isColumnNotEmpty)
             {
                 CalendarTimeRow      ctr = new CalendarTimeRow();
                 List <TrainingGroup> tgs;
                 tgs = GetTrainingGroupByName(dgv[1, i].Value as string);
                 if (tgs.Count != 0)
                 {
                     ctr.Lane1 = tgs[0].Id;
                 }
                 tgs = GetTrainingGroupByName(dgv[2, i].Value as string);
                 if (tgs.Count != 0)
                 {
                     ctr.Lane2 = tgs[0].Id;
                 }
                 tgs = GetTrainingGroupByName(dgv[3, i].Value as string);
                 if (tgs.Count != 0)
                 {
                     ctr.Lane3 = tgs[0].Id;
                 }
                 tgs = GetTrainingGroupByName(dgv[4, i].Value as string);
                 if (tgs.Count != 0)
                 {
                     ctr.Lane4 = tgs[0].Id;
                 }
                 tgs = GetTrainingGroupByName(dgv[5, i].Value as string);
                 if (tgs.Count != 0)
                 {
                     ctr.Lane5 = tgs[0].Id;
                 }
                 tgs = GetTrainingGroupByName(dgv[6, i].Value as string);
                 if (tgs.Count != 0)
                 {
                     ctr.Lane6 = tgs[0].Id;
                 }
                 ctr.TimeId = DayTimeSetIndexToId(i);
                 ctr.Date   = currDate;
                 ent.CalendarTimeRows.Add(ctr);
                 ent.SaveChanges();
             }
         }
     }
 }
Exemplo n.º 6
0
 public void DeleteEmployeeById(int id)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         Employee emp = ent.Employees.Where(e => e.Id == id).FirstOrDefault();
         ent.Employees.Remove(emp);
         ent.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public void DeleteTrainingGroupById(int id)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         TrainingGroup tg = ent.TrainingGroups.Where(t => t.Id == id).FirstOrDefault();
         ent.TrainingGroups.Remove(tg);
         ent.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public void EditTrainingGroup(TrainingGroup tg)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         TrainingGroup dbtg = ent.TrainingGroups.Where(t => t.Id == tg.Id).FirstOrDefault();
         dbtg.GroupName = tg.GroupName;
         dbtg.CoachId   = tg.CoachId;
         dbtg.Color     = tg.Color;
         ent.SaveChanges();
     }
 }
Exemplo n.º 9
0
 public void DeleteClientById(int id)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         Client cl = ent.Clients
                     .Where(c => c.Id == id)
                     .FirstOrDefault();
         ent.Clients.Remove(cl);
         ent.SaveChanges();
     }
 }
Exemplo n.º 10
0
 public void DeleteAbonementById(int id)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         Abonement abonEnt = ent.Abonements
                             .Where(a => a.Id == id)
                             .FirstOrDefault();
         ent.Abonements.Remove(abonEnt);
         ent.SaveChanges();
     }
 }
Exemplo n.º 11
0
 public void CheckVisitWithDate(int abonementId, DateTime date)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         VisitDate vd = new VisitDate();
         vd.AbonementId = abonementId;
         vd.Date        = date.Date;
         vd.ClientId    = GetClientByAbonementId(abonementId)[0].Id;
         ent.VisitDates.Add(vd);
         ent.SaveChanges();
     }
 }
Exemplo n.º 12
0
 public void EditEmployee(Employee emp)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         Employee dbEmp = ent.Employees.Where(e => e.Id == emp.Id).FirstOrDefault();
         dbEmp.Name       = emp.Name;
         dbEmp.Phone      = emp.Phone;
         dbEmp.PositionId = emp.PositionId;
         dbEmp.Secondname = emp.Secondname;
         dbEmp.Surname    = emp.Surname;
         ent.SaveChanges();
     }
 }
Exemplo n.º 13
0
        public void EditClient(Client client)
        {
            using (poolDBEntities ent = new poolDBEntities())
            {
                Client clientEnt = ent.Clients
                                   .Where(c => c.Id == client.Id)
                                   .FirstOrDefault();
                //abonEnt = abonement;
                clientEnt.Name       = client.Name;
                clientEnt.Secondname = client.Secondname;
                clientEnt.Surname    = client.Surname;
                clientEnt.Phone      = client.Phone;
                clientEnt.Gender     = client.Gender;

                ent.SaveChanges();
            }
        }
Exemplo n.º 14
0
        public void EditAbonement(Abonement abonement)
        {
            using (poolDBEntities ent = new poolDBEntities())
            {
                Abonement abonEnt = ent.Abonements
                                    .Where(a => a.Id == abonement.Id)
                                    .FirstOrDefault();
                //abonEnt = abonement;
                abonEnt.VisitTypeId     = abonement.VisitTypeId;
                abonEnt.ServiceTypeId   = abonement.ServiceTypeId;
                abonEnt.TrainingGroupId = abonement.TrainingGroupId;
                abonEnt.VisitCount      = abonement.VisitCount;
                abonEnt.ClientId        = abonement.ClientId;
                abonEnt.DateEnd         = abonement.DateEnd;

                ent.SaveChanges();
            }
        }
Exemplo n.º 15
0
        public void SaveCalendarDataGridViewCmbCellChanges(DateTime currDate, DataGridViewComboBoxCell cmbCell)
        {
            int rowInd       = cmbCell.RowIndex;
            int dayTimeSetId = DayTimeSetIndexToId(rowInd);

            using (poolDBEntities ent = new poolDBEntities())
            {
                List <CalendarTimeRow> currDateCtrs = ent.CalendarTimeRows.Where(c => System.Data.Entity.DbFunctions.TruncateTime(c.Date) == currDate.Date).ToList();
                CalendarTimeRow        ctr          = currDateCtrs?.Find(c => c.TimeId == dayTimeSetId);
                if (ctr == null)
                {
                    if (cmbCell.Value == null)
                    {
                        return;
                    }
                    CalendarTimeRow newCtr = new CalendarTimeRow();
                    newCtr.TimeId = dayTimeSetId;
                    newCtr.Date   = currDate;
                    SetCalendarTimeRowLane(ref newCtr, cmbCell.ColumnIndex, GetTrainingGroupIdByName(cmbCell.Value as string));
                    ent.CalendarTimeRows.Add(newCtr);
                    //ent.Entry(newCtr).State = System.Data.Entity.EntityState.Added;
                }
                else
                {
                    SetCalendarTimeRowLane(ref ctr, cmbCell.ColumnIndex, GetTrainingGroupIdByName(cmbCell.Value as string));
                    if (ctr.Lane1 == null &&
                        ctr.Lane2 == null &&
                        ctr.Lane3 == null &&
                        ctr.Lane4 == null &&
                        ctr.Lane5 == null &&
                        ctr.Lane6 == null)
                    {
                        ent.CalendarTimeRows.Remove(ctr);
                    }
                    //ent.Entry(ctr).State = System.Data.Entity.EntityState.Modified;
                }
                ent.SaveChanges();
            }
        }