예제 #1
0
        private void QueryByYearAndName_Click(object sender, RoutedEventArgs e)
        {
            var movies = ImportLibrary.GetMoviesByYearsAndName(TitleContains.Text, YearsToImport.Text);

            MovieGrid.ItemsSource = movies;
            //MessageBox.Show($"{movies.Count} Retrieved");
        }
예제 #2
0
 /// <summary>
 /// 添加当前页面试图引入库实例。
 /// </summary>
 /// <param name="context">当前试图上下文。</param>
 /// <param name="libraries">引入库实例。</param>
 public static void AddLibraries(this PageContext context, ImportLibrary libraries)
 {
     if (context.ViewData.TryGetValue(nameof(ImportLibrary), out var value) &&
         value is ImportLibrary data)
     {
         libraries |= data;
     }
     context.ViewData[nameof(ImportLibrary)] = libraries;
 }
예제 #3
0
        private void ImportMultiples_Click(object sender, RoutedEventArgs e)
        {
            var moviesToImport = ImportLibrary.GetMoviesFromCSV();

            var startTime      = DateTime.Now;
            var moviesImported = ImportLibrary.WriteBulkRecords(moviesToImport, System.Convert.ToInt32(NumberToImport.Text));
            var endTime        = DateTime.Now;

            MessageBox.Show($"{moviesImported} imported in {(endTime - startTime).TotalSeconds}");
        }
예제 #4
0
        private ImportLibrary GetLibrary(string name)
        {
            ImportLibrary library;

            if (!m_libraries.TryGetValue(name, out library))
            {
                library = new ImportLibrary(name);
                m_libraries.Add(name, library);
            }

            return(library);
        }
예제 #5
0
 /// <summary>
 /// 添加当前页面试图引入库实例。
 /// </summary>
 /// <param name="context">当前试图上下文。</param>
 /// <param name="libraries">引入库实例。</param>
 public static void AddLibraries(this ViewContext context, ImportLibrary libraries)
 {
     libraries |= context.GetLibraries();
     context.ViewData[nameof(ImportLibrary)] = libraries;
 }
예제 #6
0
 internal ImportLibraryOrdinalFunction(ImportLibrary importLibrary, ImportLookupTableEntry tableEntry, int ordinalNo) : base(importLibrary,tableEntry)
 {
     ordinal = ordinalNo;
 }
예제 #7
0
 internal ImportLibraryFunction(ImportLibrary importLibrary, ImportLookupTableEntry tableEntry)
 {
     library = importLibrary;
     table_entry = tableEntry;
 }
예제 #8
0
 internal ImportLibraryNamedFunction(ImportLibrary importLibrary, ImportLookupTableEntry tableEntry, ImportHintNameEntry hintEntry) : base(importLibrary,tableEntry)
 {
     hint_entry = hintEntry;
 }
예제 #9
0
        static void iWizardBusNewStudent_ValidateRow(object sender, ImportLibrary.ValidateRowEventArgs e)
        {
            string busyear = "";
            string bustime = "";
            foreach (var field in e.SelectFields)
            {
                if (field == "")
                    continue;
                string value = e.Data[field];
                if (field == "搭車年度")
                    busyear = value;
                if (field == "校車時段")
                    bustime = value;

                switch (field)
                {
                    default:
                    case "校車時段":
                        if (value.Length == 0)
                            e.ErrorFields.Add("校車時段", "請確認校車時段不可為空!");
                        else
                            if (!校車站名資料庫.ContainsKey(value))
                                e.ErrorFields.Add("校車時段", "請確認校車時段是否有誤!");
                        break;
                    case "代碼":
                        if (value.Length != 4)
                            e.ErrorFields.Add("代碼", "請確認電腦代碼之長度必須是四碼!");
                        else
                            if (!校車站名資料庫[bustime].ContainsKey(value))
                                e.ErrorFields.Add("代碼", "請確認電腦代碼是否有誤!");
                        break;
                    case "期間名稱":
                        if (value.Length == 0)
                            e.ErrorFields.Add("期間名稱", "請確認期間名稱不可為空!");
                        else
                            if (!校車時間紀錄資料庫[busyear].ContainsKey(value))
                                e.ErrorFields.Add("期間名稱", "請確認期間名稱是否有誤!");
                        break;
                    case "科別":
                        if (value.Length == 0)
                            e.ErrorFields.Add("科別", "請確認科別不可為空!");
                        else
                            if (!新生科別資料庫.Contains(value))
                                e.ErrorFields.Add("科別", "請確認科別是否有誤!");
                        break;
                    case "編號":
                        if (value.Length < 5)
                            e.ErrorFields.Add("編號", "請確認編號必須至少五碼!");
                        else
                            if (!學生資料庫.ContainsKey(value))
                                e.ErrorFields.Add("編號", "請確認編號是否為正確新生!");
                        break;
                    case "搭車年度":
                        int syear;
                        if (value.Length == 0)
                            e.ErrorFields.Add("搭車年度", "請確認搭車年度不可為空!");
                        else
                        {
                            if (!int.TryParse(value, out syear))
                                e.ErrorFields.Add("搭車年度", "請確認搭車年度是否有誤!");
                            else
                                if (!校車時間紀錄資料庫.ContainsKey(value))
                                    e.ErrorFields.Add("搭車年度", "請確認搭車年度是否有誤!");
                        }
                        break;
                    case "天數":
                        int daycount;
                        if (value.Length == 0)
                            e.ErrorFields.Add("搭車天數", "請確認搭車天數不可為空!");
                        else
                            if (!int.TryParse(value, out daycount))
                                e.ErrorFields.Add("搭車天數", "請確認搭車天數是否有誤!");
                        break;
                    case "車費":
                        int money;
                        if (value.Length > 0)
                            if (!int.TryParse(value, out money))
                                e.ErrorFields.Add("車費", "請確認車費是否有誤!");
                        break;
                    case "是否繳費":
                        if (value.Length > 0)
                            if (value != "是" && value != "否" && value != "Yes" && value != "No" && value != "True" && value != "False")
                                e.ErrorFields.Add("是否繳費", "請確認是否繳費需為是或否!");
                        break;
                    case "繳費日期":
                        DateTime day;
                        if (value.Length > 0)
                            if (!DateTime.TryParse(value, out day))
                                e.ErrorFields.Add("繳費日期", "請確認繳費日期是否有誤!");
                        break;
                    case "備註":
                        break;
                }
            }
        }
예제 #10
0
        static void iWizardBusStudentPayment_ValidateRow(object sender, ImportLibrary.ValidateRowEventArgs e)
        {
            string busyear = "";
            string bustime = "";
            foreach (var field in e.SelectFields)
            {
                if (field == "")
                    continue;
                string value = e.Data[field];

                switch (field)
                {
                    default:
                    case "搭車天數":
                        int daycount;
                        if (value.Length == 0)
                            e.ErrorFields.Add("搭車天數", "請確認搭車天數不可為空!");
                        else
                            if (!int.TryParse(value, out daycount))
                                e.ErrorFields.Add("搭車天數", "請確認搭車天數是否有誤!");
                        break;
                    case "車費":
                        int money;
                        if (value.Length > 0)
                            if (!int.TryParse(value, out money))
                                e.ErrorFields.Add("車費", "請確認車費是否有誤!");
                        break;
                    case "是否繳費":
                        if (value.Length > 0)
                            if (value != "是" && value != "否" && value != "Yes" && value != "No" && value != "True" && value != "False")
                                e.ErrorFields.Add("是否繳費", "請確認是否繳費需為是或否!");
                        break;
                    case "繳費日期":
                        DateTime day;
                        if (value.Length > 0)
                            if (!DateTime.TryParse(value, out day))
                                e.ErrorFields.Add("繳費日期", "請確認繳費日期是否有誤!");
                        break;
                    case "備註":
                        break;
                }
            }
        }
예제 #11
0
        static void iWizardBusStudentPayment_ImportPackage(object sender, ImportLibrary.ImportPackageEventArgs e)
        {
            List<Data.StudentByBus> importItems = new List<Data.StudentByBus>();
            foreach (var row in e.Items)
            {
                Data.StudentByBus importData = new Data.StudentByBus();
                if (row.ID != "")
                    importData = 搭車紀錄資料庫[row.ID];
                //Data.StudentByBus importData = (row.ID != "") ? 學生搭車紀錄資料庫[學生資料庫[row["學號"]].ID][row["搭車年度"] + row["期間名稱"]] : new Data.StudentByBus();
                //if (_DeletedBusStudents.Contains(importData))
                //    _DeletedBusStudents.Remove(importData);
                string bustime = "";
                string busid = "";
                int daycount = 0;
                foreach (var field in e.ImportFields)
                {
                    string value = row[field];

                    switch (field)
                    {
                        default:
                            break;
                        case "搭車天數":
                            if (value.Length > 0)
                                importData.DateCount = int.Parse(value);
                            break;
                        case "車費":
                            if (value.Length > 0)
                                importData.BusMoney = int.Parse(value);
                            else
                                importData.BusMoney = 0;
                            break;
                        case "是否繳費":
                            if (value.Length > 0)
                            {
                                if (value == "是" || value == "Yes" || value == "True")
                                    importData.PayStatus = true;
                                else
                                    importData.PayStatus = false;
                            }
                            else
                                importData.PayStatus = false;
                            break;
                        case "繳費日期":
                            if (value.Length > 0)
                                importData.PayDate = DateTime.Parse(value);
                            break;
                        case "備註":
                            importData.comment = value;
                            break;
                    }
                }
                importItems.Add(importData);
            }
            importItems.SaveAll();
        }
예제 #12
0
 static void iWizardBusStudentPayment_IdentifyRow(object sender, ImportLibrary.IdentifyRowEventArgs e)
 {
     if (搭車紀錄資料庫.ContainsKey(e.RowData["搭車系統編號"]))
         e.RowData.ID = 搭車紀錄資料庫[e.RowData["搭車系統編號"]].UID;
 }
예제 #13
0
 static void iWizardBusStop_ValidateRow(object sender, ImportLibrary.ValidateRowEventArgs e)
 {
     string busnumber = "";
     foreach (var field in e.SelectFields)
     {
         if (field == "")
             continue;
         string value = e.Data[field];
         if (field == "車號")
             busnumber = value;
         switch (field)
         {
             default:
             case "校車時段":
                 if (value.Length == 0)
                     e.ErrorFields.Add("校車時段", "請確認校車時段不可為空!");
                 break;
             case "代碼":
                 if (value.Length != 4)
                     e.ErrorFields.Add("代碼", "請確認電腦代碼之長度必須是四碼!");
                 break;
             case "站名":
                 if (value.Length == 0)
                     e.ErrorFields.Add("站名", "請確認站名不可為空!");
                 break;
             case "月費":
                 if (value.Length > 0)
                     if (int.Parse(value) < 0)
                         e.ErrorFields.Add("月費", "請確認月費是否有誤!");
                 break;
             case "車號":
                 if (value.Length != 2)
                     e.ErrorFields.Add("車號", "請確認車號是否有誤!");
                 break;
             case "站序":
                 if (value.Length == 0)
                     e.ErrorFields.Add("站序", "請確認站序不可為空!");
                 else
                     if (value.Substring(0, 2) != busnumber)
                         e.ErrorFields.Add("站序", "請確認站序前兩碼是否有誤!");
                 break;
             case "停車地址":
                 break;
             case "到站時間":
                 break;
             case "放學上車地點":
                 break;
         }
     }
 }
예제 #14
0
 static void iWizardBusStop_ImportPackage(object sender, ImportLibrary.ImportPackageEventArgs e)
 {
     List<Data.BusStop> importItems = new List<Data.BusStop>();
     foreach (var row in e.Items)
     {
         Data.BusStop importData = (row.ID != "") ? 檢查校車站名資料庫[row.ID] : new Data.BusStop();
         if (_DeletedBusStops.Contains(importData))
             _DeletedBusStops.Remove(importData);
         foreach (var field in e.ImportFields)
         {
             string value = row[field];
             switch (field)
             {
                 default:
                     break;
                 case "校車時段":
                     importData.BusTimeName = value;
                     break;
                 case "代碼":
                     importData.BusStopID = value;
                     break;
                 case "站名":
                     importData.BusStopName = value;
                     break;
                 case "月費":
                     if (value.Length > 0)
                         importData.BusMoney = int.Parse(value);
                     else
                         importData.BusMoney = 0;
                     break;
                 case "車號":
                     importData.BusNumber = value;
                     break;
                 case "站序":
                     importData.BusStopNo = value;
                     break;
                 case "停車地址":
                     importData.BusStopAddr = value;
                     break;
                 case "到站時間":
                     importData.ComeTime = value;
                     break;
                 case "放學上車地點":
                     importData.BusUpAddr = value;
                     break;
             }
         }
         importItems.Add(importData);
     }
     importItems.SaveAll();
 }
예제 #15
0
 static void iWizardBusStop_IdentifyRow(object sender, ImportLibrary.IdentifyRowEventArgs e)
 {
     if (校車站名資料庫.ContainsKey(e.RowData["校車時段"]))
         if (校車站名資料庫[e.RowData["校車時段"]].ContainsKey(e.RowData["代碼"]))
             e.RowData.ID = 校車站名資料庫[e.RowData["校車時段"]][e.RowData["代碼"]].UID;
 }
예제 #16
0
 static void iWizardBusStudent_IdentifyRow(object sender, ImportLibrary.IdentifyRowEventArgs e)
 {
     if (校車站名資料庫.ContainsKey(e.RowData["校車時段"]))
         if (校車站名資料庫[e.RowData["校車時段"]].ContainsKey(e.RowData["代碼"]))
             if (校車時間紀錄資料庫.ContainsKey(e.RowData["搭車年度"]))
                 if (校車時間紀錄資料庫[e.RowData["搭車年度"]].ContainsKey(e.RowData["期間名稱"]))
                     if (學生資料庫.ContainsKey(e.RowData["學號"]))
                         if (學生搭車紀錄資料庫.ContainsKey(學生資料庫[e.RowData["學號"]].ID))
                             if (學生搭車紀錄資料庫[學生資料庫[e.RowData["學號"]].ID].ContainsKey(e.RowData["搭車年度"] + e.RowData["期間名稱"]))
                                 e.RowData.ID = 學生搭車紀錄資料庫[學生資料庫[e.RowData["學號"]].ID][e.RowData["搭車年度"] + e.RowData["期間名稱"]].UID;
 }
예제 #17
0
        static void iWizardBusNewStudent_ImportPackage(object sender, ImportLibrary.ImportPackageEventArgs e)
        {
            List<Data.StudentByBus> importItems = new List<Data.StudentByBus>();
            foreach (var row in e.Items)
            {
                Data.StudentByBus importData = (row.ID != "") ? 新生搭車紀錄資料庫[新生資料庫[row["編號"]].UID] : new Data.StudentByBus();
                //if (_DeletedBusStudents.Contains(importData))
                //    _DeletedBusStudents.Remove(importData);
                string bustime = "";
                string busid = "";
                int daycount = 0;
                foreach (var field in e.ImportFields)
                {
                    string value = row[field];
                    if (field == "校車時段")
                        bustime = value;
                    if (field == "代碼")
                        busid = value;
                    if (field == "天數")
                        daycount = int.Parse(value);

                    switch (field)
                    {
                        default:
                            break;
                        case "校車時段":
                            importData.BusTimeName = value;
                            break;
                        case "代碼":
                            importData.BusStopID = value;
                            break;
                        case "期間名稱":
                            importData.BusRangeName = value;
                            break;
                        case "科別":
                            importData.ClassName = value;
                            break;
                        case "編號":
                            importData.StudentID = 新生資料庫[value].UID;
                            break;
                        case "搭車年度":
                            if (value.Length > 0)
                                importData.SchoolYear = int.Parse(value);
                            break;
                        case "天數":
                            if (value.Length > 0)
                                importData.DateCount = int.Parse(value);
                            break;
                        case "車費":
                            if (value.Length > 0)
                                importData.BusMoney = int.Parse(value);
                            else
                                importData.BusMoney = 0;
                            break;
                        case "是否繳費":
                            if (value.Length > 0)
                            {
                                if (value == "是" || value == "Yes" || value == "True")
                                    importData.PayStatus = true;
                                else
                                    importData.PayStatus = false;
                            }
                            else
                                importData.PayStatus = false;
                            break;
                        case "繳費日期":
                            if (value.Length > 0)
                                importData.PayDate = DateTime.Parse(value);
                            break;
                        case "備註":
                            importData.comment = value;
                            break;
                    }
                }
                int total = 校車站名資料庫[bustime][busid].BusMoney * daycount;
                int div_value = total / 10;
                if ((total - div_value * 10) < 5)
                    importData.BusMoney = div_value * 10;
                else
                    importData.BusMoney = div_value * 10 + 10;
                //importData.BusMoney = 校車站名資料庫[bustime][busid].BusMoney * daycount;
                importItems.Add(importData);
            }
            importItems.SaveAll();
        }