protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        string activityid;
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            ((Label)e.Row.FindControl("Label1")).Text = ((Label)e.Row.FindControl("Label1")).Text.Replace("\r\n", "<br/>");

            ACMS.DAO.ActivityRegistDAO myActivityRegistDAO = new ACMS.DAO.ActivityRegistDAO();
            if (ActivityType == "1")
            {

                activityid = ((HiddenField)e.Row.FindControl("hiID")).Value;
                if (myActivityRegistDAO.IsPersonRegisted(new Guid(activityid), clsAuth.ID, "", "1") > 0)
                {
                    e.Row.FindControl("lbtnRegist").Visible = false;

                }
            }
        }
    }
    //檢查欲報名者是否已經報過名
    protected void btnNext_Click(object sender, EventArgs e)
    {
        if (Wizard1.ActiveStepIndex == 1 && MyFormMode == FormViewMode.Insert)
        {
            ACMS.DAO.ActivityRegistDAO myActivityRegistDAO = new ACMS.DAO.ActivityRegistDAO();

            if (myActivityRegistDAO.IsPersonRegisted(ActivityID, EmpID, "", "1") > 0)
            {
                clsMyObj.ShowMessage(@"已存在此員工的報名成功紀錄!請選擇其他員工執行代理報名。");
                Wizard1.MoveTo(Wizard1.WizardSteps[0]);
            }
        }
        else if (Wizard1.ActiveStepIndex == 1 && MyFormMode != FormViewMode.Insert)
        {

            if (GridView_RegisterPeoplinfo.SelectedIndex == -1)
            {
                clsMyObj.ShowMessage(@"請選擇要編輯的人員。");
                Wizard1.MoveTo(Wizard1.WizardSteps[0]);
            }
        }

        if (Wizard1.ActiveStepIndex == 2)
        {
            RadioButtonList rblidno_type = (RadioButtonList)FormView_fixA.FindControl("tr_person_fix1").FindControl("rblidno_type");
            TextBox txtperson_fix1 = (TextBox)FormView_fixA.FindControl("tr_person_fix1").FindControl("txtperson_fix1");

            if (rblidno_type.SelectedIndex == 0 && rblidno_type.Visible )
            {
                if (clsMyObj.IDChk(txtperson_fix1.Text) != "0")
                {
                    clsMyObj.ShowMessage("身分證字號格式不正確!");
                    Wizard1.MoveTo(Wizard1.WizardSteps[1]);
                }
            }
        }
    }
    //隊員RowDataBound
    protected void GridView_TemMember_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header && (MyFormMode == FormViewMode.Edit || MyFormMode == FormViewMode.ReadOnly ))
        {
          //  e.Row.FindControl("chkDelHead").Visible = false;
          //  e.Row.FindControl("lbtnVOdeleteHeader").Visible = false;

        }
        ACMS.DAO.ActivityRegistDAO regDao = new ACMS.DAO.ActivityRegistDAO();
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            //團長不可被刪除
            ACMS.VO.ActivityTeamMemberVO myActivityTeamMemberVO = (ACMS.VO.ActivityTeamMemberVO)(e.Row.DataItem);

            if (myActivityTeamMemberVO.emp_id == myActivityTeamMemberVO.boss_id)
            {
                (e.Row.FindControl("lbtnVOdelete") as LinkButton).Visible = false;
                (e.Row.FindControl("chkDel")).Visible = false;
            }

            if (regDao.IsPersonRegisted(ActivityID,myActivityTeamMemberVO.emp_id ,"","2")>0)
            {

             (e.Row.FindControl("lbtnVOdelete") as LinkButton).Visible = false;
             (e.Row.FindControl("chkDel")).Visible = false;

            }

            //團長能改大家的資料,但是團員只能改自己的資料
            if (EmpID != RegistBy)
            {
                if (GridView_TemMember.DataKeys[e.Row.RowIndex].Value.ToString() != EmpID)
                {
                    (e.Row.FindControl("lbtnVOedit") as LinkButton).Visible = false;
                }
                (e.Row.FindControl("lbtnVOdelete") as LinkButton).Visible = false;
               // (e.Row.FindControl("chkDel")).Visible = false;
            }

            //==如果是Edit則不可刪除人員
            if (MyFormMode == FormViewMode.Edit)
            {
                (e.Row.FindControl("lbtnVOdelete") as LinkButton).Visible = false;
               // (e.Row.FindControl("chkDel")).Visible = false;
            }

        }
    }
예제 #4
0
    //團隊活動報名或取消報名
    public AlterRegistResult AlterRegist_Team(ActivityRegistVO myActivityRegistVO, List<CustomFieldValueVO> myCustomFieldValueVOList, List<ActivityTeamMemberVO> myActivityTeamMemberVOList, AlterRegistType myAlterRegistType, Guid activity_id, string emp_id, string regist_deadline, string cancelregist_deadline ,string webPath,string path,  string  allTeam ,string  RegWebPath )
    {
        lock (this)
        {
            if (myAlterRegistType == AlterRegistType.RegistInsert || myAlterRegistType == AlterRegistType.RegistUpdate)
            {
                string strEmp_id = "";
                foreach (ACMS.VO.ActivityTeamMemberVO myActivityTeamMemberVO in myActivityTeamMemberVOList)
                {
                    strEmp_id += string.Format("{0},", myActivityTeamMemberVO.emp_id);
                }

                if (strEmp_id.EndsWith(","))
                {
                    strEmp_id = strEmp_id.Substring(0, strEmp_id.Length - 1);
                }

                ACMS.DAO.ActivityRegistDAO myActivityRegistDAO = new ACMS.DAO.ActivityRegistDAO();

                if (myAlterRegistType == AlterRegistType.RegistInsert)
                {
                    //先Insert報名資訊看是否成功
                    int intSaveResult = myActivityRegistDAO.UpdateActivityRegist(myActivityRegistVO, myCustomFieldValueVOList, myActivityTeamMemberVOList, "insert", "2",webPath,path);

                    if (intSaveResult == 1)
                    {
                        //andy-報名成功寄信
                        clsMyObj.RegistSuccess_Team(myActivityRegistVO.activity_id.ToString(), strEmp_id, myActivityRegistVO.regist_by,webPath,path);

                        return AlterRegistResult.RegistSucess;
                    }
                    else
                    {
                        //若失敗可能是重複報名或額滿

                        //是否重複報名

                        int RegistCount = myActivityRegistDAO.IsPersonRegisted(myActivityRegistVO.activity_id, strEmp_id, myActivityRegistVO.regist_by, "2");

                        if (RegistCount > 0)
                        {
                            //andy-報名失敗寄信
                           // clsMyObj.RegistFail_Team(myActivityRegistVO.activity_id.ToString(), strEmp_id, myActivityRegistVO.regist_by,webPath);

                            return AlterRegistResult.RegistFail_Already;
                        }

                        //是否已額滿
                        int RegistableCount = myActivityRegistDAO.RegistableCount(myActivityRegistVO.activity_id);

                        if (RegistableCount <= 0)
                        {
                            //andy-報名失敗寄信
                            //clsMyObj.RegistFail_Team(myActivityRegistVO.activity_id.ToString(), strEmp_id, myActivityRegistVO.regist_by,webPath);

                            return AlterRegistResult.RegistFail_Full;
                        }

                        //andy-報名失敗寄信
                        //clsMyObj.RegistFail_Team(myActivityRegistVO.activity_id.ToString(), strEmp_id, myActivityRegistVO.regist_by,webPath);

                        return AlterRegistResult.RegistFail;
                    }

                }
                else
                {
                    int intSaveResult = myActivityRegistDAO.UpdateActivityRegist(myActivityRegistVO, myCustomFieldValueVOList, myActivityTeamMemberVOList, "update","2",webPath,path);

                    if (intSaveResult == 1)
                    {
                        //團隊修改寄信
                        if (allTeam == "All")//全隊取消
                        {
                            clsMyObj.CancelRegist_TeamUnderLimit(myActivityRegistVO.activity_id.ToString(), strEmp_id, myActivityRegistVO.regist_by, RegWebPath);
                        }

                        else
                        {
                            clsMyObj.RegistSuccess_Team(myActivityRegistVO.activity_id.ToString(), strEmp_id, myActivityRegistVO.regist_by, webPath, path);
                        }

                        return AlterRegistResult.UpdateRegistSucess;
                    }
                    else
                    {
                        //因為團長會異動報名的人,所以要檢查是否選到重複的人
                        if (myActivityRegistVO.emp_id == myActivityRegistVO.regist_by)
                        {
                            //是否重複報名

                            int RegistCount = myActivityRegistDAO.IsPersonRegisted(myActivityRegistVO.activity_id, strEmp_id, myActivityRegistVO.regist_by, "2");

                            if (RegistCount > 0)
                            {
                                //andy-報名失敗寄信
                               // clsMyObj.RegistFail_Team(myActivityRegistVO.activity_id.ToString(), strEmp_id, myActivityRegistVO.regist_by, webPath);

                                return AlterRegistResult.RegistFail_Already;
                            }
                        }

                        return AlterRegistResult.UpdateRegistFail;
                    }
                }

            }
            else
            {
                //報名截止日之前-刪除
                //報名截止日之後-狀態改取消
                //取消報名截止日之後-不可以取消

                ACMS.DAO.ActivityRegistDAO myActivityRegistDAO = new ACMS.DAO.ActivityRegistDAO();
               // myActivityRegistDAO.InsertActivityRegistCancel(activity_id, emp_id, "2", clsAuth.ID);

                if (Convert.ToDateTime(regist_deadline) >= DateTime.Today)
                {
                    //取消報名截止日之前-刪除
                    if (myActivityRegistDAO.DeleteRegist(activity_id, emp_id,"2",webPath,allTeam ,RegWebPath  ) > 0)
                    {
                        //寄信
                        //clsMyObj.RegistSuccess_Team(activity_id.ToString (), emp_id, "", webPath);

                        return AlterRegistResult.CancelRegistSucess;
                    }
                    else
                    {
                        return AlterRegistResult.CancelRegistFail;
                    }
                }
                else if (Convert.ToDateTime(regist_deadline) < DateTime.Today)
                {
                    //取消報名截止日之後-狀態改取消
                    if (myActivityRegistDAO.CancelRegist(activity_id, emp_id,"2",webPath) > 0)
                    {
                        //寄信
                       // clsMyObj.RegistSuccess_Team(activity_id.ToString(), emp_id,"", webPath,path);

                        return AlterRegistResult.CancelRegistSucess;
                    }
                    else
                    {
                        return AlterRegistResult.CancelRegistFail;
                    }
                }
                else if (Convert.ToDateTime(cancelregist_deadline) < DateTime.Today)
                {
                    //取消報名截止日之後-不可以取消
                    return AlterRegistResult.CancelRegistFail_DayOver;
                }

                return AlterRegistResult.CancelRegistFail;

            }

        }
    }
예제 #5
0
    //個人活動報名或取消報名
    public AlterRegistResult AlterRegist(ActivityRegistVO myActivityRegistVO, List<CustomFieldValueVO> myCustomFieldValueVOList, AlterRegistType myAlterRegistType, Guid activity_id, string emp_id,string regist_deadline, string cancelregist_deadline, string webPath ,string path,string allTeam,string RegWebPath)
    {
        lock (this)
        {
            if (myAlterRegistType == AlterRegistType.RegistInsert || myAlterRegistType == AlterRegistType.RegistUpdate)
            {
                ACMS.DAO.ActivityRegistDAO myActivityRegistDAO = new ACMS.DAO.ActivityRegistDAO();

                if (myAlterRegistType == AlterRegistType.RegistInsert)
                {
                    //先Insert報名資訊看是否成功
                    int intSaveResult = myActivityRegistDAO.UpdateActivityRegist(myActivityRegistVO, myCustomFieldValueVOList, null, "insert", "1",webPath ,path);
                    if (intSaveResult == 1)
                    {
                        //andy-報名成功寄信
                        clsMyObj.RegistSuccess(myActivityRegistVO.activity_id.ToString(), myActivityRegistVO.emp_id, myActivityRegistVO.regist_by,webPath ,path  );

                        return AlterRegistResult.RegistSucess;
                    }
                    else
                    {
                        //若失敗可能是重複報名或額滿

                        //是否重複報名
                        int RegistCount = myActivityRegistDAO.IsPersonRegisted(myActivityRegistVO.activity_id, myActivityRegistVO.emp_id,"", "1");

                        if (RegistCount > 0)
                        {
                            //andy-報名失敗寄信
                           // clsMyObj.RegistFail(myActivityRegistVO.activity_id.ToString(), myActivityRegistVO.emp_id, myActivityRegistVO.regist_by,webPath );

                            return AlterRegistResult.RegistFail_Already;
                        }

                        //是否已額滿
                        int RegistableCount = myActivityRegistDAO.RegistableCount(myActivityRegistVO.activity_id);

                        if (RegistableCount <= 0)
                        {
                            //andy-報名失敗寄信
                            //clsMyObj.RegistFail(myActivityRegistVO.activity_id.ToString(), myActivityRegistVO.emp_id, myActivityRegistVO.regist_by,webPath );
                            return AlterRegistResult.RegistFail_Full;
                        }

                        //andy-報名失敗寄信
                       // clsMyObj.RegistFail(myActivityRegistVO.activity_id.ToString(), myActivityRegistVO.emp_id, myActivityRegistVO.regist_by,webPath );

                        return AlterRegistResult.RegistFail;
                    }

                }
                else
                {
                    int intSaveResult = myActivityRegistDAO.UpdateActivityRegist(myActivityRegistVO, myCustomFieldValueVOList, null, "update", "1",webPath,path);
                    if (intSaveResult == 1)
                    {
                        //andy-個人修改成功寄信
                        clsMyObj.RegistSuccessUpdate(myActivityRegistVO.activity_id.ToString(), myActivityRegistVO.emp_id, myActivityRegistVO.regist_by, webPath, path);

                        return AlterRegistResult.UpdateRegistSucess;

                    }
                    else
                    {
                        return AlterRegistResult.UpdateRegistFail;
                    }
                }

            }
            else
            {
                //報名截止日之前-刪除
                //報名截止日之後-狀態改取消
                //取消報名截止日之後-不可以取消

                ACMS.DAO.ActivityRegistDAO myActivityRegistDAO = new ACMS.DAO.ActivityRegistDAO();

                // andy add  2011/3/28 取消前需將資料加到 ActivityRegistCancel中
                myActivityRegistDAO.InsertActivityRegistCancel(activity_id, emp_id, "1", clsAuth.ID);

                if (Convert.ToDateTime(regist_deadline) >=DateTime.Today)
                {
                    //報名截止日之前-刪除
                    if (myActivityRegistDAO.DeleteRegist(activity_id, emp_id, "1",webPath, allTeam,RegWebPath  ) > 0)
                    {
                        //andy-取消報名寄信
                        clsMyObj.CancelRegist( activity_id.ToString(),  emp_id, clsAuth.ID,RegWebPath );

                        return AlterRegistResult.CancelRegistSucess;
                    }
                    else
                    {
                        return AlterRegistResult.CancelRegistFail;
                    }
                }
                else if (Convert.ToDateTime(regist_deadline) < DateTime.Today)
                {
                    //報名截止日之後-狀態改取消
                    if (myActivityRegistDAO.CancelRegist(activity_id, emp_id, "1",webPath) > 0)
                    {
                        //andy-取消報名寄信
                        clsMyObj.CancelRegist(activity_id.ToString(), emp_id, clsAuth.ID,webPath);

                        return AlterRegistResult.CancelRegistSucess;
                    }
                    else
                    {
                        return AlterRegistResult.CancelRegistFail;
                    }
                }
                else if (Convert.ToDateTime(cancelregist_deadline) < DateTime.Today)
                {
                    //取消報名截止日之後-不可以取消
                    return AlterRegistResult.CancelRegistFail_DayOver;
                }

                return AlterRegistResult.CancelRegistFail;

            }

        }
    }
    //完成
    protected void FinishButton_Click(object sender, EventArgs e)
    {
        ACMS.DAO.ActivityGroupLimitDAO  limDAO=new ACMS.DAO.ActivityGroupLimitDAO ();

        //預覽時
        if (Session["form_mode1"] != null)
        {
            if (Session["form_mode1"].ToString() == "preview")
            {
                Session.Remove("form_mode1");
                Response.Redirect("~/WebForm/ManageActivity/ActivityEditQuery.aspx");
            }
        }

        if (MyFormMode == FormViewMode.ReadOnly)
        {
            Response.Redirect("RegistedActivityQuery.aspx?type=1");
        }
        try
        {
            //以新增方式進來時
            ACMS.VO.ActivityRegistVO myActivityRegistVO = GetActivityRegistVO(); //取得報名資訊
            ACMS.DAO.ActivityRegistDAO dao = new ACMS.DAO.ActivityRegistDAO();
            List<ACMS.VO.CustomFieldValueVO> myCustomFieldValueVOList = GetCustomFieldValueVOList();//取得自訂欄位值
            //ACMS.DAO.ActivityRegistDAO myActivityRegistDAO = new ACMS.DAO.ActivityRegistDAO();
            string path = Server.MapPath("~/UpFiles");
            //報名
            MySingleton.AlterRegistResult MyResult;
            if (limDAO.GroupLimitIsExist (ActivityID.ToString () ,myActivityRegistVO.emp_id )==false  )
            {

                clsMyObj.ShowMessage(myActivityRegistVO.emp_id+"不在可報名的名單中!");
                return;

            }
            if (MyFormMode == FormViewMode.Insert)
            {

                if (dao.IsPersonRegisted(ActivityID, myActivityRegistVO.emp_id, "", "1") > 0)
                {
                    clsMyObj.ShowMessage("已報名,無法重覆報名");
                    return;
                }
                if (dao.RegistableCount(ActivityID) < 0)
                {

                    clsMyObj.ShowMessage("已額滿,無法報名");
                    return;

                }

               // MyResult = MySingleton.GetMySingleton().AlterRegist(myActivityRegistVO, myCustomFieldValueVOList, MySingleton.AlterRegistType.RegistInsert, new Guid(), "", "", "", this.Page.Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.IndexOf('/', 7)) + "/ACMS/WebForm/RegistActivity/RegistedActivityQuery.aspx", path);
                string aa = string.Format("{0}://{1}{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Authority, HttpContext.Current.Request.ApplicationPath).TrimEnd('/');
                MyResult = MySingleton.GetMySingleton().AlterRegist(myActivityRegistVO, myCustomFieldValueVOList, MySingleton.AlterRegistType.RegistInsert, new Guid(), "", "", "", aa + "/Default.aspx", path, "", aa + "/Default.aspx");

            }
            else
            {
                // MyResult = MySingleton.GetMySingleton().AlterRegist(myActivityRegistVO, myCustomFieldValueVOList, MySingleton.AlterRegistType.RegistUpdate, new Guid(), "", "", "", this.Page.Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.IndexOf('/', 7)) + "/ACMS/WebForm/RegistActivity/RegistedActivityQuery.aspx",path);
                string aa = string.Format("{0}://{1}{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Authority, HttpContext.Current.Request.ApplicationPath).TrimEnd('/');
                MyResult = MySingleton.GetMySingleton().AlterRegist(myActivityRegistVO, myCustomFieldValueVOList, MySingleton.AlterRegistType.RegistUpdate, new Guid(), "", "", "", aa + "/Default.aspx", path, "", aa + "/Default.aspx");

            }

            if (MyResult == MySingleton.AlterRegistResult.RegistFail_Already)
            {
                clsMyObj.ShowMessage("已存在報名成功紀錄,無法重複報名!");
                return ;
            }
            else if (MyResult == MySingleton.AlterRegistResult.RegistFail_Full)
            {
                clsMyObj.ShowMessage(@"抱歉,報名已額滿!若錄取名額有增加則可再次報名。");
                return ;
            }
            else if (MyResult == MySingleton.AlterRegistResult.RegistFail)
            {
                clsMyObj.ShowMessage(@"資料存檔發生錯誤,無法完成報名。");
                return ;
            }
            else
            {

            }

        }
        catch (Exception ex)
        {
            WriteErrorLog("SaveData", ex.Message, "0");
            return;
        }
        Response.Redirect("RegistedActivityQuery.aspx?type=1");
    }