コード例 #1
0
    private void FillTimeZone(int locationId)
    {
        ITimeZoneService service = null;

        try
        {
            // Get time zone id.
            Location selectedLocation = this.mLocation.Where(item => item.Id == locationId).FirstOrDefault();
            if (selectedLocation == null)
            {
                this.hdnTimeZoneId.Value   = "0";
                this.spnTimeZone.InnerHtml = "";
                return;
            }

            // Create the service.
            service            = AppService.Create <ITimeZoneService>();
            service.AppManager = this.AppManager;
            Tks.Entities.TimeZone timeZone = service.Retrieve(selectedLocation.TimeZoneId);

            // Bind.
            this.hdnTimeZoneId.Value   = timeZone.Id.ToString();
            this.spnTimeZone.InnerHtml = timeZone.Name;
        }
        catch { throw; }
    }
コード例 #2
0
    private void DisplayEntityForEdit(int index)
    {
        ITimeZoneService service = null;

        try
        {
            //Create a Instance

            Tks.Entities.TimeZone entity = mTimeZoneList[index];
            // Assign to controls.
            this.hdnTimeZoneId.Value      = entity.Id.ToString();
            this.txtName.Value            = entity.Name;
            this.txtShortName.Value       = entity.ShortName;
            this.txtDescription.InnerText = entity.Description;
            this.chkIsActive.Checked      = entity.IsActive;

            // Show/Hide the controls.
            this.ShowHideEditControls(true);
        }
        catch { throw; }
        finally
        {
            if (service != null)
            {
                service.Dispose();
            }
        }
    }
コード例 #3
0
    protected void gvwTimeZoneList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Tks.Entities.TimeZone Entity         = (Tks.Entities.TimeZone)e.Row.DataItem;
                HtmlGenericControl    active         = (HtmlGenericControl)e.Row.FindControl("spnIsActive");
                HtmlGenericControl    LastUpdateuser = (HtmlGenericControl)e.Row.FindControl("spnLastUpdateUser");
                //Bind the TimeZone is Active or not
                active.InnerText = Entity.IsActive == true ? "Yes" : "No";


                //Bind  the Last modified Username

                LastUpdateuser.InnerText = Entity.CustomData["LastUpdateUserName"].ToString();
            }
        }
        catch
        { throw; }
    }
コード例 #4
0
    public bool UpdateEntity()
    {
        ITimeZoneService service        = null;
        bool             validateupdate = false;

        try
        {
            // Validate the entity values.
            if (hdnTimeZoneId.Value != "0")
            {
                this.ValidateEntity("Update");
            }
            else
            {
                this.ValidateEntity(string.Empty);
            }

            // Build entity.
            Tks.Entities.TimeZone entity = new Tks.Entities.TimeZone();
            entity.Id          = Int32.Parse(this.hdnTimeZoneId.Value);
            entity.Name        = this.txtName.Value;
            entity.ShortName   = this.txtShortName.Value;
            entity.Description = this.txtDescription.InnerText.ToString().Replace("<", "");
            if (hdnTimeZoneId.Value != "0")
            {
                entity.IsActive = this.chkIsActive.Checked;
            }
            else
            {
                entity.IsActive = true;
            }
            entity.Reason           = this.txtReason.Value;
            entity.LastUpdateUserId = 1;
            entity.LastUpdateDate   = DateTime.Now;
            // Create service and call method.
            service            = AppService.Create <ITimeZoneService>();
            service.AppManager = mAppManager;
            service.Update(entity);

            // Display succeed message.
        }

        catch (ValidationException ve)
        {
            // Display validation erros.
            this.DisplayValidationMessage(ve);
            validateupdate = true;
        }
        catch (Exception ex)
        {
            validateupdate = true;
            throw ex;
        }
        finally
        {
            if (service != null)
            {
                service.Dispose();
            }
        }
        return(validateupdate);
    }