Beispiel #1
0
        private void SaveUDT(UDT.Approach approach)
        {
            List <UDT.Approach> records = Access.Select <UDT.Approach>(string.Format("ref_student_id={0}", this._RunningKey));

            if (records.Count > 0)
            {
                records.ForEach(x => x.Deleted = true);
            }

            records.Add(approach);
            records.SaveAll();
        }
        protected override void OnSaveButtonClick(EventArgs e)
        {
            this.dgvData.EndEdit();
            this.dgvData.CurrentCell = null;
            if (!Is_Validated())
            {
                MessageBox.Show("請先修正錯誤。");
                return;
            }

            UDT.Approach approach = new UDT.Approach();

            string string_Q1 = this.dgvData.Rows[0].Cells[1].Value + "";
            string string_Q2 = this.dgvData.Rows[1].Cells[1].Value + "";
            string string_Q3 = this.dgvData.Rows[2].Cells[1].Value + "";
            string string_Q4 = this.dgvData.Rows[3].Cells[1].Value + "";
            string string_Q5 = this.dgvData.Rows[4].Cells[1].Value + "";
            string string_Q6 = this.dgvData.Rows[5].Cells[1].Value + "";

            //int int_QQ;

            #region 儲存UDT資料

            //approach.StudentID = int.Parse(this.PrimaryKey);
            //approach.SurveyYear = int.Parse(this.txtSurveyYear.Text.Trim());
            //approach.LastUpdateTime = DateTime.Now;
            //         approach.Q6 = string_Q6;
            //         approach.Memo = txtMemo.Text.Trim();

            //         approach.Q1 = int.Parse(this.dgvData.Rows[0].Cells[1].Value + "");
            //         if (int.TryParse(string_Q2, out int_QQ))
            //             approach.Q2 = int_QQ;
            //         else
            //             approach.Q2 = null;
            //         if (int.TryParse(string_Q3, out int_QQ))
            //             approach.Q3 = int_QQ;
            //         else
            //             approach.Q3 = null;
            //         if (int.TryParse(string_Q4, out int_QQ))
            //             approach.Q4 = int_QQ;
            //         else
            //             approach.Q4 = null;
            //         if (int.TryParse(string_Q5, out int_QQ))
            //             approach.Q5 = int_QQ;
            //         else
            //             approach.Q5 = null;

            Dictionary<string, Dictionary<string, string>> Data = new Dictionary<string, Dictionary<string, string>>();
            Data.Add(PrimaryKey, new Dictionary<string, string>());
            Data[PrimaryKey].Add("升學與就業情形", string_Q1);
            Data[PrimaryKey].Add("升學:就讀學校情形", string_Q2);
            Data[PrimaryKey].Add("升學:學制別", string_Q3);
            Data[PrimaryKey].Add("升學:入學方式", string_Q4);
            Data[PrimaryKey].Add("未升學未就業:動向", string_Q5);
            Data[PrimaryKey].Add("是否需要教育部協助", string_Q6);
            Data[PrimaryKey].Add("備註", txtMemo.Text.Trim());
            #endregion
            this._BGWSaveData.RunWorkerAsync(Data);
        }
            public override string ProcessRequest(int Year, Dictionary<string, Dictionary<string, string>> Data)
            {
                if (Year != 102 && this.successor != null)
                {
                    return this.successor.ProcessRequest(Year, Data);
                }
                else
                {
                    StringBuilder strLog = new StringBuilder();
                    List<UDT.Approach> ExistingRecords = new List<UDT.Approach>();
                    AccessHelper Access = new AccessHelper();

                    strLog.AppendLine("詳細資料:");

                    ExistingRecords = Access.Select<UDT.Approach>();
                    //  要新增的 Record
                    List<UDT.Approach> insertRecords = new List<UDT.Approach>();
                    //  要更新的 Record
                    List<UDT.Approach> updateRecords = new List<UDT.Approach>();
                    foreach (string key in Data.Keys)
                    {
                        //string id_number = Data[key]["身分證號"].Trim();
                        string q1_string = Data[key]["升學與就業情形"].Trim();
                        string q2_string = Data[key]["升學:就讀學校情形"].Trim();
                        string q3_string = Data[key]["升學:學制別"].Trim();
                        string q4_string = Data[key]["升學:入學方式"].Trim();
                        string q5_string = Data[key]["未升學未就業:動向"].Trim();
                        string q6_string = Data[key]["是否需要教育部協助"].Trim().Replace("1", "是").Replace("2", "否");
                        string memo = Data[key]["備註"].Trim();

                        strLog.AppendLine("填報學年度「" + Year + "」升學與就業情形「" + q1_string + "」升學:就讀學校情形「" + q2_string + "」升學:學制別「" + q3_string + "」升學:入學方式「" + q4_string + "」未升學未就業:動向「" + q5_string + "」是否需要教育部協助「" + q6_string + "」備註「" + memo + "」");

                        int q2_int;
                        int q3_int;
                        int q4_int;
                        int q5_int;

                        int student_id = int.Parse(key);

                        UDT.Approach record = new UDT.Approach();
                        IEnumerable<UDT.Approach> filterRecords = new List<UDT.Approach>();
                        filterRecords = ExistingRecords.Where(x => x.StudentID == student_id);

                        if (filterRecords.Count() > 0)
                        {
                            record = filterRecords.OrderByDescending(x => x.LastUpdateTime).ElementAt(0);
                            updateRecords.Add(record);
                        }
                        else
                        {
                            insertRecords.Add(record);
                        }

                        int q1 = int.Parse(q1_string);

                        record.StudentID = student_id;
                        record.SurveyYear = Year;
                        record.Q1 = q1;

                        if (int.TryParse(q2_string, out q2_int))
                            record.Q2 = q2_int;
                        else
                            record.Q2 = null;

                        if (int.TryParse(q3_string, out q3_int))
                            record.Q3 = q3_int;
                        else
                            record.Q3 = null;

                        if (int.TryParse(q4_string, out q4_int))
                            record.Q4 = q4_int;
                        else
                            record.Q4 = null;

                        if (int.TryParse(q5_string, out q5_int))
                            record.Q5 = q5_int;
                        else
                            record.Q5 = null;

                        record.Q6 = q6_string;
                        record.Memo = memo;

                        record.LastUpdateTime = DateTime.Now;
                    }

                    //  新增
                    List<string> insertedIDs = new List<string>();
                    try
                    {
                        insertedIDs = insertRecords.SaveAll();
                    }
                    catch (System.Exception e)
                    {
                        System.Windows.Forms.MessageBox.Show(e.Message);
                        return e.Message;
                    }
                    //  更新
                    List<string> updatedIDs = new List<string>();
                    try
                    {
                        updatedIDs = updateRecords.SaveAll();
                    }
                    catch (System.Exception e)
                    {
                        System.Windows.Forms.MessageBox.Show(e.Message);
                        return e.Message;
                    }

                    //  RaiseEvent
                    if (insertedIDs.Count > 0 || updatedIDs.Count > 0)
                    {
                        //IEnumerable<string> uids = insertedIDs.Union(updatedIDs);
                        UDT.Approach.RaiseAfterUpdateEvent();
                    }

                    ApplicationLog.Log("高雄市國中畢業學生進路調查", "登錄畢業學生進路", "student", "", strLog.ToString());

                    return "儲存成功。";
                }
            }
Beispiel #4
0
 private void _BGWSaveData_DoWork(object sender, DoWorkEventArgs e)
 {
     UDT.Approach approach = e.Argument as UDT.Approach;
     SaveUDT(approach);
 }
Beispiel #5
0
        protected override void OnSaveButtonClick(EventArgs e)
        {
            this.dgvData.CurrentCell = null;
            if (!Is_Validated())
            {
                MessageBox.Show("請先修正錯誤。");
                return;
            }
            this.Loading = true;

            string string_Q1 = this.dgvData.Rows[0].Cells[1].Value + "";
            string string_Q2 = this.dgvData.Rows[1].Cells[1].Value + "";
            string string_Q3 = this.dgvData.Rows[2].Cells[1].Value + "";
            string string_Q4 = this.dgvData.Rows[3].Cells[1].Value + "";
            string string_Q5 = this.dgvData.Rows[4].Cells[1].Value + "";
            string string_Q6 = this.dgvData.Rows[5].Cells[1].Value + "";

            int int_QQ;

            #region 儲存UDT資料
            UDT.Approach approach = new UDT.Approach();

            approach.LastUpdateTime = DateTime.Now;
            approach.StudentID      = int.Parse(this.PrimaryKey);
            approach.SurveyYear     = int.Parse(this.txtSurveyYear.Text.Trim());
            approach.Q6             = string_Q6;
            approach.Memo           = txtMemo.Text;

            approach.Q1 = int.Parse(this.dgvData.Rows[0].Cells[1].Value + "");
            if (int.TryParse(string_Q2, out int_QQ))
            {
                approach.Q2 = int_QQ;
            }
            else
            {
                approach.Q2 = null;
            }
            if (int.TryParse(string_Q3, out int_QQ))
            {
                approach.Q3 = int_QQ;
            }
            else
            {
                approach.Q3 = null;
            }
            if (int.TryParse(string_Q4, out int_QQ))
            {
                approach.Q4 = int_QQ;
            }
            else
            {
                approach.Q4 = null;
            }
            if (int.TryParse(string_Q5, out int_QQ))
            {
                approach.Q5 = int_QQ;
            }
            else
            {
                approach.Q5 = null;
            }
            #endregion

            this._BGWSaveData.RunWorkerAsync(approach);
        }
Beispiel #6
0
        public override string Import(List <EMBA.DocumentValidator.IRowStream> Rows)
        {
            strLog.Clear();
            strLog.AppendLine("詳細資料:");

            this.ExistingRecords = Access.Select <UDT.Approach>();
            //  要新增的 Record
            List <UDT.Approach> insertRecords = new List <UDT.Approach>();
            //  要更新的 Record
            List <UDT.Approach> updateRecords = new List <UDT.Approach>();

            foreach (IRowStream row in Rows)
            {
                string id_number   = row.GetValue("身分證號").Trim();
                string school_year = row.GetValue("填報學年度").Trim();

                string q1_string = row.GetValue("升學與就業情形").Trim();
                string q2_string = row.GetValue("升學:就讀學校情形").Trim();
                string q3_string = row.GetValue("升學:學制別").Trim();
                string q4_string = row.GetValue("升學:入學方式").Trim();
                string q5_string = row.GetValue("未升學未就業:動向").Trim();
                string q6_string = row.GetValue("是否需要教育部協助").Trim();
                string memo      = row.GetValue("備註").Trim();

                strLog.AppendLine("身分證號「" + id_number + "」填報學年度「" + school_year + "」升學與就業情形「" + q1_string + "」升學:就讀學校情形「" + q2_string + "」升學:入學方式「" + q3_string + "」升學:學制別「" + q4_string + "」未升學未就業:動向「" + q5_string + "」是否需要教育部協助「" + q6_string + "」備註「" + memo + "」");

                int q2_int;
                int q3_int;
                int q4_int;
                int q5_int;

                int student_id = int.Parse(this.dicStudents[id_number].ElementAt(0).Key);

                UDT.Approach record = new UDT.Approach();
                IEnumerable <UDT.Approach> filterRecords = new List <UDT.Approach>();
                filterRecords = ExistingRecords.Where(x => x.StudentID == student_id);

                if (filterRecords.Count() > 0)
                {
                    record = filterRecords.OrderByDescending(x => x.LastUpdateTime).ElementAt(0);
                    updateRecords.Add(record);
                }
                else
                {
                    insertRecords.Add(record);
                }

                int q1 = int.Parse(q1_string);

                record.StudentID  = student_id;
                record.SurveyYear = int.Parse(school_year);
                record.Q1         = q1;

                if (int.TryParse(q2_string, out q2_int))
                {
                    record.Q2 = q2_int;
                }
                else
                {
                    record.Q2 = null;
                }

                if (int.TryParse(q3_string, out q3_int))
                {
                    record.Q3 = q3_int;
                }
                else
                {
                    record.Q3 = null;
                }

                if (int.TryParse(q4_string, out q4_int))
                {
                    record.Q4 = q4_int;
                }
                else
                {
                    record.Q4 = null;
                }

                if (int.TryParse(q5_string, out q5_int))
                {
                    record.Q5 = q5_int;
                }
                else
                {
                    record.Q5 = null;
                }

                record.Q6   = q6_string;
                record.Memo = memo;

                record.LastUpdateTime = DateTime.Now;
            }

            //  新增
            List <string> insertedIDs = new List <string>();

            try
            {
                insertedIDs = insertRecords.SaveAll();
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
                return(e.Message);
            }
            //  更新
            List <string> updatedIDs = new List <string>();

            try
            {
                updatedIDs = updateRecords.SaveAll();
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
                return(e.Message);
            }

            //  RaiseEvent
            if (insertedIDs.Count > 0 || updatedIDs.Count > 0)
            {
                //IEnumerable<string> uids = insertedIDs.Union(updatedIDs);
                UDT.Approach.RaiseAfterUpdateEvent();
            }

            ApplicationLog.Log("高雄市國中畢業學生進路調查.匯入", "匯入畢業學生進路", "student", "", strLog.ToString());

            return("你成功了。");
        }
        public override string Import(List<EMBA.DocumentValidator.IRowStream> Rows)
        {
            strLog.Clear();
            strLog.AppendLine("詳細資料:");

            this.ExistingRecords = Access.Select<UDT.Approach>();
            //  要新增的 Record
            List<UDT.Approach> insertRecords = new List<UDT.Approach>();
            //  要更新的 Record
            List<UDT.Approach> updateRecords = new List<UDT.Approach>();
            foreach (IRowStream row in Rows)
            {
                string id_number = row.GetValue("身分證號").Trim();
                string school_year = row.GetValue("填報學年度").Trim();

                string q1_string = row.GetValue("升學與就業情形").Trim();
                string q2_string = row.GetValue("升學:就讀學校情形").Trim();
                string q3_string = row.GetValue("升學:學制別").Trim();
                string q4_string = row.GetValue("升學:入學方式").Trim();
                string q5_string = row.GetValue("未升學未就業:動向").Trim();
                string q6_string = row.GetValue("是否需要教育部協助").Trim();
                string memo = row.GetValue("備註").Trim();

                strLog.AppendLine("身分證號「" + id_number + "」填報學年度「" + school_year + "」升學與就業情形「" + q1_string + "」升學:就讀學校情形「" + q2_string + "」升學:入學方式「" + q3_string + "」升學:學制別「" + q4_string + "」未升學未就業:動向「" + q5_string + "」是否需要教育部協助「" + q6_string + "」備註「" + memo + "」");

                int q2_int;
                int q3_int;
                int q4_int;
                int q5_int;

                int student_id = int.Parse(this.dicStudents[id_number].ElementAt(0).Key);

                UDT.Approach record = new UDT.Approach();
                IEnumerable<UDT.Approach> filterRecords = new List<UDT.Approach>();
                filterRecords = ExistingRecords.Where(x => x.StudentID == student_id);

                if (filterRecords.Count() > 0)
                {
                    record = filterRecords.OrderByDescending(x => x.LastUpdateTime).ElementAt(0);
                    updateRecords.Add(record);
                }
                else
                {
                    insertRecords.Add(record);
                }

                int q1 = int.Parse(q1_string);

                record.StudentID = student_id;
                record.SurveyYear = int.Parse(school_year);
                record.Q1 = q1;

                if (int.TryParse(q2_string, out q2_int))
                    record.Q2 = q2_int;
                else
                    record.Q2 = null;

                if (int.TryParse(q3_string, out q3_int))
                    record.Q3 = q3_int;
                else
                    record.Q3 = null;

                if (int.TryParse(q4_string, out q4_int))
                    record.Q4 = q4_int;
                else
                    record.Q4 = null;

                if (int.TryParse(q5_string, out q5_int))
                    record.Q5 = q5_int;
                else
                    record.Q5 = null;

                record.Q6 = q6_string;
                record.Memo = memo;

                record.LastUpdateTime = DateTime.Now;
            }

            //  新增
            List<string> insertedIDs = new List<string>();
            try
            {
                insertedIDs = insertRecords.SaveAll();
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
                return e.Message;
            }
            //  更新
            List<string> updatedIDs = new List<string>();
            try
            {
                updatedIDs = updateRecords.SaveAll();
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
                return e.Message;
            }

            //  RaiseEvent
            if (insertedIDs.Count > 0 || updatedIDs.Count > 0)
            {
                //IEnumerable<string> uids = insertedIDs.Union(updatedIDs);
                UDT.Approach.RaiseAfterUpdateEvent();
            }

            ApplicationLog.Log("高雄市國中畢業學生進路調查.匯入", "匯入畢業學生進路","student","", strLog.ToString());

            return "你成功了。";
        }
        protected override void OnSaveButtonClick(EventArgs e)
        {
            this.dgvData.CurrentCell = null;
            if (!Is_Validated())
            {
                MessageBox.Show("請先修正錯誤。");
                return;
            }
            this.Loading = true;

            string string_Q1 = this.dgvData.Rows[0].Cells[1].Value + "";
            string string_Q2 = this.dgvData.Rows[1].Cells[1].Value + "";
            string string_Q3 = this.dgvData.Rows[2].Cells[1].Value + "";
            string string_Q4 = this.dgvData.Rows[3].Cells[1].Value + "";
            string string_Q5 = this.dgvData.Rows[4].Cells[1].Value + "";
            string string_Q6 = this.dgvData.Rows[5].Cells[1].Value + "";

            int int_QQ;

            #region 儲存UDT資料
            UDT.Approach approach = new UDT.Approach();

            approach.LastUpdateTime = DateTime.Now;
            approach.StudentID = int.Parse(this.PrimaryKey);
            approach.SurveyYear = int.Parse(this.txtSurveyYear.Text.Trim());
            approach.Q6 = string_Q6;
            approach.Memo = txtMemo.Text;

            approach.Q1 = int.Parse(this.dgvData.Rows[0].Cells[1].Value + "");
            if (int.TryParse(string_Q2, out int_QQ))
                approach.Q2 = int_QQ;
            else
                approach.Q2 = null;
            if (int.TryParse(string_Q3, out int_QQ))
                approach.Q3 = int_QQ;
            else
                approach.Q3 = null;
            if (int.TryParse(string_Q4, out int_QQ))
                approach.Q4 = int_QQ;
            else
                approach.Q4 = null;
            if (int.TryParse(string_Q5, out int_QQ))
                approach.Q5 = int_QQ;
            else
                approach.Q5 = null;
            #endregion

            this._BGWSaveData.RunWorkerAsync(approach);
        }