private void DisplayEntityForEdit(int id) { IClientService Service = null; try { // Retrieve entity based on index. Tks.Entities.Client entity = mclientlist.Where(x => x.Id == id).FirstOrDefault(); // Assign to controls. this.hdnClientId.Value = entity.Id.ToString(); this.hdnResponsibleUserId.Value = entity.ResponsibleUserId.ToString(); this.txtName.Value = entity.Name; this.txtDescription.Value = entity.Description; this.txtResponsibleUser.Value = entity.CustomData["ResponsibleUserName"].ToString(); //this.txtReason.Value = entity.Reason; this.chkIsActive.Checked = entity.IsActive; // Show/Hide the controls. this.ShowHideEditControls(true); } catch { throw; } finally { if (Service != null) { Service.Dispose(); } } }
protected void gvwEntityList_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { Tks.Entities.Client Entity = (Tks.Entities.Client)e.Row.DataItem; HtmlGenericControl active = (HtmlGenericControl)e.Row.FindControl("spnIsActive"); //HtmlGenericControl LastUpdateuser = (HtmlGenericControl)e.Row.FindControl("spnLastUpdateUser"); HtmlGenericControl ResponsibleUserName = (HtmlGenericControl)e.Row.FindControl("spnResponsibleUserName"); //Bind the TimeZone is Active or not active.InnerText = Entity.IsActive == true ? "Active" : "InActive"; //Bind the Last modified Username //LastUpdateuser.InnerText = Entity.CustomData["LastUpdateUserName"].ToString(); ResponsibleUserName.InnerText = Entity.CustomData["ResponsibleUserName"].ToString(); } } catch { throw; } }
public bool UpdateEntity() { IClientService Service = null; bool validateupdate = false; try { // Validate the entity values. if (hdnClientId.Value != "0") { this.ValidateEntity("Update"); //mEntityEditPanelHeader = ADDModeDisplay; } else { this.ValidateEntity(string.Empty); btnUpdate.Text = ADDeditModeDisplay; mEntityEditPanelHeader = ADDeditModeDisplay; } // Build entity. Tks.Entities.Client client = new Tks.Entities.Client(); client.Id = Int32.Parse(this.hdnClientId.Value); client.Name = this.txtName.Value; client.Description = this.txtDescription.Value; client.ResponsibleUserId = Int32.Parse(this.hdnResponsibleUserId.Value); if (hdnClientId.Value != "0") { client.IsActive = this.chkIsActive.Checked; } else { client.IsActive = true; } client.Reason = this.txtReason.Value; client.LastUpdateUserId = 1; client.LastUpdateDate = DateTime.Now; // Create service and call method. Service = AppService.Create <IClientService>(); Service.AppManager = mAppManager; Service.Update(client); // Display succeed message. } catch (ValidationException ve) { // Display validation erros. this.DisplayValidationMessage(ve); validateupdate = true; } catch { throw; } finally { if (Service != null) { Service.Dispose(); } } return(validateupdate); }