protected void btnUpdate_Click(object sender, EventArgs e) { try { if (controlId == 0) // add control { if (txtControlKey.Text != string.Empty && ModuleControlController.CheckExistsControlKey(txtControlKey.Text)) { this.lblUpdateStatus.Text = MiscUtility.MSG_CONTROKEY_EXISTS; return; } ModuleInfo module = ModuleController.GetModule(moduleId); if (module == null) { return; } ModuleControlInfo moduleControl = new ModuleControlInfo(); moduleControl.ModuleID = module.ModuleID; moduleControl.ControlName = txtControlName.Text.Trim(); moduleControl.ControlKey = txtControlKey.Text.Trim(); moduleControl.ControlPath = dropPath.SelectedValue; moduleControl.ControlIcon = txtControlIcon.Text.Trim(); moduleControl.ControlOrder = ConvertUtility.ToInt32(dropControlOrder.SelectedValue); moduleControl.ControlHeader = chkControlHeader.Checked; string roleList = "|"; foreach (ListItem item in chkControlType.Items) { if (item.Selected) { roleList += item.Value + "|"; } } if (roleList.Length < 2) { roleList = string.Empty; } moduleControl.ControlTitle = txtControlTitle.Text; moduleControl.ControlRole = roleList; moduleControl.ControlDescription = txtControlDescription.Text.Trim(); ModuleControlController.AddModuleControl(moduleControl); } else // update control { ModuleControlInfo moduleControl = ModuleControlController.GetModuleControl(controlId); moduleControl.ControlName = txtControlName.Text.Trim(); moduleControl.ControlDescription = txtControlDescription.Text; moduleControl.ControlKey = txtControlKey.Text.Trim(); moduleControl.ControlPath = dropPath.SelectedValue; moduleControl.ControlIcon = txtControlIcon.Text.Trim(); moduleControl.ControlOrder = ConvertUtility.ToInt32(dropControlOrder.SelectedValue); string roleList = "|"; foreach (ListItem item in chkControlType.Items) { if (item.Selected) { roleList += item.Value + "|"; } } //if (roleList.Length < 2) roleList = string.Empty; moduleControl.ControlRole = roleList; moduleControl.ControlDescription = txtControlDescription.Text.Trim(); moduleControl.ControlHeader = chkControlHeader.Checked; ModuleControlController.UpdateModuleControl(moduleControl); } this.lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS; } catch (Exception ex) { Response.Write(ex.Message); } }