Пример #1
0
 private void btnEnviar_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtMsg.Text))
     {
         bunifuSnackbar.Show(this, "Digite qualquer coisa", Bunifu.UI.WinForms.BunifuSnackbar.MessageTypes.Information);
     }
     else
     {
         if (btnStart.Text == "Conectar")
         {
             bunifuSnackbar.Show(this, "Conecte Primeiro ao seu WhatsApp", Bunifu.UI.WinForms.BunifuSnackbar.MessageTypes.Information);
         }
         else
         {
             AddToList();
             /*Progress loading start code*/
             pnProcess.Enabled = true;
             pnProcess.Visible = true;
             PicBlur.Enabled   = true;
             PicBlur.Visible   = true;
             PBB.Animated      = true;
             PBB.Visible       = true;
             PicBlur.BringToFront();
             pnProcess.BringToFront();
             pnHeader.BringToFront();
             /*Progress loading end code*/
             BGW.RunWorkerAsync();/* TODO ERROR: Progress linear */
         }
     }
 }
Пример #2
0
        void BGW_Run_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.Text        = "社團志願分配(跨部別)";
            btnStart.Enabled = true;
            if (!e.Cancelled)
            {
                if (e.Error == null)
                {
                    K12.Club.Volunteer.ClubEvents.RaiseAssnChanged();

                    this.Text        = "社團志願分配(跨部別) 資料取得中...";
                    btnStart.Enabled = false;
                    BGW.RunWorkerAsync();
                    DialogResult dr = MsgBox.Show("社團分配完成!!\n您是否要檢視分配狀況總表?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2);
                    if (dr == System.Windows.Forms.DialogResult.Yes)
                    {
                        //將LOG清單列印出來...
                        LogDic.Sort(SortLogRecord);

                        VolunteerLOG log = new VolunteerLOG(LogDic);
                        log.ShowDialog();
                    }
                }
                else
                {
                    MsgBox.Show("背景作業發生錯誤!\n" + e.Error.Message);
                }
            }
            else
            {
                MsgBox.Show("已停止志願分配!!!");
            }
        }
Пример #3
0
 private void VolunteerAssignment_Load(object sender, EventArgs e)
 {
     this.Text = "社團志願分配(跨部別) 資料取得中...";
     dataGridViewX1.Enabled = false;
     btnStart.Enabled       = false;
     BGW.RunWorkerAsync();
 }
Пример #4
0
 /// <summary>
 /// Обработчик нажатия на кнопку Поиска
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonSearch_Click(object sender, EventArgs e)
 {
     try
     {
         bool resCheck = false; // переменная для проверки заполнены ли все необходимые поля
         if (solKernel.IsEmptyBox(textBoxSubsrting.Lines))
         {                      // проверка для текста
             errorProvider.SetError(textBoxSubsrting, "Введите строку, которую необходимо найти");
             resCheck = true;
         }
         if (solKernel.IsEmptyBox(richTextBoxText.Lines))
         { // проверка для образца
             errorProvider.SetError(richTextBoxText, "Введите текст, в котором будет проводится поиск");
             resCheck = true;
         }
         if (resCheck == true) // если нет значения хотя бы в одном поле, то прерываем метод для поиска
         {
             return;
         }
         solKernel.BlockAllButtons(); // блокируем все клавиши , которые могут повлиять на текст
         // Создаем структуру с данными небоходимыми для нового потока
         ParamsForNewThread _params = new ParamsForNewThread(richTextBoxText.Lines, textBoxSubsrting.Text);
         BGW.RunWorkerAsync(_params);   // создаем новый поток (вызывем асинхронный метод)
     }
     catch (Exception ex)               // если случилось исключение
     {
         solKernel.UnblockAllButtons(); // разблокируем все кнопки и выведем сообщение об ошибке
         MessageBox.Show($"{ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
Пример #5
0
 private void GenerateReadings_Load(object sender, EventArgs e)
 {
     if (process == 1 && !BGW.IsBusy)
     {
         label1.Text = "Please Wait while POS generates previously ungenerated Zreadings";
         BGW.RunWorkerAsync();
     }
 }
Пример #6
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (K12.Club.Volunteer.ClubAdmin.Instance.SelectedSource.Count == 0)
            {
                MsgBox.Show("請選擇社團");
                return;
            }

            if (FISCA.Authentication.DSAServices.PassportToken == null)
            {
                MsgBox.Show("請使用ischool Account登入\n再使用跨部別功能!!");
                return;
            }

            if (!BGW.IsBusy)
            {
                this.Text = "社團點名單(跨部別) 資料處理中...";

                #region 日期設定

                if (dataGridViewX1.Rows.Count <= 0)
                {
                    MsgBox.Show("列印點名單必須有日期!!");
                    return;
                }

                DSXmlHelper dxXml = new DSXmlHelper("XmlData");

                foreach (DataGridViewRow row in dataGridViewX1.Rows)
                {
                    string 日期 = "" + row.Cells[0].Value;
                    dxXml.AddElement(".", "item", 日期);
                }

                #endregion

                btnStart.Enabled = false;
                BGW.RunWorkerAsync(dxXml.BaseElement);
            }
            else
            {
                MsgBox.Show("系統忙碌中...請稍後!!");
            }

            // 儲存日期設定
            // 讀取日期清單資料
            string node = "";
            foreach (DataGridViewRow dr in dataGridViewX1.Rows)
            {
                node += "<Dgv date = \"" + dr.Cells["Column1"].Value + "\" week = \"" + dr.Cells["column2"].Value + "\"></Dgv>";
            }

            string settingData = string.Format(@"<DateSetting><Weeks><Week name = ""Monday"" checked = ""{0}""/><Week name = ""Tuesday"" checked = ""{1}"" /><Week name = ""Wednesday"" checked = ""{2}"" /><Week name = ""Thursday"" checked = ""{3}"" /><Week name = ""Friday"" checked = ""{4}"" /><Week name = ""Saturday"" checked = ""{5}"" /><Week name = ""Sunday"" checked = ""{6}"" /></Weeks><StarDate Date = ""{7}"" ></StarDate><EndDate Date = ""{8}"" ></EndDate><DataGridView>{9}</DataGridView></DateSetting>"
                                               , cbDay1.Checked, cbDay2.Checked, cbDay3.Checked, cbDay4.Checked, cbDay5.Checked, cbDay6.Checked, cbDay7.Checked, dateTimeInput1.Value, dateTimeInput2.Value, node);

            DateSetting["DateSetting"] = settingData;
            DateSetting.Save();
        }
Пример #7
0
        // No deben existir componentes gui acá (esto estará en background)
        private void BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            for (int i = 0; i <= 100; i++)
            {
                // Si hay petición de cancelaci´´on lo cancelamos
                if (BGW.CancellationPending)
                {
                    e.Cancel = true;
                }

                Thread.Sleep(200);
                BGW.ReportProgress(i);
            }
        }
Пример #8
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (K12.Club.Volunteer.ClubAdmin.Instance.SelectedSource.Count == 0)
            {
                MsgBox.Show("請選擇社團");
                return;
            }

            if (FISCA.Authentication.DSAServices.PassportToken == null)
            {
                MsgBox.Show("請使用ischool Account登入\n再使用跨部別功能!!");
                return;
            }

            if (!BGW.IsBusy)
            {
                this.Text = "社團點名單(跨部別) 資料處理中...";

                #region 日期設定

                if (dataGridViewX1.Rows.Count <= 0)
                {
                    MsgBox.Show("列印點名單必須有日期!!");
                    return;
                }

                DSXmlHelper dxXml = new DSXmlHelper("XmlData");

                foreach (DataGridViewRow row in dataGridViewX1.Rows)
                {
                    string 日期 = "" + row.Cells[0].Value;
                    dxXml.AddElement(".", "item", 日期);
                }

                #endregion

                btnStart.Enabled = false;
                BGW.RunWorkerAsync(dxXml.BaseElement);
            }
            else
            {
                MsgBox.Show("系統忙碌中...請稍後!!");
            }
        }
Пример #9
0
 private void InvokeViaBgw(Action action)
 {
     BGW.ReportProgress(0, action);
 }
Пример #10
0
 private void BtnCancel_Click(object sender, EventArgs e)
 {
     BGW.CancelAsync();
 }
Пример #11
0
 private void BtnStart_Click(object sender, EventArgs e)
 {
     BGW.RunWorkerAsync();
 }
Пример #12
0
        // 列印
        private void btnPrint_Click_1(object s, EventArgs ea)
        {
            if (comboBox_ChooseSchoolYear.SelectedItem == null)
            {
                // 請使用者一定要選擇學年度,否則系統會當機
                MsgBox.Show("請先選擇學年度");
            }
            else
            {
                string schoolYear = comboBox_ChooseSchoolYear.Text;
                string returnDate = textBoxHandInDay.Text;
                string printDate  = DateTime.Today.ToShortDateString();

                BackgroundWorker BGW = new BackgroundWorker();
                BGW.WorkerReportsProgress = true;

                BGW.DoWork += delegate(object sender, DoWorkEventArgs e)
                {
                    #region DoWork
                    FISCA.UDT.AccessHelper accessHelper = new FISCA.UDT.AccessHelper();

                    Aspose.Words.Document Template;
                    Template = new Aspose.Words.Document(new MemoryStream(Properties.Resources.班級體適能確認單範本1));
                    // 取得選取班級
                    List <ClassRecord> ClassList = K12.Data.Class.SelectByIDs(K12.Presentation.NLDPanels.Class.SelectedSource);
                    Dictionary <string, StudentFitnessRecord> dicStudentFitnessRecord = new Dictionary <string, StudentFitnessRecord>();
                    var studentIDList = new List <string>();
                    foreach (ClassRecord classrecord in ClassList)
                    {
                        foreach (var studentRec in classrecord.Students)
                        {
                            studentIDList.Add(studentRec.ID);
                        }
                    }
                    BGW.ReportProgress(10);

                    var studentFitnessRecordList = accessHelper.Select <StudentFitnessRecord>(string.Format("ref_student_id in ('{0}') AND school_year = {1}", string.Join("','", studentIDList), schoolYear));

                    foreach (var fitnessRec in studentFitnessRecordList)
                    {
                        //2021/3/16 -  如果沒有新增,避免爆掉
                        //- By Dylan
                        if (!dicStudentFitnessRecord.ContainsKey(fitnessRec.StudentID))
                        {
                            dicStudentFitnessRecord.Add(fitnessRec.StudentID, fitnessRec);
                        }
                        else
                        {
                            StudentRecord stud = K12.Data.Student.SelectByID(fitnessRec.StudentID);
                            MsgBox.Show(string.Format("學生「{0}」體適能資料重複\n(一學年僅會有一筆體適能紀錄)", stud.Name));
                        }
                    }

                    BGW.ReportProgress(20);

                    //填資料部份
                    DataTable table = new DataTable();
                    table.Columns.Add("製表日期");
                    table.Columns.Add("學年");
                    table.Columns.Add("學期");
                    table.Columns.Add("班級");
                    table.Columns.Add("導師");
                    table.Columns.Add("繳回日期");


                    int classIndex = 0;
                    foreach (ClassRecord classRec in ClassList)
                    {
                        DataRow row = table.NewRow();
                        row["學年"] = schoolYear;

                        row["班級"] = classRec.Name;

                        if (classRec.Teacher != null)
                        {
                            row["導師"] = classRec.Teacher.Name;
                        }
                        //  取得視窗輸入的繳回日期
                        row["繳回日期"] = returnDate;

                        row["製表日期"] = printDate;

                        int studentCounter = 0;

                        foreach (StudentRecord studentRec in classRec.Students)
                        {
                            //2016/11/11 穎驊更正,限制抓取"一般"狀態的學生,要不然會在同一班 抓到畢業、休學、刪除的學生資料
                            if (studentRec.Status == StudentRecord.StudentStatus.一般)
                            {
                                string col = "";

                                col = string.Format("姓名{0}", studentCounter);
                                if (!table.Columns.Contains(col))
                                {
                                    table.Columns.Add(col);
                                }
                                row[col] = studentRec.Name;

                                col = string.Format("座號{0}", studentCounter);
                                if (!table.Columns.Contains(col))
                                {
                                    table.Columns.Add(col);
                                }
                                row[col] = studentRec.SeatNo;

                                if (dicStudentFitnessRecord.ContainsKey(studentRec.ID))
                                {
                                    col = string.Format("測驗日期{0}", studentCounter);
                                    if (!table.Columns.Contains(col))
                                    {
                                        table.Columns.Add(col);
                                    }
                                    row[col] = dicStudentFitnessRecord[studentRec.ID].TestDate.ToShortDateString();

                                    col = string.Format("身高{0}", studentCounter);
                                    if (!table.Columns.Contains(col))
                                    {
                                        table.Columns.Add(col);
                                    }
                                    row[col] = dicStudentFitnessRecord[studentRec.ID].Height;

                                    col = string.Format("體重{0}", studentCounter);
                                    if (!table.Columns.Contains(col))
                                    {
                                        table.Columns.Add(col);
                                    }
                                    row[col] = dicStudentFitnessRecord[studentRec.ID].Weight;

                                    col = string.Format("坐姿體前彎{0}", studentCounter);
                                    if (!table.Columns.Contains(col))
                                    {
                                        table.Columns.Add(col);
                                    }
                                    row[col] = dicStudentFitnessRecord[studentRec.ID].SitAndReach;

                                    col = string.Format("坐姿體前彎常模{0}", studentCounter);
                                    if (!table.Columns.Contains(col))
                                    {
                                        table.Columns.Add(col);
                                    }
                                    row[col] = dicStudentFitnessRecord[studentRec.ID].SitAndReachDegree;

                                    col = string.Format("立定跳遠{0}", studentCounter);
                                    if (!table.Columns.Contains(col))
                                    {
                                        table.Columns.Add(col);
                                    }
                                    row[col] = dicStudentFitnessRecord[studentRec.ID].StandingLongJump;

                                    col = string.Format("立定跳遠常模{0}", studentCounter);
                                    if (!table.Columns.Contains(col))
                                    {
                                        table.Columns.Add(col);
                                    }
                                    row[col] = dicStudentFitnessRecord[studentRec.ID].StandingLongJumpDegree;

                                    col = string.Format("仰臥起坐{0}", studentCounter);
                                    if (!table.Columns.Contains(col))
                                    {
                                        table.Columns.Add(col);
                                    }
                                    row[col] = dicStudentFitnessRecord[studentRec.ID].SitUp;

                                    col = string.Format("仰臥起坐常模{0}", studentCounter);
                                    if (!table.Columns.Contains(col))
                                    {
                                        table.Columns.Add(col);
                                    }
                                    row[col] = dicStudentFitnessRecord[studentRec.ID].SitUpDegree;

                                    col = string.Format("心肺適能{0}", studentCounter);
                                    if (!table.Columns.Contains(col))
                                    {
                                        table.Columns.Add(col);
                                    }
                                    row[col] = dicStudentFitnessRecord[studentRec.ID].Cardiorespiratory;

                                    col = string.Format("心肺適能常模{0}", studentCounter);
                                    if (!table.Columns.Contains(col))
                                    {
                                        table.Columns.Add(col);
                                    }
                                    row[col] = dicStudentFitnessRecord[studentRec.ID].CardiorespiratoryDegree;
                                }

                                studentCounter++;

                                //2016/11/11 光棍節,穎驊新增,由於目前Word樣板只支援38個學生,當班級學生數量將會有印不下的問題,
                                //因此 將第39位後的學生資料,印在第二頁、第三頁...
                                if (studentCounter >= 38)
                                {
                                    studentCounter = 0;
                                    table.Rows.Add(row);

                                    row = table.NewRow();

                                    row["學年"] = schoolYear;

                                    row["班級"] = classRec.Name;

                                    if (classRec.Teacher != null)
                                    {
                                        row["導師"] = classRec.Teacher.Name;
                                    }
                                    //  取得視窗輸入的繳回日期
                                    row["繳回日期"] = returnDate;

                                    row["製表日期"] = printDate;
                                }
                            }
                        }
                        // 一個row 一班
                        if (studentCounter != 0)
                        {
                            table.Rows.Add(row);
                        }

                        classIndex++;
                        BGW.ReportProgress(20 + classIndex * 80 / ClassList.Count);
                    }

                    #region 自動生成功變數代碼(開發用很方便,平常註解掉)

                    // 雖然已經講過了,但穎驊不得不大力推薦,這~真~的~超~級~好~用~的!!! 原本自己手動改,三個小時還不一全部改得完、正確,
                    // 用程式自動產生功能變數mailmerge名稱後,十分鐘內就完成&確認檢查完畢了


                    //Document doc = new Document();
                    //DocumentBuilder bu = new DocumentBuilder(doc);
                    //bu.MoveToDocumentStart();
                    //bu.CellFormat.Borders.LineStyle = LineStyle.Single;
                    //bu.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
                    //Table table1 = bu.StartTable();

                    //List<string> fitnessItem = new List<string>();

                    //fitnessItem.Add("座號");
                    //fitnessItem.Add("姓名");
                    //fitnessItem.Add("測驗日期");
                    //fitnessItem.Add("身高");
                    //fitnessItem.Add("體重");
                    //fitnessItem.Add("坐姿體前彎");
                    //fitnessItem.Add("坐姿體前彎常模");
                    //fitnessItem.Add("立定跳遠");
                    //fitnessItem.Add("立定跳遠常模");
                    //fitnessItem.Add("仰臥起坐");
                    //fitnessItem.Add("仰臥起坐常模");
                    //fitnessItem.Add("心肺適能");
                    //fitnessItem.Add("心肺適能常模");

                    //    foreach (String item in fitnessItem)
                    //    {
                    //        for (int fitnessCounter = 0; fitnessCounter < 40; fitnessCounter++)
                    //        {
                    //        bu.InsertCell();
                    //        bu.CellFormat.Width = 15;
                    //        bu.InsertField("MERGEFIELD " + item + fitnessCounter + @" \* MERGEFORMAT", "«»");
                    //        bu.ParagraphFormat.Alignment = ParagraphAlignment.Center;
                    //        bu.InsertCell();
                    //        bu.CellFormat.Width = 125;
                    //        bu.Write(item + fitnessCounter);
                    //        bu.ParagraphFormat.Alignment = ParagraphAlignment.Left;
                    //        bu.EndRow();

                    //    }

                    //}
                    //    table1.AllowAutoFit = false;
                    //bu.EndTable();
                    //Document PageOne = (Document)Template.Clone(true);
                    //PageOne = doc;

                    # endregion

                    Document PageOne = (Document)Template.Clone(true);
                    PageOne.MailMerge.Execute(table);
                    PageOne.MailMerge.DeleteFields();


                    e.Result = PageOne;
                    #endregion
                };

                BGW.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e)
                {
                    FISCA.Presentation.MotherForm.SetStatusBarMessage("班級體適能通知單產生中...", e.ProgressPercentage);
                };

                BGW.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    #region RunWorkerCompleted
                    if (e.Cancelled)
                    {
                        MsgBox.Show("作業已被中止!!");
                    }
                    else
                    {
                        if (e.Error == null)
                        {
                            Document inResult = (Document)e.Result;

                            try
                            {
                                SaveFileDialog SaveFileDialog1 = new SaveFileDialog();

                                SaveFileDialog1.Filter   = "Word (*.docx)|*.docx|所有檔案 (*.*)|*.*";
                                SaveFileDialog1.FileName = "班級體適能通知單";

                                if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
                                {
                                    inResult.Save(SaveFileDialog1.FileName);
                                    Process.Start(SaveFileDialog1.FileName);
                                }
                                else
                                {
                                    FISCA.Presentation.Controls.MsgBox.Show("檔案未儲存");
                                    return;
                                }
                            }
                            catch
                            {
                                FISCA.Presentation.Controls.MsgBox.Show("檔案儲存錯誤,請檢查檔案是否開啟中!!");
                                return;
                            }

                            FISCA.Presentation.MotherForm.SetStatusBarMessage("班級體適能通知單產生完成", 100);
                        }
                        else
                        {
                            MsgBox.Show("列印資料發生錯誤\n" + e.Error.Message);
                        }
                    }
                    #endregion
                };

                FISCA.Presentation.MotherForm.SetStatusBarMessage("班級體適能通知單產生中...", 0);

                BGW.RunWorkerAsync();
                this.Close();
            }