protected void ctlParameterFormView_ItemUpdating(object sender, FormViewUpdateEventArgs e) { short Id = UIHelper.ParseShort(ctlParameterFormView.DataKey.Value.ToString()); DbParameter dbParam = DbParameterService.FindByIdentity(Id); TextBox ctlParameterValueTextInGrid = ctlParameterFormView.FindControl("ctlParameterValueText") as TextBox; TextBox ctlParameterValueIntInGrid = ctlParameterFormView.FindControl("ctlParameterValueInt") as TextBox; global::SCG.eAccounting.Web.UserControls.Calendar ctlCalendarInGrid = ctlParameterFormView.FindControl("ctlCalendar") as global::SCG.eAccounting.Web.UserControls.Calendar; Label ctlParameterTypeInGrid = ctlParameterFormView.FindControl("ctlParameterType") as Label; string parameterType = ctlParameterTypeInGrid.Text; if (parameterType.ToLower().Trim() == "text") { dbParam.ParameterValue = ctlParameterValueTextInGrid.Text.Trim(); } else if (parameterType.ToLower().Trim() == "integer") { if (!ctlParameterValueIntInGrid.Text.Equals(string.Empty)) { dbParam.ParameterValue = ctlParameterValueIntInGrid.Text.Trim(); } else { dbParam.ParameterValue = "0"; } } else if (parameterType.ToLower().Trim() == "date") { dbParam.ParameterValue = ctlCalendarInGrid.DateValue; } else { dbParam.ParameterValue = ctlParameterValueTextInGrid.Text.Trim(); } try { DbParameterService.UpdateParameter(dbParam); e.Cancel = true; ctlGridParameter.DataCountAndBind(); ctlParameterModalPopupExtender.Hide(); UpdatePanelParamaterGridView.Update(); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }
protected void ctlParameterFormView_DataBound(object sender, EventArgs e) { if (ctlParameterFormView.CurrentMode.Equals(FormViewMode.Edit)) { short groupNo = UIHelper.ParseShort(Session["groupNo"].ToString()); Label ctlParameterTypeInGrid = ctlParameterFormView.FindControl("ctlParameterType") as Label; #region Hidden Panel pnText = ctlParameterFormView.FindControl("ctlTextPanel") as Panel; Panel pnInteger = ctlParameterFormView.FindControl("ctlIntegerPanel") as Panel; Panel pnDate = ctlParameterFormView.FindControl("ctlDatePanel") as Panel; string parameterType = ctlParameterTypeInGrid.Text; if (parameterType.ToLower().Trim() == "text") { pnText.Visible = true; pnInteger.Visible = false; pnDate.Visible = false; } else if (parameterType.ToLower().Trim() == "integer") { pnText.Visible = false; pnInteger.Visible = true; pnDate.Visible = false; } else if (parameterType.ToLower().Trim() == "date") { pnText.Visible = false; pnInteger.Visible = false; pnDate.Visible = true; Label ctlParameterValueDateInGrid = ctlParameterFormView.FindControl("ctlParameterValueDate") as Label; global::SCG.eAccounting.Web.UserControls.Calendar ctlCalendarInGrid = ctlParameterFormView.FindControl("ctlCalendar") as global::SCG.eAccounting.Web.UserControls.Calendar; ctlCalendarInGrid.DateValue = ctlParameterValueDateInGrid.Text; } else { pnText.Visible = true; pnInteger.Visible = false; pnDate.Visible = false; } #endregion Hidden DbParameter parameter = DbParameterService.FindByIdentity(groupNo); DbParameterGroup parameterGroup = DbParameterGroupQuery.FindByIdentity(groupNo); Label ctlGroupNameInGrid = ctlParameterFormView.FindControl("ctlGroupName") as Label; ctlGroupNameInGrid.Text = parameterGroup.GroupName; } }