Exemple #1
0
        /// <summary>
        /// 指定された文字配列の値からCSCScheduleオブジェクトを作成する
        /// </summary>
        /// <param name="fields">文字列配列</param>
        /// <returns>CSCScheduleオブジェクト</returns>
        private static CSCSchedule CreateCSCSchedule(string[] fields)
        {
            if (fields.Length != 4) throw new ImportDataException();
            var q = from x in fields where x == null select x;
            if (q.Any()) throw new ImportDataException();
            CSCSchedule schedule = new CSCSchedule();

            schedule.Title = fields[0].TrimEnd();
            if (schedule.Title.Length == 0 || schedule.Title.Length > 32)
                throw new ImportDataException();

            schedule.Contents = fields[1].TrimEnd();
            if (schedule.Contents.Length > 32)
                throw new ImportDataException();

            DateTime d;
            if (!DateTime.TryParse(fields[2], out d))
                throw new ImportDataException();
            schedule.Limit = d;

            bool b;
            if (!bool.TryParse(fields[3], out b))
                throw new ImportDataException();
            schedule.IsFinished = b;

            return schedule;
        }
 partial void DeleteCSCSchedule(CSCSchedule instance);
 partial void UpdateCSCSchedule(CSCSchedule instance);
 partial void InsertCSCSchedule(CSCSchedule instance);
 /// <summary>
 /// 
 /// </summary>
 private void InsertRecord()
 {
     CSCSchedule schedule = new CSCSchedule();
     GetDataPropertyValues(schedule);
     _dataContext.CSCSchedule.InsertOnSubmit(schedule);
     _dataContext.SubmitChanges();
     Items.Add(schedule);
     Item = schedule;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="schedule"></param>
 private void GetDataPropertyValues(CSCSchedule schedule)
 {
     schedule.Id = Id;
     schedule.Title = Title;
     schedule.Contents = Contents;
     schedule.Limit = Limit;
     schedule.IsFinished = IsFinished;
 }
        /// <summary>
        /// 指定されたタイトルを含むデータをデータベースから読み込んでItemプロパティに格納する
        /// </summary>
        /// <param name="keyword">タイトル</param>
        private void FillItems(String keyword = null)
        {
            string k = (keyword ?? string.Empty).Trim();
            var q =
                from p in _dataContext.CSCSchedule
                where p.Title.Contains(k)
                orderby p.Id descending
                select p;

            Items.Clear();
            CSCSchedule newSchedule = new CSCSchedule { Title = "(新規)" };
            Items.Add(newSchedule);
            foreach (var x in q)
            {
                Items.Add(x);
            }
            Item = Items[0];
        }