コード例 #1
0
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Setup/EventList.aspx";
            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(returnURL);
            }
            if (e.CommandName.ToLower() == "refresh")
            {
                try
                {
                    odsData.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null) masterPage.PageMessage = SRPResources.RefreshOK;
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if (e.CommandName.ToLower() == "add" || e.CommandName.ToLower() == "addandback")
            {
                try
                {
                    var obj = new Event();
                    //obj.GenNotificationFlag = ((CheckBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2").FindControl("GenNotificationFlag")).Checked;

                    obj.EventTitle = ((TextBox)((DetailsView)sender).FindControl("EventTitle")).Text;
                    obj.EventDate = FormatHelper.SafeToDateTime(((TextBox)((DetailsView)sender).FindControl("EventDate")).Text);
                    obj.EventTime = ((TextBox)((DetailsView)sender).FindControl("EventTime")).Text;
                    obj.HTML = ((HtmlTextArea)((DetailsView)sender).FindControl("HTML")).InnerHtml;
                    obj.SecretCode = ((TextBox)((DetailsView)sender).FindControl("SecretCode")).Text;
                    obj.NumberPoints =  FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("NumberPoints")).Text);
                    obj.BadgeID = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("BadgeID")).SelectedValue);
                    obj.BranchID = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("BranchID")).SelectedValue);
                    obj.Custom1 = ((EvtCustFldCtl)((DetailsView)sender).FindControl("Custom1")).Value;
                    obj.Custom2 = ((EvtCustFldCtl)((DetailsView)sender).FindControl("Custom2")).Value;
                    obj.Custom3 = ((EvtCustFldCtl)((DetailsView)sender).FindControl("Custom3")).Value;

                    obj.ShortDescription = ((TextBox)((DetailsView)sender).FindControl("ShortDescription")).Text;
                    obj.EndDate = ((TextBox)((DetailsView)sender).FindControl("EndDate")).Text.SafeToDateTime();
                    obj.EndTime = ((TextBox)((DetailsView)sender).FindControl("EndTime")).Text;
                    
                    obj.AddedDate = DateTime.Now;
                    obj.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session
                    obj.LastModDate = obj.AddedDate;
                    obj.LastModUser = obj.AddedUser;

                    if (obj.IsValid(BusinessRulesValidationMode.INSERT))
                    {
                        obj.Insert();
                        new SessionTools(Session).RemoveCache(Cache, CacheKey.EventsActive);
                        if (e.CommandName.ToLower() == "addandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        lblPK.Text = obj.EID.ToString();

                        odsData.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.AddedOK;
                    }
                    else
                    {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        masterPage.PageError = message;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback")
            {
                try
                {
                    var obj = new Event();
                    int pk = int.Parse(lblPK.Text);//int.Parse(((DetailsView)sender).Rows[0].Cells[1].Text));
                    obj.Fetch(pk);

                    obj.EventTitle = ((TextBox)((DetailsView)sender).FindControl("EventTitle")).Text.Trim();
                    obj.EventDate = FormatHelper.SafeToDateTime(((TextBox)((DetailsView)sender).FindControl("EventDate")).Text);
                    //obj.EventTime = ((TextBox)((DetailsView)sender).FindControl("EventTime")).Text;
                    obj.HTML = ((HtmlTextArea)((DetailsView)sender).FindControl("HTML")).InnerHtml.Trim();
                    obj.SecretCode = ((TextBox)((DetailsView)sender).FindControl("SecretCode")).Text.Trim().ToLower();
                    obj.NumberPoints = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("NumberPoints")).Text);
                    obj.BadgeID = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("BadgeID")).SelectedValue);
                    obj.BranchID = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("BranchID")).SelectedValue);

                    obj.Custom1 = ((EvtCustFldCtl)((DetailsView)sender).FindControl("Custom1")).Value;
                    obj.Custom2 = ((EvtCustFldCtl)((DetailsView)sender).FindControl("Custom2")).Value;
                    obj.Custom3 = ((EvtCustFldCtl)((DetailsView)sender).FindControl("Custom3")).Value;
                    //obj.Custom2 = ((TextBox)((DetailsView)sender).FindControl("Custom2")).Text;
                    //obj.Custom3 = ((TextBox)((DetailsView)sender).FindControl("Custom3")).Text;


                    //obj.ShortDescription = ((TextBox)((DetailsView)sender).FindControl("ShortDescription")).Text;
                    //obj.EndDate = ((TextBox)((DetailsView)sender).FindControl("EndDate")).Text.SafeToDateTime();
                    //obj.EndTime = ((TextBox)((DetailsView)sender).FindControl("EndTime")).Text;

                    obj.ExternalLinkToEvent = ((TextBox)((DetailsView)sender).FindControl("ExternalLinkToEvent")).Text.Trim();
                    obj.HiddenFromPublic = ((DropDownList)((DetailsView)sender).FindControl("HiddenFromPublic")).SelectedIndex > 0;

                    obj.LastModDate = DateTime.Now;
                    obj.LastModUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session

                    if (obj.IsValid(BusinessRulesValidationMode.UPDATE))
                    {
                        obj.Update();
                        var st = new SessionTools(Session);
                        st.RemoveCache(Cache, CacheKey.EventsActive);
                        st.RemoveCache(Cache, CacheKey.AllEvents);
                        if (e.CommandName.ToLower() == "saveandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        odsData.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.SaveOK;
                    }
                    else
                    {
                        var masterPage = (IControlRoomMaster)Master;
                        string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        masterPage.PageError = message;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
        }
コード例 #2
0
        public static int Delete(Event o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[1];
            arrParams[0] = new SqlParameter("@EID", GlobalUtilities.DBSafeValue(o.EID, o.EID.GetTypeCode()));

            try
            {
                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Event_Delete", arrParams);
            }
            catch (SqlException exx)
            {
                "GRA.SRP.DAL.Event".Log().Error("Error deleting Event: {0} - {1}",
                    exx.Message,
                    exx.StackTrace);
                System.Diagnostics.Debug.Write(exx.Message);
            }

            return iReturn;
        }
コード例 #3
0
 /// <summary>
 /// Formats an event date to be nice for end users.
 /// 
 /// Must have an Event object with the following properties specified: EventDate,
 /// EventTime, EndDate, EndTime
 /// </summary>
 /// <param name="e">The Event object</param>
 /// <returns>A nice string describing start and end times.</returns>
 public static string DisplayEventDateTime(Event e)
 {
     return string.Format("{0} at {1}",
         e.EventDate.ToShortDateString(),
         e.EventDate.ToShortTimeString());
 }
コード例 #4
0
        public static int Insert(Event o)
        {
            var arrParams = new List<SqlParameter>();

            arrParams.Add(new SqlParameter("@EventTitle", GlobalUtilities.DBSafeValue(o.EventTitle, o.EventTitle.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EventDate", GlobalUtilities.DBSafeValue(o.EventDate, o.EventDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EventTime", GlobalUtilities.DBSafeValue(o.EventTime, o.EventTime.GetTypeCode())));

            string html = o.HTML;
            if (!string.IsNullOrWhiteSpace(html) && html.EndsWith(TrailingBr))
            {
                html = html.Substring(0, html.Length - TrailingBr.Length);
            }

            arrParams.Add(new SqlParameter("@HTML", GlobalUtilities.DBSafeValue(html, html.GetTypeCode())));
            arrParams.Add(new SqlParameter("@SecretCode", GlobalUtilities.DBSafeValue(o.SecretCode, o.SecretCode.GetTypeCode())));
            arrParams.Add(new SqlParameter("@NumberPoints", GlobalUtilities.DBSafeValue(o.NumberPoints, o.NumberPoints.GetTypeCode())));
            arrParams.Add(new SqlParameter("@BadgeID", GlobalUtilities.DBSafeValue(o.BadgeID, o.BadgeID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@BranchID", GlobalUtilities.DBSafeValue(o.BranchID, o.BranchID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Custom1", GlobalUtilities.DBSafeValue(o.Custom1, o.Custom1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Custom2", GlobalUtilities.DBSafeValue(o.Custom2, o.Custom2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Custom3", GlobalUtilities.DBSafeValue(o.Custom3, o.Custom3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModDate", GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModUser", GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedDate", GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedUser", GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())));

            arrParams.Add(new SqlParameter("@TenID", GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt1", GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt2", GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt3", GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit1", GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit2", GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit3", GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText1", GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText2", GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText3", GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())));

            arrParams.Add(new SqlParameter("@ShortDescription", GlobalUtilities.DBSafeValue(o.ShortDescription, o.ShortDescription.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EndDate", GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EndTime", GlobalUtilities.DBSafeValue(o.EndTime, o.EndTime.GetTypeCode())));

            arrParams.Add(new SqlParameter("@ExternalLinkToEvent", GlobalUtilities.DBSafeValue(o.ExternalLinkToEvent, o.ExternalLinkToEvent.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HiddenFromPublic", GlobalUtilities.DBSafeValue(o.HiddenFromPublic, o.HiddenFromPublic.GetTypeCode())));

            var param = new SqlParameter("@EID", GlobalUtilities.DBSafeValue(o.EID, o.EID.GetTypeCode()));
            param.Direction = ParameterDirection.Output;
            arrParams.Add(param);

            SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Event_Insert", arrParams.ToArray());

            o.EID = int.Parse(param.Value.ToString());

            return o.EID;
        }
コード例 #5
0
        public static int Update(Event o)
        {
            int iReturn = -1; //assume the worst
            var arrParams = new List<SqlParameter>();

            arrParams.Add(new SqlParameter("@EID", GlobalUtilities.DBSafeValue(o.EID, o.EID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EventTitle", GlobalUtilities.DBSafeValue(o.EventTitle, o.EventTitle.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EventDate", GlobalUtilities.DBSafeValue(o.EventDate, o.EventDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EventTime", GlobalUtilities.DBSafeValue(o.EventTime, o.EventTime.GetTypeCode())));
            string html = o.HTML;
            if (!string.IsNullOrWhiteSpace(html) && html.EndsWith(TrailingBr))
            {
                html = html.Substring(0, html.Length - TrailingBr.Length);
            }
            arrParams.Add(new SqlParameter("@HTML", GlobalUtilities.DBSafeValue(html, html.GetTypeCode())));
            arrParams.Add(new SqlParameter("@SecretCode", GlobalUtilities.DBSafeValue(o.SecretCode, o.SecretCode.GetTypeCode())));
            arrParams.Add(new SqlParameter("@NumberPoints", GlobalUtilities.DBSafeValue(o.NumberPoints, o.NumberPoints.GetTypeCode())));
            arrParams.Add(new SqlParameter("@BadgeID", GlobalUtilities.DBSafeValue(o.BadgeID, o.BadgeID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@BranchID", GlobalUtilities.DBSafeValue(o.BranchID, o.BranchID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Custom1", GlobalUtilities.DBSafeValue(o.Custom1, o.Custom1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Custom2", GlobalUtilities.DBSafeValue(o.Custom2, o.Custom2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Custom3", GlobalUtilities.DBSafeValue(o.Custom3, o.Custom3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModDate", GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModUser", GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedDate", GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedUser", GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())));

            arrParams.Add(new SqlParameter("@TenID", GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt1", GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt2", GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt3", GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit1", GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit2", GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit3", GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText1", GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText2", GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText3", GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())));

            arrParams.Add(new SqlParameter("@ShortDescription", GlobalUtilities.DBSafeValue(o.ShortDescription, o.ShortDescription.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EndDate", GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EndTime", GlobalUtilities.DBSafeValue(o.EndTime, o.EndTime.GetTypeCode())));

            arrParams.Add(new SqlParameter("@ExternalLinkToEvent", GlobalUtilities.DBSafeValue(o.ExternalLinkToEvent, o.ExternalLinkToEvent.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HiddenFromPublic", GlobalUtilities.DBSafeValue(o.HiddenFromPublic, o.HiddenFromPublic.GetTypeCode())));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Event_Update", arrParams.ToArray());

            }
            catch (SqlException exx)
            {
                "GRA.SRP.DAL.Event".Log().Error("Error updating Event: {0} - {1}",
                    exx.Message,
                    exx.StackTrace);
                System.Diagnostics.Debug.Write(exx.Message);
            }

            return iReturn;

        }
コード例 #6
0
        private Event LoadEventObject()
        {
            var obj = new Event();

            obj.EventTitle = EventTitle.Text;
            obj.EventDate = FormatHelper.SafeToDateTime(EventDate.Text);
            obj.EventTime = EventTime.Text;
            obj.HTML = HTML.InnerHtml;
            obj.SecretCode = SecretCode.Text;
            obj.NumberPoints = NumberPoints.Text.SafeToInt();
            obj.BadgeID = BadgeID.SelectedValue.SafeToInt();
            obj.BranchID = BranchId.Text.SafeToInt();
            obj.Custom1 = Custom1.Value;
            obj.Custom2 = Custom2.Value;
            obj.Custom3 = Custom3.Value;

            obj.ShortDescription = ShortDescription.Text;
            obj.EndDate = EndDate.Text.SafeToDateTime();
            obj.EndTime = EndTime.Text;

            obj.AddedDate = DateTime.Now;
            obj.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session
            obj.LastModDate = obj.AddedDate;
            obj.LastModUser = obj.AddedUser;

            return obj;
        }
コード例 #7
0
        public bool Fetch(int EID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@EID", EID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Event_GetByID", arrParams);

            if (dr.Read())
            {

                // declare return value

                Event result = new Event();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["EID"].ToString(), out _int)) this.EID = _int;
                this.EventTitle = dr["EventTitle"].ToString();
                if (DateTime.TryParse(dr["EventDate"].ToString(), out _datetime)) this.EventDate = _datetime;
                this.EventTime = dr["EventTime"].ToString();
                result.HTML = dr["HTML"].ToString();
                if (!string.IsNullOrWhiteSpace(result.HTML) && result.HTML.EndsWith(TrailingBr))
                {
                    result.HTML = result.HTML.Substring(0, result.HTML.Length - TrailingBr.Length);
                }
                this.SecretCode = dr["SecretCode"].ToString();
                if (int.TryParse(dr["NumberPoints"].ToString(), out _int)) this.NumberPoints = _int;
                if (int.TryParse(dr["BadgeID"].ToString(), out _int)) this.BadgeID = _int;
                if (int.TryParse(dr["BranchID"].ToString(), out _int)) this.BranchID = _int;
                this.Custom1 = dr["Custom1"].ToString();
                this.Custom2 = dr["Custom2"].ToString();
                this.Custom3 = dr["Custom3"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) this.LastModDate = _datetime;
                this.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) this.AddedDate = _datetime;
                this.AddedUser = dr["AddedUser"].ToString();

                if (int.TryParse(dr["TenID"].ToString(), out _int)) this.TenID = _int;
                if (int.TryParse(dr["FldInt1"].ToString(), out _int)) this.FldInt1 = _int;
                if (int.TryParse(dr["FldInt2"].ToString(), out _int)) this.FldInt2 = _int;
                if (int.TryParse(dr["FldInt3"].ToString(), out _int)) this.FldInt3 = _int;
                this.FldBit1 = bool.Parse(dr["FldBit1"].ToString());
                this.FldBit2 = bool.Parse(dr["FldBit2"].ToString());
                this.FldBit3 = bool.Parse(dr["FldBit3"].ToString());
                this.FldText1 = dr["FldText1"].ToString();
                this.FldText2 = dr["FldText2"].ToString();
                this.FldText3 = dr["FldText3"].ToString();


                this.ShortDescription = dr["ShortDescription"].ToString();
                if (DateTime.TryParse(dr["EndDate"].ToString(), out _datetime)) this.EndDate = _datetime;
                this.EndTime = dr["EndTime"].ToString();

                this.HiddenFromPublic = (bool)dr["HiddenFromPublic"];
                this.ExternalLinkToEvent = dr["ExternalLinkToEvent"].ToString();

                dr.Close();

                return true;

            }

            dr.Close();

            return false;

        }
コード例 #8
0
 protected void GvRowCommand(object sender, GridViewCommandEventArgs e)
 {
     string editpage = "~/ControlRoom/Modules/Setup/EventAddEdit.aspx";
     string addpage = "~/ControlRoom/Modules/Setup/EventAddWizard.aspx";
     if (e.CommandName.ToLower() == "addrecord")
     {
         Session["EID"] = string.Empty; Response.Redirect(addpage);
     }
     if (e.CommandName.ToLower() == "editrecord")
     {
         int key = Convert.ToInt32(e.CommandArgument);
         Session["EID"] = key; Response.Redirect(editpage);
     }
     if (e.CommandName.ToLower() == "deleterecord")
     {
         var key = Convert.ToInt32(e.CommandArgument);
         try
         {
             var obj = new Event();
             if (obj.IsValid(BusinessRulesValidationMode.DELETE))
             {
                 obj.FetchObject(key).Delete();
                 var st = new SessionTools(Session);
                 st.RemoveCache(Cache, CacheKey.EventsActive);
                 st.RemoveCache(Cache, CacheKey.AllEvents);
                 LoadData();
                 var masterPage = (IControlRoomMaster)Master;
                 if (masterPage != null) masterPage.PageMessage = SRPResources.DeleteOK;
             }
             else
             {
                 var masterPage = (IControlRoomMaster)Master;
                 string message = String.Format(SRPResources.ApplicationError1, "<ul>");
                 foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                 {
                     message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                 }
                 message = string.Format("{0}</ul>", message);
                 if (masterPage != null) masterPage.PageError = message;
             }
         }
         catch (Exception ex)
         {
             var masterPage = (IControlRoomMaster)Master;
             if (masterPage != null)
                 masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
         }
     }
 }
コード例 #9
0
        private Event LoadEventObject()
        {
            var eventObj = new Event();

            eventObj.EventTitle = EventTitle.Text.Trim();
            eventObj.EventDate = FormatHelper.SafeToDateTime(EventDate.Text);
            //eventObj.EventTime = EventTime.Text;
            eventObj.HTML = HTML.InnerHtml.Trim();
            eventObj.SecretCode = SecretCode.Text.Trim().ToLower();
            eventObj.NumberPoints = NumberPoints.Text.SafeToInt();
            eventObj.BadgeID = BadgeID.SelectedValue.SafeToInt();
            eventObj.BranchID = BranchId.Text.SafeToInt();
            eventObj.Custom1 = Custom1.Value;
            eventObj.Custom2 = Custom2.Value;
            eventObj.Custom3 = Custom3.Value;

            //eventObj.ShortDescription = ShortDescription.Text;

            //eventObj.EndDate = EndDate.Text.SafeToDateTime();
            //eventObj.EndTime = EndTime.Text;

            eventObj.ExternalLinkToEvent = ExternalLinkToEvent.Text;
            eventObj.HiddenFromPublic = HiddenFromPublic.SelectedIndex > 0;

            eventObj.AddedDate = DateTime.Now;
            eventObj.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session
            eventObj.LastModDate = eventObj.AddedDate;
            eventObj.LastModUser = eventObj.AddedUser;

            return eventObj;
        }
コード例 #10
0
ファイル: Event.cs プロジェクト: iafb/greatreadingadventure
        public static int Update(Event o)
        {
            int iReturn = -1; //assume the worst
            var arrParams = new List<SqlParameter>();

            arrParams.Add(new SqlParameter("@EID", GlobalUtilities.DBSafeValue(o.EID, o.EID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EventTitle", GlobalUtilities.DBSafeValue(o.EventTitle, o.EventTitle.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EventDate", GlobalUtilities.DBSafeValue(o.EventDate, o.EventDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EventTime", GlobalUtilities.DBSafeValue(o.EventTime, o.EventTime.GetTypeCode())));
            string html = o.HTML;
            if (!string.IsNullOrWhiteSpace(html) && html.EndsWith(TrailingBr))
            {
                html = html.Substring(0, html.Length - TrailingBr.Length);
            }
            arrParams.Add(new SqlParameter("@HTML", GlobalUtilities.DBSafeValue(html, html.GetTypeCode())));
            arrParams.Add(new SqlParameter("@SecretCode", GlobalUtilities.DBSafeValue(o.SecretCode, o.SecretCode.GetTypeCode())));
            arrParams.Add(new SqlParameter("@NumberPoints", GlobalUtilities.DBSafeValue(o.NumberPoints, o.NumberPoints.GetTypeCode())));
            arrParams.Add(new SqlParameter("@BadgeID", GlobalUtilities.DBSafeValue(o.BadgeID, o.BadgeID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@BranchID", GlobalUtilities.DBSafeValue(o.BranchID, o.BranchID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Custom1", GlobalUtilities.DBSafeValue(o.Custom1, o.Custom1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Custom2", GlobalUtilities.DBSafeValue(o.Custom2, o.Custom2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@Custom3", GlobalUtilities.DBSafeValue(o.Custom3, o.Custom3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModDate", GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@LastModUser", GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedDate", GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@AddedUser", GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())));

            arrParams.Add(new SqlParameter("@TenID", GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt1", GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt2", GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldInt3", GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit1", GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit2", GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldBit3", GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText1", GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText2", GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())));
            arrParams.Add(new SqlParameter("@FldText3", GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())));

            arrParams.Add(new SqlParameter("@ShortDescription", GlobalUtilities.DBSafeValue(o.ShortDescription, o.ShortDescription.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EndDate", GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode())));
            arrParams.Add(new SqlParameter("@EndTime", GlobalUtilities.DBSafeValue(o.EndTime, o.EndTime.GetTypeCode())));

            arrParams.Add(new SqlParameter("@ExternalLinkToEvent", GlobalUtilities.DBSafeValue(o.ExternalLinkToEvent, o.ExternalLinkToEvent.GetTypeCode())));
            arrParams.Add(new SqlParameter("@HiddenFromPublic", GlobalUtilities.DBSafeValue(o.HiddenFromPublic, o.HiddenFromPublic.GetTypeCode())));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Event_Update", arrParams.ToArray());

            }
            catch (SqlException exx)
            {
                "GRA.SRP.DAL.Event".Log().Error("Error updating Event: {0} - {1}",
                    exx.Message,
                    exx.StackTrace);
                System.Diagnostics.Debug.Write(exx.Message);
            }

            return iReturn;

        }
コード例 #11
0
ファイル: Event.cs プロジェクト: iafb/greatreadingadventure
 /// <summary>
 /// Formats an event date to be nice for end users.
 /// 
 /// Must have an Event object with the following properties specified: EventDate,
 /// EventTime, EndDate, EndTime
 /// </summary>
 /// <param name="e">The Event object</param>
 /// <returns>A nice string describing start and end times.</returns>
 public static string DisplayEventDateTime(Event e)
 {
     return string.Format("{0} at {1}",
         e.EventDate.ToShortDateString(),
         e.EventDate.ToShortTimeString());
 }
コード例 #12
0
ファイル: Event.cs プロジェクト: iafb/greatreadingadventure
        public static Event GetEvent(int EID)
        {

            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@EID", EID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Event_GetByID", arrParams);

            if (dr.Read())
            {

                // declare return value

                Event result = new Event();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["EID"].ToString(), out _int)) result.EID = _int;
                result.EventTitle = dr["EventTitle"].ToString();
                if (DateTime.TryParse(dr["EventDate"].ToString(), out _datetime)) result.EventDate = _datetime;
                result.EventTime = dr["EventTime"].ToString();
                result.HTML = dr["HTML"].ToString();
                if (!string.IsNullOrWhiteSpace(result.HTML) && result.HTML.EndsWith(TrailingBr))
                {
                    result.HTML = result.HTML.Substring(0, result.HTML.Length - TrailingBr.Length);
                }

                result.SecretCode = dr["SecretCode"].ToString();
                if (int.TryParse(dr["NumberPoints"].ToString(), out _int)) result.NumberPoints = _int;
                if (int.TryParse(dr["BadgeID"].ToString(), out _int)) result.BadgeID = _int;
                if (int.TryParse(dr["BranchID"].ToString(), out _int)) result.BranchID = _int;
                result.Custom1 = dr["Custom1"].ToString();
                result.Custom2 = dr["Custom2"].ToString();
                result.Custom3 = dr["Custom3"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) result.LastModDate = _datetime;
                result.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) result.AddedDate = _datetime;
                result.AddedUser = dr["AddedUser"].ToString();

                if (int.TryParse(dr["TenID"].ToString(), out _int)) result.TenID = _int;
                if (int.TryParse(dr["FldInt1"].ToString(), out _int)) result.FldInt1 = _int;
                if (int.TryParse(dr["FldInt2"].ToString(), out _int)) result.FldInt2 = _int;
                if (int.TryParse(dr["FldInt3"].ToString(), out _int)) result.FldInt3 = _int;
                result.FldBit1 = bool.Parse(dr["FldBit1"].ToString());
                result.FldBit2 = bool.Parse(dr["FldBit2"].ToString());
                result.FldBit3 = bool.Parse(dr["FldBit3"].ToString());
                result.FldText1 = dr["FldText1"].ToString();
                result.FldText2 = dr["FldText2"].ToString();
                result.FldText3 = dr["FldText3"].ToString();


                result.ShortDescription = dr["ShortDescription"].ToString();
                if (DateTime.TryParse(dr["EndDate"].ToString(), out _datetime)) result.EndDate = _datetime;
                result.EndTime = dr["EndTime"].ToString();

                result.HiddenFromPublic = (bool)dr["HiddenFromPublic"];
                result.ExternalLinkToEvent = dr["ExternalLinkToEvent"].ToString();

                dr.Close();

                return result;

            }

            dr.Close();

            return null;

        }
コード例 #13
0
        public Event FetchObject(int EID)
        {
            // declare reader

            SqlDataReader dr;

            SqlParameter[] arrParams = new SqlParameter[1];

            arrParams[0] = new SqlParameter("@EID", EID);

            dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_Event_GetByID", arrParams);

            if (dr.Read())
            {

                // declare return value

                Event result = new Event();

                DateTime _datetime;

                int _int;

                //decimal _decimal;

                if (int.TryParse(dr["EID"].ToString(), out _int)) result.EID = _int;
                result.EventTitle = dr["EventTitle"].ToString();
                if (DateTime.TryParse(dr["EventDate"].ToString(), out _datetime)) result.EventDate = _datetime;
                result.EventTime = dr["EventTime"].ToString();
                result.HTML = dr["HTML"].ToString();
                result.SecretCode = dr["SecretCode"].ToString();
                if (int.TryParse(dr["NumberPoints"].ToString(), out _int)) result.NumberPoints = _int;
                if (int.TryParse(dr["BadgeID"].ToString(), out _int)) result.BadgeID = _int;
                if (int.TryParse(dr["BranchID"].ToString(), out _int)) result.BranchID = _int;
                result.Custom1 = dr["Custom1"].ToString();
                result.Custom2 = dr["Custom2"].ToString();
                result.Custom3 = dr["Custom3"].ToString();
                if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) result.LastModDate = _datetime;
                result.LastModUser = dr["LastModUser"].ToString();
                if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) result.AddedDate = _datetime;
                result.AddedUser = dr["AddedUser"].ToString();

                if (int.TryParse(dr["TenID"].ToString(), out _int)) result.TenID = _int;
                if (int.TryParse(dr["FldInt1"].ToString(), out _int)) result.FldInt1 = _int;
                if (int.TryParse(dr["FldInt2"].ToString(), out _int)) result.FldInt2 = _int;
                if (int.TryParse(dr["FldInt3"].ToString(), out _int)) result.FldInt3 = _int;
                result.FldBit1 = bool.Parse(dr["FldBit1"].ToString());
                result.FldBit2 = bool.Parse(dr["FldBit2"].ToString());
                result.FldBit3 = bool.Parse(dr["FldBit3"].ToString());
                result.FldText1 = dr["FldText1"].ToString();
                result.FldText2 = dr["FldText2"].ToString();
                result.FldText3 = dr["FldText3"].ToString();

                result.ShortDescription = dr["ShortDescription"].ToString();
                if (DateTime.TryParse(dr["EndDate"].ToString(), out _datetime)) result.EndDate = _datetime;
                result.EndTime = dr["EndTime"].ToString();

                dr.Close();

                return result;

            }

            dr.Close();

            return null;
        }
コード例 #14
0
        public static int Update(Event o)
        {
            int iReturn = -1; //assume the worst

            SqlParameter[] arrParams = new SqlParameter[29];

            arrParams[0] = new SqlParameter("@EID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EID, o.EID.GetTypeCode()));
            arrParams[1] = new SqlParameter("@EventTitle", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EventTitle, o.EventTitle.GetTypeCode()));
            arrParams[2] = new SqlParameter("@EventDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EventDate, o.EventDate.GetTypeCode()));
            arrParams[3] = new SqlParameter("@EventTime", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EventTime, o.EventTime.GetTypeCode()));
            arrParams[4] = new SqlParameter("@HTML", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML, o.HTML.GetTypeCode()));
            arrParams[5] = new SqlParameter("@SecretCode", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SecretCode, o.SecretCode.GetTypeCode()));
            arrParams[6] = new SqlParameter("@NumberPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NumberPoints, o.NumberPoints.GetTypeCode()));
            arrParams[7] = new SqlParameter("@BadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BadgeID, o.BadgeID.GetTypeCode()));
            arrParams[8] = new SqlParameter("@BranchID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BranchID, o.BranchID.GetTypeCode()));
            arrParams[9] = new SqlParameter("@Custom1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Custom1, o.Custom1.GetTypeCode()));
            arrParams[10] = new SqlParameter("@Custom2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Custom2, o.Custom2.GetTypeCode()));
            arrParams[11] = new SqlParameter("@Custom3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Custom3, o.Custom3.GetTypeCode()));
            arrParams[12] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[13] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[14] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[15] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

            arrParams[16] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[17] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[18] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[19] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[20] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[21] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[22] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[23] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[24] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[25] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            arrParams[26] = new SqlParameter("@ShortDescription", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ShortDescription, o.ShortDescription.GetTypeCode()));
            arrParams[27] = new SqlParameter("@EndDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode()));
            arrParams[28] = new SqlParameter("@EndTime", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EndTime, o.EndTime.GetTypeCode()));

            try
            {

                iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Event_Update", arrParams);

            }

            catch (SqlException exx)
            {

                System.Diagnostics.Debug.Write(exx.Message);

            }

            return iReturn;
        }
コード例 #15
0
        public static int Insert(Event o)
        {
            SqlParameter[] arrParams = new SqlParameter[29];

            arrParams[0] = new SqlParameter("@EventTitle", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EventTitle, o.EventTitle.GetTypeCode()));
            arrParams[1] = new SqlParameter("@EventDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EventDate, o.EventDate.GetTypeCode()));
            arrParams[2] = new SqlParameter("@EventTime", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EventTime, o.EventTime.GetTypeCode()));
            arrParams[3] = new SqlParameter("@HTML", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HTML, o.HTML.GetTypeCode()));
            arrParams[4] = new SqlParameter("@SecretCode", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SecretCode, o.SecretCode.GetTypeCode()));
            arrParams[5] = new SqlParameter("@NumberPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NumberPoints, o.NumberPoints.GetTypeCode()));
            arrParams[6] = new SqlParameter("@BadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BadgeID, o.BadgeID.GetTypeCode()));
            arrParams[7] = new SqlParameter("@BranchID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BranchID, o.BranchID.GetTypeCode()));
            arrParams[8] = new SqlParameter("@Custom1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Custom1, o.Custom1.GetTypeCode()));
            arrParams[9] = new SqlParameter("@Custom2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Custom2, o.Custom2.GetTypeCode()));
            arrParams[10] = new SqlParameter("@Custom3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Custom3, o.Custom3.GetTypeCode()));
            arrParams[11] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode()));
            arrParams[12] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode()));
            arrParams[13] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode()));
            arrParams[14] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode()));

            arrParams[15] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode()));
            arrParams[16] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode()));
            arrParams[17] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode()));
            arrParams[18] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode()));
            arrParams[19] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode()));
            arrParams[20] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode()));
            arrParams[21] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode()));
            arrParams[22] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode()));
            arrParams[23] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode()));
            arrParams[24] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode()));

            arrParams[25] = new SqlParameter("@ShortDescription", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ShortDescription, o.ShortDescription.GetTypeCode()));
            arrParams[26] = new SqlParameter("@EndDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EndDate, o.EndDate.GetTypeCode()));
            arrParams[27] = new SqlParameter("@EndTime", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EndTime, o.EndTime.GetTypeCode()));

            arrParams[28] = new SqlParameter("@EID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.EID, o.EID.GetTypeCode()));
            arrParams[28].Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_Event_Insert", arrParams);

            o.EID = int.Parse(arrParams[28].Value.ToString());

            return o.EID;
        }
コード例 #16
0
 /// <summary>
 /// Formats an event date to be nice for end users.
 /// 
 /// Must have an Event object with the following properties specified: EventDate,
 /// EventTime, EndDate, EndTime
 /// </summary>
 /// <param name="e">The Event object</param>
 /// <returns>A nice string describing start and end times.</returns>
 public static string DisplayEventDateTime(Event e)
 {
     StringBuilder sb = new StringBuilder(e.EventDate.ToNormalDate());
     if(!string.IsNullOrWhiteSpace(e.EventTime)) {
         sb.AppendFormat(" {0}", e.EventTime);
     }
     if(e.EndDate != null && e.EndDate > e.EventDate) {
         sb.AppendFormat(" until {0}",
                         e.EndDate.ToNormalDate().Replace("01/01/1900",
                                                          string.Empty));
         if(!string.IsNullOrWhiteSpace(e.EndTime)) {
             sb.AppendFormat(" {0}", e.EndTime);
         }
     }
     return sb.ToString();
 }