Esempio n. 1
0
        /*--- 報名 ---*/
        private void btnSignUp_Click(object sender, EventArgs e)
        {
            string inStr = txtName.Text.Trim();

            /*- if: 輸入內容不能為空
             *- else if: 必須選擇姓名
             *-------------------------*/
            if (inStr == "")
            {
                lblNameMsg.Visible = true; //顯示 『必須輸入』
                return;
            }
            else if (selectedName == null)
            {
                formFun.OpenFocusForm(new WarningForm("必須選擇性名"));
                return;
            }

            /*-- 確認要報名嗎? --*/
            ConfirmForm confirmForm = new ConfirmForm("確認要報名嗎?");

            formFun.OpenFocusForm(confirmForm);
            if (confirmForm.isOk)
            {
                askingTablesForm.AddNameTo_SignUpList(selectedContactNum, selectedName, txtRemark.Text);
            }
            else
            {
                return;
            }

            this.Close();
        }
        /*--- 新增聯絡資訊 ---*/
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string contactNum, addName, addPhone, addPlace, addRemarks;

            addName = txtName.Text.Trim();
            DateTime addDate = dateTime.Value;

            addPhone   = txtPhone.Text.Trim();
            addPlace   = txtPlace.Text.Trim();
            addRemarks = txtRemarks.Text.Trim();
            // Console.WriteLine("姓名: " + addName);
            //Console.WriteLine("日期: " + addDate);
            //Console.WriteLine("電話: " + addPhone);
            //Console.WriteLine("地點: " + addPlace);
            // Console.WriteLine("備註: " + addRemarks);


            /*-- 姓名和居住地不能為空 --*/
            if (addName == "" || addPlace == "")
            {
                if (addName == "")
                {
                    lblNameMsg.Visible = true;
                }
                if (addPlace == "")
                {
                    lblPlaceMsg.Visible = true;
                }

                return;
            }

            /*- 把資料加到資料庫的 Personal_Info -*/
            Message.ConfirmForm confirmForm = new Message.ConfirmForm("確認要報名嗎?");
            form.OpenFocusForm(confirmForm);

            if (confirmForm.isOk)
            {
                /* 新增的聯絡資料是否已存在 */
                if (IsRepeatData(addName, addPhone, addPlace))
                {
                    form.OpenFocusForm(new Message.WarningForm(addName + "已經新增過了"));
                    return;
                }

                /* 產生聯絡編號 */
                CodeGenerator cg = new CodeGenerator();
                contactNum = addDate.ToString("yyyyMMddhhmm") + cg.LettersCode(3);
                /* 把資料加到資料庫 */
                AddDataToDB(contactNum, addName, addPhone, addPlace, addDate, addRemarks);
                /* 如果由問事表開啟,就把資料加到問事表視窗 */
                if (isFromTableForm == true)
                {
                    askingTablesForm.AddNameTo_SignUpList(contactNum, addName, addRemarks);
                }

                this.Close();
            }
        }