private DataTable GetEvent(int EventID, int EventPeriodID) { BusinessServices.Event objEvent = new BusinessServices.Event(); DataTable dtEvent = objEvent.GetEvent(EventID, EventPeriodID, UserContext.UserData.OrgID); return(dtEvent); }
private void LoadEvent(int EventID, int EventPeriodID) { try { BusinessServices.Event objEvent = new BusinessServices.Event(); DataTable dtEvent = objEvent.GetEvent(EventID, EventPeriodID, UserContext.UserData.OrgID); if (dtEvent.Rows.Count > 0) { this.txtEventName.Text = dtEvent.Rows[0]["EventName"].ToString(); EventNameCheck = dtEvent.Rows[0]["EventName"].ToString(); this.txtEventItem.Text = dtEvent.Rows[0]["EventItem"].ToString(); this.txtEventLocation.Text = dtEvent.Rows[0]["EventLocation"].ToString(); this.txtEventProvider.Text = dtEvent.Rows[0]["EventProvider"].ToString(); this.ddlEventType.SelectedValue = dtEvent.Rows[0]["EventType"].ToString(); // this.chkstatus.Checked = Boolean.Parse(dtEvent.Rows[0]["RegisterPoint"].ToString()); //this.chkallowuser.Checked = Boolean.Parse(dtEvent.Rows[0]["AllowUser"].ToString()); this.ddlCPDProfile.SelectedValue = dtEvent.Rows[0]["ProfileID"].ToString(); ViewState["EventID"] = EventID; ViewState["EventPeriodID"] = EventPeriodID; ViewState["CurrentEventPoints"] = dtEvent.Rows[0]["Points"].ToString();; // if (Session["Action"] == "Edit") EventFileList(); if (this.panPeriod.Visible == true) { if (!dtEvent.Rows[0]["datestart"].Equals(System.DBNull.Value)) { DateTime dtStart = (DateTime)dtEvent.Rows[0]["datestart"]; this.ddlCurrentDateStartDay.SelectedValue = dtStart.Day.ToString(); this.ddlCurrentDateStartMonth.SelectedValue = dtStart.Month.ToString(); this.ddlCurrentDateStartYear.SelectedValue = dtStart.Year.ToString(); this.ddlCurrentDateStartHour.SelectedValue = dtStart.Hour.ToString(); this.ddlCurrentDateStartMinute.SelectedValue = dtStart.Minute.ToString(); } if (!dtEvent.Rows[0]["dateend"].Equals(System.DBNull.Value)) { DateTime dtStart = (DateTime)dtEvent.Rows[0]["dateend"]; this.ddlCurrentDateEndDay.SelectedValue = dtStart.Day.ToString(); this.ddlCurrentDateEndMonth.SelectedValue = dtStart.Month.ToString(); this.ddlCurrentDateEndYear.SelectedValue = dtStart.Year.ToString(); this.ddlCurrentDateEndHour.SelectedValue = dtStart.Hour.ToString(); this.ddlCurrentDateEndMinute.SelectedValue = dtStart.Minute.ToString(); } if (!dtEvent.Rows[0]["Points"].Equals(System.DBNull.Value)) { this.txtCurrentPoints.Text = dtEvent.Rows[0]["Points"].ToString(); } string strEndOfPeriodAction = dtEvent.Rows[0]["EndOfPeriodAction"].ToString(); } } } catch (Exception ex) { ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "LoadEvent", ex.Message); } }
private DataTable GetEvent() { int OrganisationID = UserContext.UserData.OrgID; BusinessServices.Event org = new BusinessServices.Event(); DataTable dtPolicies = org.GetOrganisationEvents(OrganisationID); return(dtPolicies); }
private bool UploadEventFile(int EventPeriodID, bool checkFile) { int FileId; bool UploadStatus = false; if ((UploadFile.PostedFile != null) && (UploadFile.PostedFile.ContentLength > 0)) { BusinessServices.Event objEvent = new BusinessServices.Event(); int OrganisationID = UserContext.UserData.OrgID; string SaveDir = Server.MapPath(@"\General") + @"\CPDEvent\" + UserContext.UserData.OrgID.ToString(); //Check that the directory exists - if it doesn't then create it if (!Directory.Exists(SaveDir)) { Directory.CreateDirectory(SaveDir); } try { HttpFileCollection hfc = Request.Files; for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { System.IO.FileInfo file = new System.IO.FileInfo(hpf.FileName); string fname = file.Name.Remove((file.Name.Length - file.Extension.Length)); fname = fname + "~" + DateTime.Now.ToString("ddMMyyyyhhmmss") + file.Extension; hpf.SaveAs(SaveDir + @"\" + fname); objEvent.EventPeriodID = EventPeriodID; objEvent.FileName = fname; FileId = objEvent.AddEventFile(objEvent); } } } catch (Exception ex) { //log exception to event log ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "UploadEventFile", ex.Message); //display friendly message to user lblMessage.Text = ResourceManager.GetString("UploadFail"); lblMessage.CssClass = "WarningMessage"; } } else { lblMessage.Text = ResourceManager.GetString("NoUploadFile"); lblMessage.CssClass = "WarningMessage"; } return(UploadStatus); }
protected void EventFileList() { BusinessServices.Event objEvent = new BusinessServices.Event(); DataTable dtEvent = objEvent.GetEventFileName(int.Parse(ViewState["EventID"].ToString()), int.Parse(ViewState["EventPeriodID"].ToString())); if (dtEvent.Rows.Count > 0) { gvFile.DataSource = dtEvent; gvFile.DataBind(); } }
private void checkAvailablepoint(int EventID, int EventPeriodID) { BusinessServices.Event objEvent = new BusinessServices.Event(); DataTable dtEvent = objEvent.CheckAvilableEventpoint(EventID, EventPeriodID, UserContext.UserData.OrgID, UserContext.UserID); if (dtEvent.Rows.Count > 0) { lblavailablepoint.Text = dtEvent.Rows[0]["Points"].ToString(); lblavailablepoint.ForeColor = Color.Green; } }
//delete event protected void gvImage_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridViewRow row = (GridViewRow)gvImage.Rows[e.RowIndex]; Label lbldeleteid = (Label)row.FindControl("lblImgId"); BusinessServices.Event objProfile = new BusinessServices.Event(); objProfile.EventTypeId = int.Parse(lbldeleteid.Text); objProfile.DeleteEventType(objProfile); EventType(); }
//protected void btnDeleteFuturePeriod_Click(object sender, System.EventArgs e) //{ // // Delete future period // int EventID; // try // { // EventID = int.Parse(Session["EventID"].ToString()); // } // catch // { // EventID = -1; // } // BusinessServices.Event objEvent = new BusinessServices.Event(); // objEvent.DeleteFuturePeriod(EventID); // Response.Redirect(@"\Administration\CPD\cpdeventdefault.aspx"); //} private void BindEventType() { int OrganisationID = UserContext.UserData.OrgID; BusinessServices.Event objEvent = new BusinessServices.Event(); DataTable dtPolicyPoints = objEvent.GetEventType(OrganisationID); if (dtPolicyPoints.Rows.Count > 0) //No policies exist - hide relevant controls and display message { ddlEventType.DataSource = dtPolicyPoints; ddlEventType.DataValueField = "EventTypeId"; ddlEventType.DataTextField = "EventTypeName"; ddlEventType.DataBind(); } }
// update event protected void gvImage_RowUpdating(object sender, GridViewUpdateEventArgs e) { BusinessServices.Event objProfile = new BusinessServices.Event(); TextBox EventTypeName = (TextBox)gvImage.Rows[e.RowIndex].FindControl("txtImageName"); string EventTypeId = gvImage.DataKeys[e.RowIndex].Value.ToString(); objProfile.EventTypeId = int.Parse(EventTypeId); objProfile.EventTypeName = EventTypeName.Text; objProfile.UpdateEventType(objProfile); gvImage.EditIndex = -1; EventType(); }
protected void EventType() { BusinessServices.Event objEvent = new BusinessServices.Event(); int PageSize = ApplicationSettings.PageSize; this.gvImage.PageSize = PageSize; int OrganisationID = UserContext.UserData.OrgID; DataTable dtPolicyPoints = objEvent.GetEventType(OrganisationID); if (dtPolicyPoints.Rows.Count > 0) { gvImage.DataSource = dtPolicyPoints; gvImage.DataBind(); } }
protected void cvEventItem_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) { int EventID; int EventPeriodID; try { EventID = int.Parse(Session["EventID"].ToString()); } catch { EventID = -1; } try { EventPeriodID = int.Parse(Session["EventPeriodID"].ToString()); } catch { EventPeriodID = -1; } int OrganisationID = UserContext.UserData.OrgID; string EventItem = this.txtEventItem.Text; BusinessServices.Event objProfile = new BusinessServices.Event(); DataTable dtEventName = objProfile.CheckEventItem(EventItem, EventID, EventPeriodID, UserContext.UserID); if (dtEventName.Rows.Count > 0) { ((CustomValidator)source).ErrorMessage = ResourceManager.GetString("EventItemExists"); args.IsValid = false; return; } string strEventItem = this.txtEventItem.Text; if (strEventItem.Equals(String.Empty)) { ((CustomValidator)source).ErrorMessage = ResourceManager.GetString("rfvEventItem"); args.IsValid = false; return; } }
private void dgrCPD_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName != "Page") { string EventPeriodIDValue = @"-1"; string Action = e.CommandName; Label EventID = (Label)e.Item.FindControl("lblEventID"); Label EventPeriodID = (Label)e.Item.FindControl("lblEventPeriodID"); string EventIDValue = EventID.Text; if (EventPeriodID.Text != "") { EventPeriodIDValue = EventPeriodID.Text; } Session["EventID"] = EventIDValue; Session["EventPeriodID"] = EventPeriodIDValue; switch (Action) { case "Edit": Response.Redirect(@"\Administration\CPD\cpdeventdetail.aspx"); break; case "Delete": string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Yes") { //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked YES!')", true); BusinessServices.Event objEvent = new BusinessServices.Event(); objEvent.DeleteEventPeriod(Convert.ToInt32(EventPeriodIDValue)); Response.Redirect(@"\Administration\CPD\cpdevent.aspx"); } else { //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true); } break; case "Copy": Response.Redirect(@"\Administration\CPD\cpdeventdetail.aspx?IsCopy=copy"); break; } } }
//delete event protected void gvFile_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { GridViewRow row = (GridViewRow)gvFile.Rows[e.RowIndex]; Label lbldeleteid = (Label)row.FindControl("lblImgId"); Label lblDeleteImageName = (Label)row.FindControl("lblImageName"); BusinessServices.Event objProfile = new BusinessServices.Event(); objProfile.FileID = int.Parse(lbldeleteid.Text); objProfile.DeleteEventFile(objProfile); FileDeleteFromFolder(lblDeleteImageName.Text); EventFileList(); } catch (Exception ex) { ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "gvFile_RowDeleting", ex.Message); } }
private void LoadPolicy() { int UserID = UserContext.UserID; int FileID = int.Parse(Request.QueryString["FileID"].ToString()); BusinessServices.Event objPolicy = new BusinessServices.Event(); // if the policy as not accepted, enable to checkbox if (!objPolicy.CheckFileAccepted(FileID, UserID)) { //string ConfirmationMessage = "I have read and understood the event"; //this.chkAgree.Text = ConfirmationMessage; btnFinish.Visible = true; } else { this.chkAgree.Enabled = false; this.chkAgree.Checked = true; string lastAccepted = objPolicy.GetLastAccepted(UserID, UserContext.UserData.OrgID, FileID); this.chkAgree.Text = ResourceManager.GetString("lblLastAccepted") + " " + lastAccepted; btnFinish.Visible = false; } DataTable dtPolicy = objPolicy.GetFileName(FileID); // string PolicyName = objPolicy.GetFileName(FileID); string FileName = dtPolicy.Rows[0]["FileName"].ToString(); string PolicyDir = @"\General\CPDEvent\" + UserContext.UserData.OrgID.ToString(); this.pdfFrame.Attributes["src"] = PolicyDir + @"\" + dtPolicy.Rows[0]["FileName"].ToString(); this.pdfFrame.Visible = true; }
private void LoadPolicy() { //int UserID = UserContext.UserID; //BusinessServices.User objUser = new BusinessServices.User(); //DataTable dtUserProfiles = objUser.GetEventPeriodList(UserID); int FileID = int.Parse(Request.QueryString["FileID"].ToString()); BusinessServices.Event objPolicy = new BusinessServices.Event(); // if the policy as not accepted, enable to checkbox //if (!objPolicy.CheckAccepted(PolicyID, UserID)) //{ // string ConfirmationMessage = objPolicy.GetConfirmationMessage(PolicyID); // this.chkAgree.Text = ConfirmationMessage; //} //else //{ // this.chkAgree.Enabled = false; // this.chkAgree.Checked = true; // string lastAccepted = objPolicy.GetLastAccepted(UserID, UserContext.UserData.OrgID, PolicyID); // this.chkAgree.Text = ResourceManager.GetString("lblLastAccepted") + " " + lastAccepted; //} DataTable dtPolicy = objPolicy.GetFileName(FileID); // string PolicyName = objPolicy.GetFileName(FileID); string FileName = dtPolicy.Rows[0]["FileName"].ToString(); string PolicyDir = @"\General\CPDEvent\" + UserContext.UserData.OrgID.ToString(); this.pdfFrame.Attributes["src"] = PolicyDir + @"\" + dtPolicy.Rows[0]["FileName"].ToString(); this.pdfFrame.Visible = true; }
protected void btnFinish_Click(object sender, System.EventArgs e) { int FileID = int.Parse(Request.QueryString["FileID"].ToString()); int EventPeriodId = int.Parse(Request.QueryString["EventPeriodId"].ToString()); int UserID = UserContext.UserID; BusinessServices.Event objEvent = new BusinessServices.Event(); // Only want to do anything if user has read and understood the policy if (this.chkAgree.Checked) { // Check if policy marked as accepted // If not then mark user as accepted the policy if (!objEvent.CheckFileAccepted(FileID, UserID)) { objEvent.AcceptFile(FileID, UserID); } } // Response.Redirect("/MyTraining.aspx"); Response.Write("<script language='javascript'> {opener.location.reload(); self.close(); }</script>"); //Page.ClientScript.RegisterOnSubmitStatement(typeof(Page), "closePage", "window.onunload = CloseWindow();"); }
// update event protected void gvFile_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { BusinessServices.Event objProfile = new BusinessServices.Event(); FileUpload FileUpload1 = (FileUpload)gvFile.Rows[e.RowIndex].FindControl("FileUpload1"); string path = Server.MapPath(@"\General") + @"\CPDEvent\" + UserContext.UserData.OrgID.ToString() + @"\"; int OrganisationID = UserContext.UserData.OrgID; DataTable dt = objProfile.CheckFileName(OrganisationID, FileUpload1.FileName); int CheckRowCount = dt.Rows.Count; if (CheckRowCount != 0) { lblMessage.Text = ResourceManager.GetString("FileExists"); lblMessage.CssClass = "WarningMessage"; return; } string FileID = gvFile.DataKeys[e.RowIndex].Value.ToString(); if (FileUpload1.HasFile) { FileUpload1.SaveAs(path + FileUpload1.FileName); } objProfile.FileID = int.Parse(FileID); objProfile.FileName = FileUpload1.FileName; objProfile.UpdateEventFile(objProfile); gvFile.EditIndex = -1; EventFileList(); } catch (Exception ex) { ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "gvFile_RowUpdating", ex.Message); } }
protected void btnSave_Click(object sender, System.EventArgs e) { lblMessage.Text = ""; if (Page.IsValid) { if (txtEventTypeName.Text.ToString().Trim() != "") { BusinessServices.Event objEvent = new BusinessServices.Event(); int OrganisationID = UserContext.UserData.OrgID; DataTable dtEventType = objEvent.GetEventType(txtEventTypeName.Text.ToString().Trim(), OrganisationID); if (dtEventType.Rows.Count > 0) { lblMessage.Text = ResourceManager.GetString("EventExists"); } else { objEvent.AddEventType(txtEventTypeName.Text.ToString().Trim(), OrganisationID, Convert.ToInt32(cboStatus.SelectedValue)); EventType(); lblMessage.Text = ResourceManager.GetString("SaveSuccess"); } } } }
//override protected void OnInit(EventArgs e) //{ // // // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // // // InitializeComponent(); // base.OnInit(e); //} //private void InitializeComponent() //{ // this.txtCurrentPoints.TextChanged +=new EventHandler(txtCurrentPoints_TextChanged); //} //void txtCurrentPoints_TextChanged(object sender, EventArgs e) //{ // if (int.Parse(txtCurrentPoints.Text) <= int.Parse(lblavailablepoint.Text)) // { // } // else // { // txtCurrentPoints.Text = "0"; // } //} protected void Page_Load(object sender, System.EventArgs e) { try { BusinessServices.Organisation objOrganisation = new BusinessServices.Organisation(); if (objOrganisation.GetOrganisationCPDAccess(UserContext.UserData.OrgID)) { pagTitle.InnerText = ResourceManager.GetString("pagTitle"); int EventID; int EventPeriodID; //int ProfileID; //string EventName; //int EventType; try { EventID = int.Parse(Session["EventID"].ToString()); } catch { EventID = -1; } try { EventPeriodID = int.Parse(Session["EventPeriodID"].ToString()); } catch { EventPeriodID = -1; } this.InitialisePage(EventID, EventPeriodID); if (!Page.IsPostBack) { Session["PageIndex"] = 0; PopulateDropdown(this.ddlCurrentDateStartDay, this.ddlCurrentDateStartMonth, this.ddlCurrentDateStartYear); PopulateDropdown(this.ddlCurrentDateEndDay, this.ddlCurrentDateEndMonth, this.ddlCurrentDateEndYear); this.ddlCurrentDateStartDay.SelectedValue = System.DateTime.Today.Day.ToString(); this.ddlCurrentDateStartMonth.SelectedValue = System.DateTime.Today.Month.ToString(); this.ddlCurrentDateStartYear.SelectedValue = System.DateTime.Today.Year.ToString(); this.ddlCurrentDateEndDay.SelectedValue = System.DateTime.Today.Day.ToString(); this.ddlCurrentDateEndMonth.SelectedValue = System.DateTime.Today.Month.ToString(); this.ddlCurrentDateEndYear.SelectedValue = System.DateTime.Today.Year.ToString(); SetSortOrder("LastName"); BindCPDProfile(); BindEventType(); checkAvailablepoint(EventID, EventPeriodID); BusinessServices.Event objEvent = new BusinessServices.Event(); DataTable dtEvent = objEvent.GetEvent(EventID, EventPeriodID, UserContext.UserData.OrgID); try { txtEventName.Text = dtEvent.Rows[0]["EventName"].ToString(); txtEventName.ReadOnly = true; ddlCPDProfile.SelectedValue = dtEvent.Rows[0]["ProfileID"].ToString(); ddlCPDProfile.Enabled = false; ddlEventType.SelectedValue = dtEvent.Rows[0]["EventType"].ToString(); // ddlEventType.Enabled = false; ViewState["CurrentEventPoints"] = "0"; } catch { } if (Session["Action"].ToString() == "Add") { EventID = -1; EventPeriodID = -1; } //By default "No Action" radiobutton checked if a new Event if (EventID > 0) //Existing Event { LoadEvent(EventID, EventPeriodID); } var hours = Enumerable.Range(0, 24).Select(i => i.ToString()); var minutes = Enumerable.Range(0, 60).Select(i => i.ToString()); ddlCurrentDateStartHour.DataSource = hours; ddlCurrentDateStartHour.DataBind(); ddlCurrentDateStartMinute.DataSource = minutes; ddlCurrentDateStartMinute.DataBind(); ddlCurrentDateEndHour.DataSource = hours; ddlCurrentDateEndHour.DataBind(); ddlCurrentDateEndMinute.DataSource = minutes; ddlCurrentDateEndMinute.DataBind(); } } else// dosnt have access to CPD { pagTitle.InnerText = ResourceManager.GetString("pagTitle"); this.lblPageTitle.Text = ResourceManager.GetString("lblPageTitle"); panCPD.Visible = false; lblMessage.Text = ResourceManager.GetString("NoAccess"); lblMessage.CssClass = "WarningMessage"; } } catch (Exception ex) { //log exception to event log ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "Page_Load", ex.Message); } }
private BusinessServices.Event GetEventValues() { BusinessServices.Event objEvent = new BusinessServices.Event(); int EventID; try { EventID = int.Parse(Session["EventID"].ToString()); } catch { EventID = -1; } if (EventID > 0) // Set EventID if existing Event { objEvent.EventID = EventID; } int EventPeriodID; try { EventPeriodID = int.Parse(Session["EventPeriodID"].ToString()); } catch { EventPeriodID = -1; } if (EventPeriodID > 0) { objEvent.EventPeriodID = EventPeriodID; } // Get values from controls objEvent.UserID = UserContext.UserID; objEvent.OrganisationID = UserContext.UserData.OrgID; objEvent.EventName = this.txtEventName.Text.ToString(); objEvent.ProfileID = int.Parse(ddlCPDProfile.SelectedValue); objEvent.EventProvider = this.txtEventProvider.Text.ToString(); objEvent.EventType = int.Parse(ddlEventType.SelectedValue); objEvent.EventLocation = this.txtEventLocation.Text.ToString(); objEvent.EventItem = this.txtEventItem.Text.ToString(); objEvent.UserType = 2; // objEvent.RegisterPoint = this.chkstatus.Checked; // objEvent.AllowUser = this.chkallowuser.Checked; try { objEvent.DateStart = GetDateFromDropDowns("CurrentDate", "Start"); } catch { objEvent.DateStart = DateTime.Parse("1/1/1900"); } try { objEvent.DateEnd = GetDateFromDropDowns("CurrentDate", "End"); } catch { objEvent.DateEnd = DateTime.Parse("1/1/1900"); } if (this.txtCurrentPoints.Text.Length > 0) { objEvent.Points = double.Parse(this.txtCurrentPoints.Text.ToString()); } objEvent.EndOfPeriodAction = GetEndOfPeriodAction(); return(objEvent); }
protected void btnSaveEvent_Click(object sender, System.EventArgs e) { try { //this.cvCurrentPoints.Validate(); this.cvCurrentDate.Validate(); int EventID; int EventPeriodID; try { EventID = int.Parse(Session["EventID"].ToString()); } catch { EventID = -1; } try { EventPeriodID = int.Parse(Session["EventPeriodID"].ToString()); } catch { EventPeriodID = -1; } if (Session["Action"].ToString() == "Add") { EventID = -1; EventPeriodID = -1; } if (!this.IsValid && (EventID < 0)) { return; } else if (!this.IsValid) { return; } this.lblNoPeriod.Text = String.Empty; BusinessServices.Event objEvent = new BusinessServices.Event(); objEvent = GetEventValues(); int OrganisationID = UserContext.UserData.OrgID; string ProfileName = this.txtEventName.Text; DataTable dtEventName = objEvent.CheckUserEventName(objEvent.EventName, OrganisationID, int.Parse(ddlCPDProfile.SelectedValue), EventPeriodID, UserContext.UserID); //if (dtProfileName.Rows.Count > 0 && (ProfileNameCheck != ProfileName)) if (dtEventName.Rows.Count > 0) { this.lblMessage.Text += ResourceManager.GetString("EventExists"); this.lblMessage.CssClass = "WarningMessage"; return; } int CheckRowCount = 0; bool flagCanUpload = true; HttpFileCollection hfc = Request.Files; //for (int i = 0; i < hfc.Count; i++) //{ // HttpPostedFile hpf = hfc[i]; // if (hpf.FileName != "") // { // System.IO.FileInfo file = new System.IO.FileInfo(hpf.FileName); // string fname = file.Name.Remove((file.Name.Length - file.Extension.Length)); // fname = fname + "_" + DateTime.Now.ToString("dd-MM-yyyy-hh:mm:ss") + file.Extension; // if (hpf.ContentLength > 0) // { // DataTable dt = objEvent.CheckFileName(OrganisationID, fname); // CheckRowCount = dt.Rows.Count; // if (CheckRowCount != 0) // { // // File with this name already exists for this organisation // flagCanUpload = false; // lblMessage.Text = ResourceManager.GetString("FileExists"); // lblMessage.CssClass = "WarningMessage"; // return; // } // } // } //} if (EventID > 0) //Existing Event - update { if (flagCanUpload) { objEvent.UpdateUserEvent(objEvent); // EventPeriodID = objProfile.GetEventPeriodID(EventID); Session["EventPeriodID"] = EventPeriodID; UploadEventFile(EventPeriodID, true); // objEvent.UpdateEventPeriodAccess(OrganisationID, EventPeriodID, objEvent.EventID); panPeriod.Visible = true; InitialisePage(EventID, EventPeriodID); LoadEvent(EventID, EventPeriodID); this.lblMessage.Text += ResourceManager.GetString("SaveSuccess"); this.lblMessage.CssClass = "SuccessMessage"; } } else // New Event - Add { if (flagCanUpload) { EventID = objEvent.AddEvent(objEvent); EventPeriodID = objEvent.EventPeriodID; UploadEventFile(EventPeriodID, true); // Assign the new values to session variables Session["EventPeriodID"] = EventPeriodID; Session["EventID"] = EventID; // Initialize all units and users granted access to 0 //objEvent.InitialiseEventPeriodAccess(OrganisationID, objEvent.EventID, EventPeriodID); panPeriod.Visible = true; InitialisePage(EventID, EventPeriodID); LoadEvent(EventID, EventPeriodID); this.lblMessage.Text += ResourceManager.GetString("SaveSuccess"); this.lblMessage.CssClass = "SuccessMessage"; } } } catch (Exception ex) { ErrorHandler.ErrorLog el = new ErrorHandler.ErrorLog(ex, ErrorLevel.High, "Usercpdevent.aspx.cs", "btnSaveEvent_Click", ex.Message); } }
private void dgrCPD_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { //if (e.Item.ItemType != ListItemType.Pager) //{ if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DataRowView drv = (DataRowView)e.Item.DataItem; int EventID = (int)drv["EventID"]; BusinessServices.Event objEvent = new BusinessServices.Event(); DataTable dtEvent = objEvent.GetEvent(EventID, -1, UserContext.UserData.OrgID); if (dtEvent.Rows.Count > 0) { if (GEventid != EventID) { GEventid = EventID; GEventrowcount = 0; } else { GEventrowcount++; } if (!dtEvent.Rows[GEventrowcount]["DateStart"].Equals(System.DBNull.Value)) { DateTime dtStart = (DateTime)dtEvent.Rows[GEventrowcount]["DateStart"]; if (dtStart < DateTime.Now) //Current Period { Label lblCurrentDate = (Label)e.Item.FindControl("lblCurrentDate"); lblCurrentDate.Text = string.Format("{0:dd/MM/yyyy}", (DateTime)dtEvent.Rows[GEventrowcount]["DateStart"]) + " - " + string.Format("{0:dd/MM/yyyy}", (DateTime)dtEvent.Rows[GEventrowcount]["DateEnd"]); Label lblStarttime = (Label)e.Item.FindControl("lblStarttime"); lblStarttime.Text = string.Format("{0:hh:mm tt}", (DateTime)dtEvent.Rows[GEventrowcount]["DateStart"]); Label lblendtime = (Label)e.Item.FindControl("lblendtime"); lblendtime.Text = string.Format("{0:hh:mm tt}", (DateTime)dtEvent.Rows[GEventrowcount]["DateEnd"]); Label lblFutureDate = (Label)e.Item.FindControl("lblFutureDate"); if (!dtEvent.Rows[GEventrowcount]["FutureDateStart"].Equals(System.DBNull.Value)) { lblFutureDate.Text = string.Format("{0:dd/MM/yyyy}", (DateTime)dtEvent.Rows[GEventrowcount]["FutureDateStart"]) + " - " + string.Format("{0:dd/MM/yyyy}", (DateTime)dtEvent.Rows[GEventrowcount]["FutureDateEnd"]); } } else //Future Period { Label lblFutureDate = (Label)e.Item.FindControl("lblFutureDate"); lblFutureDate.Text = string.Format("{0:dd/MM/yyyy}", (DateTime)dtEvent.Rows[GEventrowcount]["DateStart"]) + " - " + string.Format("{0:dd/MM/yyyy}", (DateTime)dtEvent.Rows[GEventrowcount]["DateEnd"]); } } } } //} }