public void Save(SQLiteDatabase sqlDatabase) { if (sqlDatabase.IsOpen) { if (IsNew) { Log.Info(TAG, "Save: Attempting to Save new Activity..."); try { ContentValues values = new ContentValues(); values.Put("ActivityDate", string.Format("{0:yyyy-MM-dd HH:mm:ss}", ActivityDate)); ActivityID = (int)sqlDatabase.Insert("Activities", null, values); Log.Info(TAG, "Save: Saved Activity with ID - " + ActivityID.ToString()); foreach (ActivityTime activityTime in ActivityTimes) { activityTime.IsNew = true; if (!string.IsNullOrEmpty(activityTime.ActivityName.Trim())) { Log.Info(TAG, "Save: Found ActivityTime - " + activityTime.ActivityName); activityTime.ActivityID = ActivityID; Log.Info(TAG, "Save: Assigned ID " + ActivityID.ToString() + " for " + activityTime.ActivityName); Log.Info(TAG, "Save: Calling Save for the ActivityTime..."); activityTime.Save(sqlDatabase); } } IsNew = false; IsDirty = false; } catch (Exception newE) { throw new Exception("Unable to save Activity - " + newE.Message); } } if (IsDirty) { Log.Info(TAG, "Save: No need to update existing Activity"); try { foreach (ActivityTime activityTime in ActivityTimes) { Log.Info(TAG, "Save: Attempting to Save ActivityTime with ActivityID " + activityTime.ActivityID.ToString() + " (reported as " + (activityTime.IsNew ? "New" : "Dirty") + " item)"); if (activityTime.IsNew) { activityTime.ActivityID = ActivityID; } activityTime.Save(sqlDatabase); } IsDirty = false; } catch (Exception dirtyE) { throw new Exception("Unable to Update Activity - " + dirtyE.Message); } } } }
private void GetActivityDefault() { try { InitQueryBlock(ActivityID.ToString()); //取得活動資訊 ACMS.DAO.ActivatyDAO myActivatyDAO = new ACMS.DAO.ActivatyDAO(); ACMS.VO.ActivatyVO myActivatyVO = myActivatyDAO.SelectActivatyByID(ActivityID); //報名截止日後要唯讀 if (myActivatyVO.regist_deadline < DateTime.Today) { MyFormMode = FormViewMode.ReadOnly; //GridView_RegisterPeoplinfo.Enabled = false; PanelCustomFieldA1.Enabled = false; } if (MyFormMode == FormViewMode.Edit) { Wizard1.FindControl("FinishNavigationTemplateContainerID$btnHome").Visible = true; ((Button)Wizard1.FindControl("FinishNavigationTemplateContainerID$FinishButton")).Text = "儲存並發送確認信"; } //活動海報訊息 Literal1.Text = myActivatyVO.activity_info; //活動相關訊息 ObjectDataSource_ActivatyDetails.SelectParameters["id"].DefaultValue = ActivityID.ToString(); ObjectDataSource_UpFiles.SelectParameters["dirName"].DefaultValue = Server.MapPath(Path.Combine("~/UpFiles", ActivityID.ToString())); //報名者資訊 ObjectDataSource_RegisterPersonInfo.SelectParameters["emp_id"].DefaultValue = clsAuth.ID;//預設登入者 //所有報名者資訊 ObjectDataSource_RegisterPeoplenfo.SelectParameters["activity_id"].DefaultValue = ActivityID.ToString(); ObjectDataSource_RegisterPeoplenfo.SelectParameters["emp_id"].DefaultValue = RegistBy;//由登入者所報名(含登入者本人) //注意事項 Literal_notice.Text = myActivatyVO.notice.Replace("\r\n", "<br />"); FormView_fixA.DataBind(); ACMS.BO.CustomFieldBO myCustFieldBo = new ACMS.BO.CustomFieldBO(); if (myCustFieldBo.SelectByActivity_id(ActivityID).Count > 0) { Session["ShowPanel"] = true; } } catch (Exception ex) { WriteErrorLog("GetDefault", ex.Message, "0"); } //FormView_fixA.FindControl("tr_person_fix1").Visible = (myActivatyVO.is_showperson_fix1 == "Y"); //FormView_fixA.FindControl("tr_person_fix2").Visible = (myActivatyVO.is_showperson_fix2 == "Y"); //(FormView_fixA.FindControl("tr_person_fix2").FindControl("lblAf2Start") as Label).Text = myActivatyVO.personextcount_min.ToString(); //(FormView_fixA.FindControl("tr_person_fix2").FindControl("lblAf2End") as Label).Text = myActivatyVO.personextcount_max.ToString(); //RangeValidator myRangeValidator = (FormView_fixA.FindControl("tr_person_fix2").FindControl("chk_txtperson_fix2_3") as RangeValidator); //myRangeValidator.MinimumValue = myActivatyVO.personextcount_min.ToString(); //myRangeValidator.MaximumValue = myActivatyVO.personextcount_max.ToString(); }
//人員切換之後指定EmpID protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { RadioButton RadioButton1 = sender as RadioButton; RadioButton1.Checked = true; GridView_RegisterPeoplinfo.SelectedIndex = (RadioButton1.NamingContainer as GridViewRow).RowIndex; EmpID = GridView_RegisterPeoplinfo.DataKeys[GridView_RegisterPeoplinfo.SelectedIndex].Value.ToString(); //載入個人資訊 //個人固定欄位 ObjectDataSource_fixA.SelectParameters["activity_id"].DefaultValue = ActivityID.ToString(); ObjectDataSource_fixA.SelectParameters["emp_id"].DefaultValue = EmpID; FormView_fixA.DataBind(); //載入動態欄位資料 ACMS.DAO.CustomFieldValueDAO myCustomFieldValueDAO = new ACMS.DAO.CustomFieldValueDAO(); List <ACMS.VO.CustomFieldValueVO> myCustomFieldValueVOList = myCustomFieldValueDAO.SelectCustomFieldValue(ActivityID, EmpID); foreach (ACMS.VO.CustomFieldValueVO myCustomFieldValueVO in myCustomFieldValueVOList) { if (myCustomFieldValueVO.field_control.ToUpper() == "TEXTBOX") { TextBox MyControl = new TextBox(); MyControl.ID = string.Format("txt{0}", myCustomFieldValueVO.field_id); (PlaceHolder1.FindControl(MyControl.ID) as TextBox).Text = myCustomFieldValueVO.field_value; } else if (myCustomFieldValueVO.field_control.ToUpper() == "TEXTBOXLIST") { TCheckBoxList MyControl = new TCheckBoxList(); MyControl.ID = string.Format("plh{0}", myCustomFieldValueVO.field_id); (PlaceHolder1.FindControl(MyControl.ID) as TCheckBoxList).SelectedValueList = myCustomFieldValueVO.field_value; CheckBoxList1_SelectedIndexChanged((PlaceHolder1.FindControl(MyControl.ID) as TCheckBoxList), null); } else if (myCustomFieldValueVO.field_control.ToUpper() == "CHECKBOXLIST") { TCheckBoxList MyControl = new TCheckBoxList(); MyControl.ID = string.Format("cbl{0}", myCustomFieldValueVO.field_id); (PlaceHolder1.FindControl(MyControl.ID) as TCheckBoxList).SelectedValueList = myCustomFieldValueVO.field_value; } else if (myCustomFieldValueVO.field_control.ToUpper() == "RADIOBUTTONLIST") { TRadioButtonList MyControl = new TRadioButtonList(); MyControl.ID = string.Format("radl{0}", myCustomFieldValueVO.field_id); (MyControl as TRadioButtonList).ClearSelection(); (PlaceHolder1.FindControl(MyControl.ID) as TRadioButtonList).SelectedValue = myCustomFieldValueVO.field_value; } } }
//開啟選擇報名者視窗 protected void btnAgent_Click(object sender, EventArgs e) { try { OpenAgentSelector1.Visible = true; OpenAgentSelector1.TitleName = "代理報名"; //OpenAgentSelector1.OkName = "報名"; OpenAgentSelector1.InitDataAndShow(ActivityID.ToString()); } catch (Exception ex) { WriteErrorLog("Agent", ex.Message, "0"); } }
private void setTimetableGridDataSource() { ods.TypeName = typeof(ProviderBFC).FullName; ods.EnablePaging = true; ods.SelectParameters.Clear(); ods.SelectParameters.Add("activityID", ActivityID.ToString()); ods.SelectMethod = "RetrieveTimetableGrid"; ods.SelectCountMethod = "RetrieveTimetableGridCount"; ods.MaximumRowsParameterName = "amount"; ods.StartRowIndexParameterName = "startIndex"; ods.SortParameterName = "sortExpression"; var timetable = new ProviderBFC().RetrieveTimetableGrid(0, 9999, ActivityID.ToString(), ""); GridView1.DataSource = timetable; GridView1.DataBind(); }
//選取人員之後指定EmpID protected void GetSmallEmployees_Click(object sender, GetEmployeeEventArgs e) { try { EmpID = e.id; ObjectDataSource_RegisterPersonInfo.SelectParameters["emp_id"].DefaultValue = e.id; FormView_RegisterPersonInfo.DataBind(); //個人固定欄位 ObjectDataSource_fixA.SelectParameters["activity_id"].DefaultValue = ActivityID.ToString(); ObjectDataSource_fixA.SelectParameters["emp_id"].DefaultValue = EmpID; } catch (Exception ex) { WriteErrorLog("GetSmallEmployees", ex.Message, "0"); } }
//新增報名 protected void GoSecondStep_Click(object sender, RegistGoSecondEventArgs e) { try { Wizard1.MoveTo(Wizard1.WizardSteps[0]); RegistActivity_Query1.Visible = false; Wizard1.Visible = true; //必要屬性 MyFormMode = FormViewMode.Insert; ActivityID = e.activity_id; EmpID = clsAuth.ID; //預設是登入者 RegistBy = clsAuth.ID; //執行是登入者 PanelRegisterInfoA.Visible = true; PanelRegisterInfoB.Visible = false; MyHiddenField.Value = ActivityID.ToString(); //載入活動資訊 GetActivityDefault(); ((Label)FormView_ActivatyDetails.FindControl("activity_startdateLabel")).Text = ((Label)FormView_ActivatyDetails.FindControl("activity_startdateLabel")).Text.Replace("-", "/").Replace("T", " "); ((Label)FormView_ActivatyDetails.FindControl("activity_enddateLabel")).Text = ((Label)FormView_ActivatyDetails.FindControl("activity_enddateLabel")).Text.Replace("-", "/").Replace("T", " "); //if (((Label)FormView_ActivatyDetails.FindControl("limit_countLabel")).Text == "999999") //{ // ((Label)FormView_ActivatyDetails.FindControl("limit_countLabel")).Text = "無上限"; //} //if (((Label)FormView_ActivatyDetails.FindControl("limit2_countLabel")).Text == "0") //{ // ((Label)FormView_ActivatyDetails.FindControl("limit2_countLabel")).Text = "無"; //} } catch (Exception ex) { WriteErrorLog("SecondStep", ex.Message, "0"); } }
protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e) { if (Wizard1.ActiveStepIndex == 0) { if (Session["Agent"] != null) { OpenAgentSelector1.Visible = true; OpenAgentSelector1.TitleName = "代理報名"; //OpenAgentSelector1.OkName = "報名"; OpenAgentSelector1.InitDataAndShow(ActivityID.ToString()); btnAgent.Visible = true; } } if (Wizard1.ActiveStepIndex == 1) { if (((Boolean)Session["ShowPanel"]) == false) { Wizard1.MoveTo(Wizard1.WizardSteps[3]); } } }
public void Save(SQLiteDatabase sqlDatabase) { if (sqlDatabase != null && sqlDatabase.IsOpen) { //ccannot save without a corresponding ActivityID if (ActivityID != -1) { Log.Info(TAG, "Save: Attempting to Save ActivityTime for Activity with ID " + ActivityID.ToString()); try { if (!string.IsNullOrEmpty(ActivityName)) { Log.Info(TAG, "Save: Found Activity Name - " + ActivityName); if (!(IsNew || IsDirty)) { Log.Info(TAG, "Save: Unchanged ActivityTime detected - no work to do!"); return; } ContentValues values = new ContentValues(); values.Put("ActivityName", ActivityName); values.Put("ActivityTime", (int)ActivityTime); values.Put("Achievement", Achievement); values.Put("Intimacy", Intimacy); values.Put("Pleasure", Pleasure); if (IsNew) { Log.Info(TAG, "Save: Is a new ActivityTime, using ActivityID - " + ActivityID.ToString()); values.Put("ActivityID", ActivityID); ActivityTimeID = (int)sqlDatabase.Insert("ActivityTimes", null, values); Log.Info(TAG, "Save: Saved ActivityTime with ID " + ActivityTimeID.ToString()); IsNew = false; IsDirty = false; } if (IsDirty) { Log.Info(TAG, "Save: Found existing ActivityTime with ActivityID - " + ActivityID.ToString() + " and ActivityTimesID - " + ActivityTimeID.ToString()); var whereClause = "ActivityID = " + ActivityID + " AND ActivityTimesID = " + ActivityTimeID; sqlDatabase.Update("ActivityTimes", values, whereClause, null); Log.Info(TAG, "Save: Updated successfully"); IsDirty = false; } } else { Log.Info(TAG, "Save: Skipping Save of ActivityTime because its name was null!"); } } catch (Exception e) { Log.Error(TAG, "Save: Exception - " + e.Message); } } else { throw new Exception("Cannot save Activity time details because Activity ID is invalid (did you forget to save the Main Activity?)"); } } }
//完成 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"); }
protected void Page_Load(object sender, EventArgs e) { try { //if (Wizard1.ActiveStepIndex >= 1) try { InitQueryBlock(ActivityID.ToString()); } catch { } if (!IsPostBack) { Session.Remove("form_mode1"); Session["ShowPanel"] = false; Session.Remove("Team"); ((MyMasterPage)(this.Master)).PanelMainGroupingText = "個人報名"; Wizard1.Visible = false; if (Session["form_mode"] != null && Session["activity_id"] != null) { //以新增方式進來時 if (Session["form_mode"].ToString() == "regist") { RegistGoSecondEventArgs myRegistGoSecondEventArgs = new RegistGoSecondEventArgs(new Guid(Session["activity_id"].ToString())); GoSecondStep_Click(null, myRegistGoSecondEventArgs); } //以預覽方式進來時 if (Session["form_mode"].ToString() == "preview") { hiMode1.Value = "preview"; Session["form_mode1"] = "preview"; RegistGoSecondEventArgs myRegistGoSecondEventArgs = new RegistGoSecondEventArgs(new Guid(Session["activity_id"].ToString())); GoSecondStep_Click(null, myRegistGoSecondEventArgs); } if (Session["form_mode"].ToString() == "edit") { //以編輯方式進來時 GoThirdStep_Click(null, null); //Wizard1.FindControl("FinishNavigationTemplateContainerID$btnHome").Visible = true; //((Button)Wizard1.FindControl("FinishNavigationTemplateContainerID$FinishButton")).Text = "儲存並發送確認信"; } } else { //先查詢,再 GoSecondStep_Click } Session["form_mode"] = null; //Session["activity_id"] = null; } } catch (Exception ex) { WriteErrorLog("PageLoad", ex.Message, "0"); } }
//下載檔案 protected void lbtnFileDownload_Click(object sender, EventArgs e) { try { GridView GridView_UpFiles = (GridView)FormView_ActivatyDetails.FindControl("GridView_UpFiles"); FileInfo myFileInfo = new FileInfo(GridView_UpFiles.DataKeys[((sender as LinkButton).NamingContainer as GridViewRow).RowIndex].Value.ToString()); //ScriptManager.RegisterClientScriptBlock(HttpContext.Current.Handler as Page, typeof(string), string.Format("alert_{0}", DateTime.Now.ToString("hhmmss")), js, true); string fileName = GridView_UpFiles.DataKeys[((sender as LinkButton).NamingContainer as GridViewRow).RowIndex].Value.ToString(); fileName = this.ResolveUrl("~/Upfiles/" + fileName.Substring(fileName.IndexOf(ActivityID.ToString()))); if (myFileInfo.Exists) { // Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", Server.UrlEncode((myFileInfo.Name)))); // // 輸出檔案。 // Response.WriteFile(myFileInfo.FullName); // Response.Write("<script type=\"text/javascript\"> window.open('" + fileName + "')</script>"); ScriptManager.RegisterClientScriptBlock(this, typeof(string), string.Format("alert_{0}", DateTime.Now.ToString("hhmmss")), " window.open('" + fileName + "')", true); } } catch (Exception ex) { WriteErrorLog("DownLoadFile", ex.Message, "0"); } }