Example #1
0
 public static void Delete(BusSetup route)
 {
     List<ActiveRecord> schs = new List<ActiveRecord>();
     schs.Add(route);
     udtHelper.DeletedValues(schs);
     if (ItemChanged != null)
         ItemChanged(null, EventArgs.Empty);
 }
Example #2
0
 public static string Insert(BusSetup route)
 {
     List<ActiveRecord> logs = new List<ActiveRecord>();
     logs.Add(route);
     List<string> newIDs = udtHelper.InsertValues(logs);
     if (ItemChanged != null)
         ItemChanged(null, EventArgs.Empty);
     return newIDs[0];
 }
Example #3
0
        private void savebtn_Click(object sender, EventArgs e)
        {
            if (this.cboYear.Text == "" || this.cboRange.Text == "")
            {
                MessageBox.Show("搭車年度與期間名稱不可為空!");
                return;
            }

            List<BusSetup> bussetups = BusSetupDAO.SelectByBusYear(int.Parse(this.cboYear.Text));
            BusSetup bussetup = new BusSetup();
            List<StudentByBus> _Source = StudentByBusDAO.SelectByBusYearAndTimeName(int.Parse(this.cboYear.Text), this.cboRange.Text);
            Dictionary<string, StudentByBus> studentids = new Dictionary<string, StudentByBus>();
            //找到所選校車撘乘之資料
            foreach (StudentByBus item in _Source)
            {
                if (!studentids.ContainsKey(item.StudentID))
                    studentids.Add(item.StudentID, item);
            }
            //找到夜輔設定之資料
            bussetups.Reverse();
            foreach (BusSetup item in bussetups)
            {
                if (item.BusTimeName == "夜輔")
                {
                    bussetup = item;
                    continue;
                }
            }
            if (bussetup.BusRangeName == null)
            {
                MessageBox.Show("夜輔無資料,請確認後重新輸入!");
                return;
            }

            List<StudentByBus> Source_night = StudentByBusDAO.SelectByBusYearAndTimeName(int.Parse(this.cboYear.Text), bussetup.BusRangeName);
            List<StudentByBus> StudentBuses = new List<StudentByBus>();
            foreach (StudentByBus item in Source_night)
            {
                if (studentids.ContainsKey(item.StudentID))
                {
                    //item.BusMoney = 0;
                    StudentBuses.Add(item);
                }
            }

            if (StudentBuses.Count > 0)
            {
                //StudentBuses.SaveAll();
                MessageBox.Show("夜輔共" + StudentBuses.Count + "筆儲存成功!");
            }
            else
                MessageBox.Show("無任何符合條件夜輔!");
        }
Example #4
0
        private void CheeckBusStop()
        {
            if (this.cboBusRange.Text != "")
            {
                if (textBusStop.Text.Length != 4)
                {
                    this.textBusStopName.Text = "";
                    this.btnReport.Enabled = false;
                    this.dtDueDate.Enabled = false;
                    MessageBox.Show("電腦代碼為四位,請確認!");
                    return;
                }
                else
                {
                    BusSetup bussetup = new BusSetup();
                    bussetup = BusSetupDAO.SelectByBusYearAndRange(this.intSchoolYear.Value, this.cboBusRange.Text);
                    BusStop busstops = BusStopDAO.SelectByBusTimeNameAndByStopID(bussetup.BusTimeName, textBusStop.Text);
                    if (busstops.BusStopID == null)
                    {
                        this.textBusStopName.Text = "";
                        this.btnReport.Enabled = false;
                        this.dtDueDate.Enabled = false;
                        MessageBox.Show("電腦代碼錯誤,請確認!");
                        return;
                    }
                    else
                        this.textBusStopName.Text = busstops.BusStopName;

                    this.btnReport.Enabled = true;
                    this.dtDueDate.Enabled = false;
                }
            }
        }
Example #5
0
        private void reloadstatus()
        {
            if (cboBusRange.Text != "")
            {
                StudentByBus studentbus = new StudentByBus();
                studentbus = StudentByBusDAO.SelectByBusYearAndTimeNameAndStudntID(this.intSchoolYear.Value, cboBusRange.Text, K12.Presentation.NLDPanels.Student.SelectedSource[0]);

                BusSetup bussetup = new BusSetup();
                if (BusSetupDAO.SelectByBusYear(this.intSchoolYear.Value).Count == 0)
                {
                    MessageBox.Show("此年度無校車紀錄,請重新選擇!");
                    return;
                }
                else
                    bussetup = BusSetupDAO.SelectByBusYearAndRange(this.intSchoolYear.Value, this.cboBusRange.Text);

                List<BusStop> busstops = BusStopDAO.SelectByBusTimeNameOrderByStopID(bussetup.BusTimeName);

                if (studentbus == null)
                {
                }
                else
                {
                    BusStop stu_busstop = BusStopDAO.SelectByBusTimeNameAndByStopID(bussetup.BusTimeName, studentbus.BusStopID);
                    this.textBusStop.Text = stu_busstop.BusStopID;
                    this.textBusStopName.Text = stu_busstop.BusStopName;
                }
            }
        }
Example #6
0
        private void cboBusRange_SelectedIndexChanged(object sender, EventArgs e)
        {
            #region cboBusRange異動
            this.labelX3.Text = "";
            if (cboBusRange.Text != "")
            {
                StudentByBus studentbus = new StudentByBus();
                studentbus = StudentByBusDAO.SelectByBusYearAndTimeNameAndStudntID(this.intSchoolYear.Value, cboBusRange.Text, K12.Presentation.NLDPanels.Student.SelectedSource[0]);

                BusSetup bussetup = new BusSetup();
                if (BusSetupDAO.SelectByBusYear(this.intSchoolYear.Value).Count == 0)
                {
                    MessageBox.Show("此年度無校車紀錄,請重新選擇!");
                    return;
                }
                else
                    bussetup = BusSetupDAO.SelectByBusYearAndRange(this.intSchoolYear.Value, this.cboBusRange.Text);
                List<BusStop> busstops = BusStopDAO.SelectByBusTimeNameOrderByStopID(bussetup.BusTimeName);

                if (studentbus == null)
                {
                }
                else
                {
                    BusStop stu_busstop = BusStopDAO.SelectByBusTimeNameAndByStopID(bussetup.BusTimeName, studentbus.BusStopID);
                    this.textBusStop.Text = stu_busstop.BusStopID;
                    this.textBusStopName.Text = stu_busstop.BusStopName;
                }

                //讀取系統中所有的收費模組(日期設定)。
                List<Payment> pays = Payment.GetAll();
                int next_schoolYear = 0;
                string next_semester = "上學期";
                if (this.cboSemester.Text == "上學期")
                {
                    next_schoolYear = this.intSchoolYear.Value;
                    next_semester = "下學期";
                }
                else
                    next_schoolYear = this.intSchoolYear.Value + 1;
                this.cboPayment.Items.Clear();
                if (pays.Count > 0)
                {
                    foreach (Payment pay in pays)
                        //if ((pay.SchoolYear == this.intSchoolYear.Value && pay.Semester == (this.cboSemester.Text == "上學期" ? 1 : 2)) || (pay.SchoolYear == next_schoolYear && pay.Semester == (next_semester == "上學期" ? 1 : 2)))
                        if (pay.SchoolYear == this.intSchoolYear.Value && pay.Semester == (this.cboSemester.Text == "上學期" ? 1 : 2))
                            if (pay.Name == this.cboBusRange.Text)
                                this.cboPayment.Items.Add(pay);
                }
                if (cboPayment.Items.Count == 0)
                {
                    this.btnReport.Enabled = false;
                    MessageBox.Show("請先設定收費模組");
                    this.Close();
                    return;
                }
                else
                {
                    this.cboPayment.SelectedIndex = 0;
                    this.cboPayment.Enabled = false;
                    Payment selectPayment = cboPayment.SelectedItem as Payment;

                    if (!selectPayment.Extensions.ContainsKey("DefaultExpiration"))
                    {
                        this.btnReport.Enabled = false;
                        MessageBox.Show("請先設定收費之截止日期");
                        this.Close();
                        return;
                    }
                    else
                    {
                        DateTime dutedate;
                        if (!DateTime.TryParse(selectPayment.Extensions["DefaultExpiration"], out dutedate))
                        {
                            this.btnReport.Enabled = false;
                            MessageBox.Show("請先設定收費之截止日期");
                            this.Close();
                            return;
                        }
                        else
                            this.dtDueDate.Value = DateTime.Parse(selectPayment.Extensions["DefaultExpiration"]);

                        List<PaymentDetail> Studentdetail = PaymentDetail.GetByTarget("Student", K12.Presentation.NLDPanels.Student.SelectedSource);
                        if (Studentdetail.Count > 0)
                        {
                            foreach (PaymentDetail pdetail in Studentdetail)
                            {
                                if (pdetail.Extensions["校車收費名稱"] == cboBusRange.SelectedItem.ToString() && int.Parse(pdetail.Extensions["校車收費年度"]) == intSchoolYear.Value)
                                {
                                    pdetail.FillHistories();
                                    IList<PaymentHistory> historyss = pdetail.Histories;
                                    if (historyss == null)
                                        this.labelX3.Text = "未產生過繳費單";
                                    else
                                        this.labelX3.Text = "已產生過繳費單";
                                }
                            }
                        }
                        else
                            this.labelX3.Text = "未產生過繳費單";
                    }
                }

                if (this.textBusStop.Text.Length == 4)
                {
                    this.btnReport.Enabled = true;
                    this.dtDueDate.Enabled = false;
                }
                else
                {
                    this.btnReport.Enabled = false;
                    this.dtDueDate.Enabled = false;
                }
            }
            #endregion
        }
Example #7
0
 //依設定時間先後排序副程式
 static int CompareBusSetup(BusSetup a, BusSetup b)
 {
     return a.UID.CompareTo(b.UID);
 }
Example #8
0
        private void btnReport_Click(object sender, EventArgs e)
        {
            MotherForm.SetStatusBarMessage("正在處理資料...");
            List<StudentRecord> studentclass = K12.Data.Student.SelectAll();
            List<StudentRecord> studentActive =new List<StudentRecord>();
            Dictionary<string, StudentRecord> studentActiveRecord = new Dictionary<string, StudentRecord>();
            int nowSet = 0;
            foreach (StudentRecord var in studentclass)
            {
                MotherForm.SetStatusBarMessage("正在讀取學生資料", nowSet++ * 15 / studentclass.Count);
                if (var.Status.ToString() != "一般")
                    continue;
                if (var.Class.GradeYear == null)
                    continue;
                if (var.Class.GradeYear > 3)
                    continue;
                if (var.Class.GradeYear == 1)
                {
                    if (int.Parse(var.Class.DisplayOrder) > 23)
                        continue;
                }
                else
                {
                    if (int.Parse(var.Class.DisplayOrder) > 24)
                        continue;
                }
                studentActive.Add(var);
                if (!studentActiveRecord.ContainsKey(var.ID))
                    studentActiveRecord.Add(var.ID, var);
            }
            studentActive.Sort(CompareClassNumber);

            List<BusSetup> bussetups = BusSetupDAO.SelectAll();
            BusSetup bussetup = new BusSetup();
            bussetups.Sort(CompareBusSetup);
            foreach (BusSetup var in bussetups)
            {
                bussetup = var;
                break;
            }
            List<Data.StudentByBus> _Source = StudentByBusDAO.SelectByBusYearAndTimeName(bussetup.BusYear, bussetup.BusRangeName);
            Dictionary<string, StudentByBus> stuBuses = new Dictionary<string, StudentByBus>();
            nowSet = 0;
            foreach (StudentByBus var in _Source)
            {
                MotherForm.SetStatusBarMessage("正在讀取搭車資料", 15 + nowSet++ * 15 / _Source.Count);
                if (!studentActiveRecord.ContainsKey(var.StudentID))
                    continue;
                if (!stuBuses.ContainsKey(var.StudentID))
                    stuBuses.Add(var.StudentID, var);
            }

            List<BusStop> busstop = BusStopDAO.SelectByBusTimeName(bussetup.BusTimeName);
            Dictionary<string, BusStop> busstops = new Dictionary<string, BusStop>();
            foreach (BusStop var in busstop)
            {
                if (!busstops.ContainsKey(var.BusStopID))
                    busstops.Add(var.BusStopID, var);
            }

            #region 建立樣板
            Workbook template = new Workbook();
            template.Open(new MemoryStream(Properties.Resources.學生搭車調查表), FileFormatType.Excel2003);
            Workbook wb = new Workbook();
            wb.Open(new MemoryStream(Properties.Resources.學生搭車調查表));
            Worksheet sheet = wb.Worksheets[0];
            #endregion
            Style defaultStyle = wb.DefaultStyle;
            defaultStyle.Font.Name = "標楷體";
            defaultStyle.Font.Size = 12;
            wb.DefaultStyle = defaultStyle;
            int row = 0;
            nowSet = 0;
            sheet.Name = "學生搭乘校車調查表";

            #region 第2列加特殊邊
            Aspose.Cells.Range eachFiveRow = sheet.Cells.CreateRange(row, 0, 1, 8);
            eachFiveRow.SetOutlineBorder(Aspose.Cells.BorderType.TopBorder, CellBorderType.Medium, Color.Black);
            eachFiveRow.SetOutlineBorder(Aspose.Cells.BorderType.BottomBorder, CellBorderType.Medium, Color.Black);
            //校車路線站名資料
            sheet.Cells[row, 0].PutValue("班級");
            sheet.Cells[row, 1].PutValue("學號");
            sheet.Cells[row, 2].PutValue("姓名");
            sheet.Cells[row, 3].PutValue("代碼");
            sheet.Cells[row, 4].PutValue("站名");
            sheet.Cells[row, 5].PutValue("不搭乘");
            sheet.Cells[row, 6].PutValue("要搭乘");
            sheet.Cells[row, 7].PutValue("簽名");
            sheet.Cells[row, 4].Style.HorizontalAlignment = TextAlignmentType.Center;
            row++;
            #endregion
            //buses.Sort(CompareBusNumber);
            string oldclass = "";
            int oldclass_stucount = 0;
            foreach (StudentRecord var in studentActive)
            {
                MotherForm.SetStatusBarMessage("正在產生調查表", 30 + nowSet++ * 100 / studentActive.Count);
                if (var.Class.Name != oldclass && oldclass != "")
                {
                    sheet.Cells[row, 0].PutValue("班級人數");
                    sheet.Cells[row, 1].PutValue(oldclass_stucount.ToString() + "人");
                    sheet.Cells.SetRowHeight(row, 15);
                    row++;
                    sheet.HPageBreaks.Add(row, 6);
                    oldclass_stucount = 0;
                }
                eachFiveRow = sheet.Cells.CreateRange(row, 0, 1, 8);
                sheet.Cells[row, 0].PutValue(var.Class.Name);
                sheet.Cells[row, 1].PutValue(var.StudentNumber);
                sheet.Cells[row, 2].PutValue(var.Name);
                if (stuBuses.ContainsKey(var.ID))
                {
                    if (stuBuses[var.ID].BusStopID != "0000")
                    {
                        sheet.Cells[row, 3].PutValue(stuBuses[var.ID].BusStopID);
                        if (busstops.ContainsKey(stuBuses[var.ID].BusStopID))
                            sheet.Cells[row, 4].PutValue(busstops[stuBuses[var.ID].BusStopID].BusStopName);
                    }
                }
                sheet.Cells[row, 5].PutValue("□");
                sheet.Cells[row, 6].PutValue("□");
                sheet.Cells.SetRowHeight(row, 15);
                eachFiveRow.SetOutlineBorder(Aspose.Cells.BorderType.BottomBorder, CellBorderType.Thin, Color.Black);
                oldclass = var.Class.Name;
                oldclass_stucount++;
                row++;
            }
            sheet.Cells[row, 0].PutValue("班級人數");
            sheet.Cells[row, 1].PutValue(oldclass_stucount.ToString() + "人");
            sheet.Cells.SetRowHeight(row, 15);
            sheet.PageSetup.TopMargin = 0.7;
            sheet.PageSetup.BottomMargin = 1.5;
            sheet.PageSetup.LeftMargin = 1.2;
            sheet.PageSetup.RightMargin = 1.2;
            sheet.PageSetup.CenterHorizontally = true;
            sheet.PageSetup.Zoom = 95;
            //sheet.PageSetup.SetFooter(0, "&[日期]");
            //sheet.PageSetup.SetFooter(2, "第 &[頁碼] 頁,共 &[總頁數] 頁");
            sheet.PageSetup.PrintTitleRows = "$1:$1";
            sheet.AutoFitColumns();

            try
            {
                wb.Save(Application.StartupPath + "\\Reports\\學生搭乘校車調查表.xls", FileFormatType.Excel2003);
                System.Diagnostics.Process.Start(Application.StartupPath + "\\Reports\\學生搭乘校車調查表.xls");
                MotherForm.SetStatusBarMessage("學生搭乘校車調查表已匯出完成", 100);
            }
            catch
            {
                System.Windows.Forms.SaveFileDialog sd1 = new System.Windows.Forms.SaveFileDialog();
                sd1.Title = "另存新檔";
                sd1.FileName = "學生搭乘校車調查表.xls";
                sd1.Filter = "Excel檔案 (*.xls)|*.xls|所有檔案 (*.*)|*.*";
                if (sd1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    try
                    {
                        wb.Save(sd1.FileName, FileFormatType.Excel2003);
                        System.Diagnostics.Process.Start(sd1.FileName);
                        MotherForm.SetStatusBarMessage("學生搭乘校車調查表已匯出完成", 100);
                    }
                    catch
                    {
                        System.Windows.Forms.MessageBox.Show("指定路徑無法存取。", "建立檔案失敗", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        return;
                    }
                }
            }
        }
Example #9
0
 //依校車時段、搭車起始日期排序副程式
 static int CompareBusTimeStartDate(BusSetup a, BusSetup b)
 {
     if (a.BusTimeName == b.BusTimeName)
         return a.BusStartDate.CompareTo(b.BusStartDate);
     else
         return a.BusTimeName.CompareTo(b.BusTimeName);
 }
Example #10
0
 //依搭車起始日期排序副程式
 static int CompareBusStartDate(BusSetup a, BusSetup b)
 {
     return a.BusStartDate.CompareTo(b.BusStartDate);
 }
Example #11
0
 public static string Update(BusSetup route)
 {
     List<ActiveRecord> schs = new List<ActiveRecord>();
     schs.Add(route);
     udtHelper.UpdateValues(schs);
     if (ItemChanged != null)
         ItemChanged(null, EventArgs.Empty);
     return route.UID;
 }
Example #12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool repeat = false;
            Data.BusSetup bus = new Data.BusSetup();
            if (this.txtBusRange.Text == "")
            {
                MessageBox.Show("期間名稱不可為空,請重新輸入!");
                repeat = true;
            }
            if (this.txtBusRange.Text.IndexOf("-" + this.cboBusTime.Text) < 0)
            {
                MessageBox.Show("期間名稱開頭需為『-" + this.cboBusTime.Text + "』,請重新輸入!");
                repeat = true;
            }

            if (this.cboBusTime.Text == "")
            {
                MessageBox.Show("校車時段不可為空,請重新輸入!");
                repeat = true;
            }
            if (this.cboPayment.Text == "")
            {
                MessageBox.Show("收費銀行設定不可為空,請重新輸入!");
                repeat = true;
            }

            if (this.dateTime_start.Value > this.dateTime_end.Value)
            {
                MessageBox.Show("搭車起始日期不可為大於搭車截止日期,請重新輸入!");
                repeat = true;
            }
            //if (this.dateTime_start.Value < DateTime.Today)
            //{
            //    MessageBox.Show("搭車起始日期不可為小於今日,請重新輸入!");
            //    repeat = true;
            //}
            if (repeat)
                return;

            if (this._busset.BusRangeName != null)
            {
                if (this._busset.BusPaymentName != "")
                {
                    //讀取系統中所有的收費模組(日期設定)。
                    List<Payment> pays = Payment.GetAll();
                    if (pays.Count > 0)
                    {
                        foreach (Payment pay in pays)
                        {
                            if (pay.SchoolYear == this.nrSchoolYear.Value && pay.Semester == this.nrSemester.Value)
                            {
                                if (Payment.GetByID(this._busset.BusPaymentName).SchoolYear == pay.SchoolYear && Payment.GetByID(this._busset.BusPaymentName).Semester == pay.Semester)
                                {
                                    if (this.txtBusRange.Text != pay.Name)
                                        continue;
                                    pay.Name = this.txtBusRange.Text;
                                    if (!pay.Extensions.ContainsKey("DefaultExpiration"))
                                        pay.Extensions.Add("DefaultExpiration", this.dateTime_payend.Value.ToShortDateString());
                                    else
                                        pay.Extensions["DefaultExpiration"] = this.dateTime_payend.Value.ToShortDateString();
                                    if (pay.BarcodeConfiguration == null)
                                        pay.BarcodeConfiguration = cboPayment.SelectedItem as BarcodeConfiguration;
                                    Payment.Update(pay);
                                    this._busset.BusPaymentName = pay.UID;
                                    continue;
                                }
                                else
                                {
                                    if (this.txtBusRange.Text == pay.Name)
                                    {
                                        MessageBox.Show("此學期此收費名稱已存在!");
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    List<BarcodeConfiguration> barcodes = BarcodeConfiguration.GetAll();
                    string barcodeid = "";
                    foreach (BarcodeConfiguration barcode in barcodes)
                        if (barcode.Name == this.cboPayment.Text)
                            barcodeid = barcode.UID;

                    //讀取系統中所有的收費模組(日期設定)。
                    List<Payment> pays = Payment.GetAll();
                    if (pays.Count > 0)
                    {
                        foreach (Payment pay in pays)
                        {
                            if (pay.SchoolYear == this.nrSchoolYear.Value && pay.Semester == this.nrSemester.Value)
                            {
                                if (this.txtBusRange.Text != pay.Name)
                                    continue;
                                pay.Name = this.txtBusRange.Text;
                                if (!pay.Extensions.ContainsKey("DefaultExpiration"))
                                    pay.Extensions.Add("DefaultExpiration", this.dateTime_payend.Value.ToShortDateString());
                                else
                                    pay.Extensions["DefaultExpiration"] = this.dateTime_payend.Value.ToShortDateString();
                                if (pay.BarcodeConfiguration == null)
                                    pay.BarcodeConfiguration = cboPayment.SelectedItem as BarcodeConfiguration;
                                Payment.Update(pay);
                                this._busset.BusPaymentName = pay.UID;
                                continue;
                            }
                        }
                    }
                    else
                    {
                        Payment BusPayment = new Payment(txtBusRange.Text, int.Parse(nrSchoolYear.Value.ToString()), int.Parse(nrSemester.Value.ToString()));
                        BusPayment.Extensions.Add("DefaultExpiration", this.dateTime_payend.Value.ToShortDateString());
                        BusPayment.BarcodeConfiguration = cboPayment.SelectedItem as BarcodeConfiguration;
                        BusPayment = Payment.Insert(BusPayment);
                        this._busset.BusPaymentName = BusPayment.UID;
                    }
                }

                this._busset.BusYear = int.Parse(this.nrYear.Value.ToString());
                this._busset.BusRangeName = this.txtBusRange.Text;
                this._busset.BusStartDate = this.dateTime_start.Value;
                this._busset.BusEndDate = this.dateTime_end.Value;
                this._busset.PayEndDate = this.dateTime_payend.Value;
                this._busset.DateCount = int.Parse(this.nrBusDay.Value.ToString());
                this._busset.BusTimeName = this.cboBusTime.Text;
                //Payment selectPayment = this.cboBusPayment.SelectedItem as Payment;
                //this._busset.BusPaymentName = selectPayment.UID;
                //this._busset.BusByNewStudent = this.chkNew.Checked;
                if (repeat == false)
                    Data.BusSetupDAO.Update(_busset);
            }
            else
            {
                Payment BusPayment = new Payment(txtBusRange.Text, int.Parse(nrSchoolYear.Value.ToString()), int.Parse(nrSemester.Value.ToString()));
                BusPayment.Extensions.Add("DefaultExpiration", this.dateTime_payend.Value.ToShortDateString());
                BusPayment.BarcodeConfiguration = cboPayment.SelectedItem as BarcodeConfiguration;
                BusPayment = Payment.Insert(BusPayment);
                bus.BusPaymentName = BusPayment.UID;

                bus.BusYear = int.Parse(this.nrYear.Value.ToString());
                bus.BusRangeName = this.txtBusRange.Text;
                bus.BusStartDate = this.dateTime_start.Value;
                bus.BusEndDate = this.dateTime_end.Value;
                bus.PayEndDate = this.dateTime_payend.Value;
                bus.DateCount = int.Parse(this.nrBusDay.Value.ToString());
                bus.BusTimeName = this.cboBusTime.Text;
                //Payment selectPayment = this.cboBusPayment.SelectedItem as Payment;
                //this._busset.BusPaymentName = selectPayment.UID;
                //bus.BusByNewStudent = this.chkNew.Checked;
                if (repeat == false)
                    Data.BusSetupDAO.Insert(bus);
            }
            if (repeat == false)
                this.Close();
        }
Example #13
0
 /// <summary>
 /// 若要修改某個站名,就會把該站名物件傳進來。
 /// </summary>
 /// <param name="bus"></param>
 public void SetBus(Data.BusSetup busset)
 {
     this._busset = busset;
 }
Example #14
0
        private void reloadstatus()
        {
            if (cboBusRange.Text != "")
            {
                StudentByBus studentbus = new StudentByBus();
                foreach (MySchoolModule.NewStudentRecord nsr in NewStudent.Instance.SelectedList)
                    studentbus = StudentByBusDAO.SelectByBusYearAndTimeNameAndStudntID(this.intSchoolYear.Value, cboBusRange.Text, nsr.UID);

                BusSetup bussetup = new BusSetup();
                if (BusSetupDAO.SelectByBusYear(this.intSchoolYear.Value).Count == 0)
                {
                    MessageBox.Show("此年度無校車紀錄,請重新選擇!");
                    return;
                }
                else
                    bussetup = BusSetupDAO.SelectByBusYearAndRange(this.intSchoolYear.Value, cboBusRange.Text);

                List<BusStop> busstops = BusStopDAO.SelectByBusTimeNameOrderByStopID(bussetup.BusTimeName);

                if (studentbus == null)
                {
                }
                else
                {
                    BusStop stu_busstop = BusStopDAO.SelectByBusTimeNameAndByStopID(bussetup.BusTimeName, studentbus.BusStopID);
                    this.textBusStop.Text = stu_busstop.BusStopID;
                    this.textBusStopName.Text = stu_busstop.BusStopName;
                }
            }
        }
Example #15
0
        private void cboBusRange_SelectedIndexChanged(object sender, EventArgs e)
        {
            #region cboBusRange異動
            this.labelX3.Text = "";
            if (cboBusRange.Text != "")
            {
                StudentByBus studentbus = new StudentByBus();
                foreach (MySchoolModule.NewStudentRecord nsr in NewStudent.Instance.SelectedList)
                    studentbus = StudentByBusDAO.SelectByBusYearAndTimeNameAndStudntID(this.intSchoolYear.Value, cboBusRange.Text, nsr.UID);

                BusSetup bussetup = new BusSetup();
                if (BusSetupDAO.SelectByBusYear(this.intSchoolYear.Value).Count == 0)
                {
                    MessageBox.Show("此年度無校車紀錄,請重新選擇!");
                    return;
                }
                else
                    bussetup = BusSetupDAO.SelectByBusYearAndRange(this.intSchoolYear.Value, cboBusRange.Text);
                List<BusStop> busstops = BusStopDAO.SelectByBusTimeNameOrderByStopID(bussetup.BusTimeName);
                //Dictionary<string, BusStop> busstopRecord = new Dictionary<string, BusStop>();
                //this.cboBusStopID.Items.Clear();
                //foreach (BusStop busstop in busstops)
                //{
                //    this.cboBusStopID.Items.Add(busstop.BusStopID + "  " + busstop.BusStopName);
                //    busstopRecord.Add(busstop.BusStopID, busstop);
                //}

                if (studentbus == null)
                {
                }
                else
                {
                    BusStop stu_busstop = BusStopDAO.SelectByBusTimeNameAndByStopID(bussetup.BusTimeName, studentbus.BusStopID);
                    //if (busstopRecord.ContainsKey(stu_busstop.BusStopID))
                    //    this.cboBusStopID.SelectedIndex = busstopRecord.Keys.ToList().IndexOf(stu_busstop.BusStopID);
                    this.textBusStop.Text = stu_busstop.BusStopID;
                    this.textBusStopName.Text = stu_busstop.BusStopName;
                }

                //讀取系統中所有的收費模組(日期設定)。
                List<Payment> pays = Payment.GetAll();

                this.cboPayment.Items.Clear();
                if (pays.Count > 0)
                {
                    foreach (Payment pay in pays)
                        if (pay.SchoolYear == this.intSchoolYear.Value && pay.Semester == (this.cboSemester.Text == "上學期" ? 1 : 2))
                            if (pay.Name == this.cboBusRange.Text)
                                this.cboPayment.Items.Add(pay);
                }
                if (cboPayment.Items.Count == 0)
                {
                    this.btnReport.Enabled = false;
                    MessageBox.Show("請先設定收費模組");
                    this.Close();
                    return;
                }
                else
                {
                    this.cboPayment.SelectedIndex = 0;
                    this.cboPayment.Enabled = false;
                    Payment selectPayment = cboPayment.SelectedItem as Payment;

                    if (!selectPayment.Extensions.ContainsKey("DefaultExpiration"))
                    {
                        this.btnReport.Enabled = false;
                        MessageBox.Show("請先設定收費之截止日期");
                        this.Close();
                        return;
                    }
                    else
                    {
                        DateTime dutedate;
                        if (!DateTime.TryParse(selectPayment.Extensions["DefaultExpiration"], out dutedate))
                        {
                            this.btnReport.Enabled = false;
                            MessageBox.Show("請先設定收費之截止日期");
                            this.Close();
                            return;
                        }
                        else
                            this.dtDueDate.Value = DateTime.Parse(selectPayment.Extensions["DefaultExpiration"]);

                        List<PaymentDetail> Studentdetail = PaymentDetail.GetByTarget("NewStudent", NewStudent.Instance.SelectedList[0].UID);
                        if (Studentdetail.Count > 0)
                        {
                            foreach (PaymentDetail pdetail in Studentdetail)
                            {
                                if (pdetail.Extensions["校車收費名稱"] == cboBusRange.SelectedItem.ToString() && int.Parse(pdetail.Extensions["校車收費年度"]) == intSchoolYear.Value)
                                {
                                    pdetail.FillHistories();
                                    IList<PaymentHistory> historyss = pdetail.Histories;
                                    if (historyss == null)
                                        this.labelX3.Text = "未產生過繳費單";
                                    else
                                        this.labelX3.Text = "已產生過繳費單";
                                }
                            }
                        }
                        else
                            this.labelX3.Text = "未產生過繳費單";
                    }
                }

                if (this.textBusStop.Text.Length == 4)
                {
                    this.btnReport.Enabled = true;
                    this.dtDueDate.Enabled = false;
                }
                else
                {
                    this.btnReport.Enabled = false;
                    this.dtDueDate.Enabled = false;
                }
            }
            #endregion
        }