Ejemplo n.º 1
0
        private void NewProc_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(DateTime.Parse(DayBox.SelectedItem.ToString()).Year.ToString());
            //MessageBox.Show(DateTime.Parse(DayBox.SelectedItem.ToString()).Month.ToString());
            //MessageBox.Show(DateTime.Parse(DayBox.SelectedItem.ToString()).Day.ToString());

            DateTime day  = new DateTime(DateTime.Parse(DayBox.SelectedItem.ToString()).Year, DateTime.Parse(DayBox.SelectedItem.ToString()).Month, DateTime.Parse(DayBox.SelectedItem.ToString()).Day);
            DateTime time = new DateTime(1, 1, 1, TimeSpan.Parse(TimeBox.SelectedItem.ToString()).Hours, TimeSpan.Parse(TimeBox.SelectedItem.ToString()).Minutes, TimeSpan.Parse(TimeBox.SelectedItem.ToString()).Seconds);
            //MessageBox.Show(day.ToString());
            //MessageBox.Show(time.ToString());

            ProcModel procmodel = new ProcModel();

            FreeTimeModel freetimemodel = new FreeTimeModel();

            freetimemodel.Day         = day;
            freetimemodel.Time        = time;
            freetimemodel.Personal_Id = usercollection[DoctorBox.SelectedIndex].Id;
            freetimemodel.Id          = freetime.Get_Item(freetimemodel.Day, freetimemodel.Time, freetimemodel.Personal_Id).Id;
            procmodel.Client_Id       = Id;
            procmodel.Personal_Id     = usercollection[DoctorBox.SelectedIndex].Id;
            procmodel.Proc_Type_Id    = proctype.Get_Item("Name", ProcTypeBox.SelectedItem.ToString(), ConditionType.Equal).Id;
            procmodel.Date_Id         = date.SwapFreeTime(freetimemodel);

            //MessageBox.Show(procmodel.ToString());
            proc.Add(procmodel);
            MessageBox.Show("Сохранено");
            back.Show();
            this.Close();
        }
Ejemplo n.º 2
0
        public FreeTimeModel Get_Item(DateTime day, DateTime time, long Id)
        {
            using (var db = new MainDb())
            {
                var query = MakeSelect(db);



                query = query.Where(q => q.Personal_Id.Equals(Id));

                query = query.Where(q => q.Day.Equals(day));

                query = query.Where(q => q.Time.Equals(time));



                FreeTimeModel Result = new FreeTimeModel();
                try
                {
                    Result = query.Single();
                    return(Result);
                }
                catch
                {
                    FreeTimeModel NullResult = new FreeTimeModel();
                    NullResult.Id          = 0;
                    NullResult.Personal_Id = 0;

                    return(NullResult);
                }
            }
        }
Ejemplo n.º 3
0
        public long SwapFreeTime(FreeTimeModel freetime)
        {
            long      id;
            DateModel datemodel = new DateModel();
            Date      date      = new Date();
            FreeTime  ftime     = new FreeTime();
            DateTime  datetime  = new DateTime(freetime.Day.Year, freetime.Day.Month, freetime.Day.Day, freetime.Time.Hour, freetime.Time.Minute, freetime.Time.Second);


            using (var db = new MainDb())
            {
                try
                {
                    datemodel = date.List("Get_id", datetime).Single();

                    id = datemodel.Id;
                }
                catch
                {
                    datemodel.Day  = freetime.Day;
                    datemodel.Time = freetime.Time;
                    id             = date.Add(datemodel);
                }
                Console.WriteLine(freetime.Id);
                ftime.Delete(freetime.Id);
                return(id);
            }
        }
Ejemplo n.º 4
0
        public long Add(FreeTimeModel model)
        {
            //TODO: валидация модели

            //Сохранение
            using (var db = new MainDb())
            {
                long id = Convert.ToInt64(db.FreeTime.InsertWithIdentity(() => new Kpo.Dal.MainDb.FreeTimeDataModel
                {
                    Personal_Id = model.Personal_Id,
                    Day         = model.Day,
                    Time        = model.Time
                }));

                return(id);
            }
        }