示例#1
0
 public void AddEmployee(Employee emp)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         ent.Employees.Add(emp);
         ent.SaveChanges();
     }
 }
示例#2
0
 public void AddAbonement(Abonement abonement)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         ent.Abonements.Add(abonement);
         ent.SaveChanges();
     }
 }
示例#3
0
 public void AddTrainingGroup(TrainingGroup tg)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         ent.TrainingGroups.Add(tg);
         ent.SaveChanges();
     }
 }
示例#4
0
 public void AddClient(Client client)
 {
     using (poolDBEntities ent = new poolDBEntities())
     {
         ent.Clients.Add(client);
         ent.SaveChanges();
     }
 }
示例#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();
             }
         }
     }
 }
示例#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();
     }
 }
示例#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();
     }
 }
示例#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();
     }
 }
示例#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();
     }
 }
示例#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();
     }
 }
示例#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();
     }
 }
示例#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();
     }
 }
示例#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();
            }
        }
示例#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();
            }
        }
示例#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();
            }
        }