private void Page_Load(object sender, System.EventArgs e) { Utils.SetPageTitle(Page, L10n.Term("Administration.LBL_RENAME_TABS")); // 06/04/2006 Paul. Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load. this.Visible = SplendidCRM.Security.IS_ADMIN; if (!this.Visible) { return; } // 09/08/2005 Paul. An empty key is valid, so use a separate INSERT field. if (txtRENAME.Value == "1") { try { SqlProcs.spMODULES_TAB_Rename(Guid.Empty, txtKEY.Value, ctlSearch.LANGUAGE, txtVALUE.Value); SplendidCache.ClearList(ctlSearch.LANGUAGE, "moduleList"); // 01/17/2006 Paul. Also need to clear the TabMenu. SplendidCache.ClearTabMenu(); // 04/20/2006 Paul. Also clear the term for the list. L10N.SetTerm(ctlSearch.LANGUAGE, String.Empty, "moduleList", txtKEY.Value, txtVALUE.Value); txtRENAME.Value = ""; // 09/09/2005 Paul. Transfer so that viewstate will be reset completely. // 01/04/2005 Paul. Redirecting to default.aspx will loose the language setting. Just rebind. } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } } // Must bind in order for LinkButton to get the argument. // ImageButton does not work no matter what I try. TERMINOLOGY_BindData(true); }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "NewRecord") { reqNAME.Enabled = true; reqNAME.Validate(); if (Page.IsValid) { Guid gID = Guid.Empty; try { SqlProcs.spTERMINOLOGY_InsertOnly(txtNAME.Text, lstLANGUAGE.SelectedValue, lstMODULE_NAME.SelectedValue, lstLIST_NAME.SelectedValue, Sql.ToInteger(txtLIST_ORDER.Text), txtDISPLAY_NAME.Text); // 01/16/2006 Paul. Update language cache. if (Sql.IsEmptyString(lstLIST_NAME.SelectedValue)) { L10N.SetTerm(lstLANGUAGE.SelectedValue, lstMODULE_NAME.SelectedValue, txtNAME.Text, txtDISPLAY_NAME.Text); } else { L10N.SetTerm(lstLANGUAGE.SelectedValue, lstMODULE_NAME.SelectedValue, lstLIST_NAME.SelectedValue, txtNAME.Text, txtDISPLAY_NAME.Text); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } if (!Sql.IsEmptyGuid(gID)) { Response.Redirect("default.aspx"); } } } }
private void Page_Load(object sender, System.EventArgs e) { Utils.SetPageTitle(Page, L10n.Term("Dropdown.LBL_LIST_FORM_TITLE")); // 06/04/2006 Paul. Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load. this.Visible = SplendidCRM.Security.IS_ADMIN; if (!this.Visible) { return; } try { // 09/08/2005 Paul. An empty key is valid, so use a separate INSERT field. if (txtINSERT.Value == "1") { try { Guid gID = Guid.Empty; SqlProcs.spTERMINOLOGY_LIST_Insert(ref gID, txtKEY.Value, ctlSearch.LANGUAGE, String.Empty, ctlSearch.DROPDOWN, Sql.ToInteger(txtINDEX.Value), txtVALUE.Value); // 01/16/2006 Paul. Update cache. L10N.SetTerm(ctlSearch.LANGUAGE, String.Empty, ctlSearch.DROPDOWN, txtKEY.Value, txtVALUE.Value); // 07/25/2005 Paul. In addition to updating the term, we must update the cached list. SplendidCache.ClearList(ctlSearch.LANGUAGE, ctlSearch.DROPDOWN); txtINSERT.Value = ""; // 09/09/2005 Paul. Transfer so that viewstate will be reset completely. Response.Redirect("default.aspx?Dropdown=" + ctlSearch.DROPDOWN); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } } if (!IsPostBack) { string sDROPDOWN = Sql.ToString(Request["Dropdown"]); if (!Sql.IsEmptyString(sDROPDOWN)) { ctlSearch.DROPDOWN = sDROPDOWN; TERMINOLOGY_BindData(true); } } else { // Must bind in order for LinkButton to get the argument. // ImageButton does not work no matter what I try. TERMINOLOGY_BindData(true); } } catch (Exception ex) { // 01/20/2006 Paul. Need to catch all errors. Saw a dropdown error when creating a new dropdown. lblError.Text = ex.Message; } }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "NewRecord") { txtNAME.Text = txtNAME.Text.Trim(); txtLABEL.Text = txtLABEL.Text.Trim(); if (Sql.IsEmptyString(txtLABEL.Text)) { txtLABEL.Text = txtNAME.Text; } Regex r = new Regex(@"[^\w]+"); txtNAME.Text = r.Replace(txtNAME.Text, "_"); // 01/11/2006 Paul. The label does not need to be validated because it will become the term display name. reqNAME.Enabled = true; regNAME.Enabled = true; reqNAME.Validate(); regNAME.Validate(); if (Page.IsValid) { Guid gID = Guid.Empty; try { // 01/11/2006 Paul. The label needs to be stored in the TERMINOLOGY table. // 05/20/2007 Paul. The Label term is no longer used. The label term must be derived from the field name // in order for the reporting area to work properly. The reporting area assumes that the label is the of the format "LBL_" + Name + "_C". string sLABEL_TERM = String.Empty; // r.Replace(txtLABEL.Text, "_"); // 04/24/2006 Paul. Upgrade to SugarCRM 4.2 Schema. // 04/24/2006 Paul. We don't support MassUpdate at this time. // 07/18/2006 Paul. Manually create the command so that we can increase the timeout. // 07/18/2006 Paul. Keep the original procedure call so that we will get a compiler error if something changes. bool bIncreaseTimeout = true; if (!bIncreaseTimeout) { SqlProcs.spFIELDS_META_DATA_Insert(ref gID, txtNAME.Text, txtLABEL.Text, sLABEL_TERM, sMODULE_NAME, lstDATA_TYPE.SelectedValue, Sql.ToInteger(txtMAX_SIZE.Text), chkREQUIRED.Checked, chkAUDITED.Checked, txtDEFAULT_VALUE.Text, lstDROPDOWN_LIST.SelectedValue, false); } else { string sNAME = txtNAME.Text; string sLABEL = txtLABEL.Text; string sCUSTOM_MODULE = sMODULE_NAME; string sDATA_TYPE = lstDATA_TYPE.SelectedValue; Int32 nMAX_SIZE = Sql.ToInteger(txtMAX_SIZE.Text); bool bREQUIRED = chkREQUIRED.Checked; bool bAUDITED = chkAUDITED.Checked; string sDEFAULT_VALUE = txtDEFAULT_VALUE.Text; string sDROPDOWN_LIST = lstDROPDOWN_LIST.SelectedValue; bool bMASS_UPDATE = false; DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbTransaction trn = con.BeginTransaction()) { try { using (IDbCommand cmd = con.CreateCommand()) { cmd.Transaction = trn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "spFIELDS_META_DATA_Insert"; // 07/18/2006 Paul. Tripple the default timeout. The operation was timing-out on QA machines and on the demo server. // 02/03/2007 Paul. Increase timeout to 5 minutes. It should not take that long, but some users are reporting a timeout. cmd.CommandTimeout = 5 * 60; IDbDataParameter parID = Sql.AddParameter(cmd, "@ID", gID); IDbDataParameter parMODIFIED_USER_ID = Sql.AddParameter(cmd, "@MODIFIED_USER_ID", Security.USER_ID); IDbDataParameter parNAME = Sql.AddParameter(cmd, "@NAME", sNAME, 255); IDbDataParameter parLABEL = Sql.AddParameter(cmd, "@LABEL", sLABEL, 255); IDbDataParameter parLABEL_TERM = Sql.AddParameter(cmd, "@LABEL_TERM", sLABEL_TERM, 255); IDbDataParameter parCUSTOM_MODULE = Sql.AddParameter(cmd, "@CUSTOM_MODULE", sCUSTOM_MODULE, 255); IDbDataParameter parDATA_TYPE = Sql.AddParameter(cmd, "@DATA_TYPE", sDATA_TYPE, 255); IDbDataParameter parMAX_SIZE = Sql.AddParameter(cmd, "@MAX_SIZE", nMAX_SIZE); IDbDataParameter parREQUIRED = Sql.AddParameter(cmd, "@REQUIRED", bREQUIRED); IDbDataParameter parAUDITED = Sql.AddParameter(cmd, "@AUDITED", bAUDITED); IDbDataParameter parDEFAULT_VALUE = Sql.AddParameter(cmd, "@DEFAULT_VALUE", sDEFAULT_VALUE, 255); IDbDataParameter parDROPDOWN_LIST = Sql.AddParameter(cmd, "@DROPDOWN_LIST", sDROPDOWN_LIST, 50); IDbDataParameter parMASS_UPDATE = Sql.AddParameter(cmd, "@MASS_UPDATE", bMASS_UPDATE); parID.Direction = ParameterDirection.InputOutput; cmd.ExecuteNonQuery(); gID = Sql.ToGuid(parID.Value); } trn.Commit(); } catch (Exception ex) { trn.Rollback(); throw(new Exception(ex.Message, ex.InnerException)); } } } } // 01/11/2006 Paul. Add term to the local cache. Always default to english. //Application["en-US." + sMODULE_NAME + "." + sLABEL_TERM] = txtLABEL.Text; // 04/05/2006 Paul. A _C is appended to the term in the procedure. Do so here as well. // 05/20/2007 Paul. The label is also prepended with LBL_. This is a requirement for the reporting system. // 05/20/2007 Paul. The Label term is no longer used. The label term must be derived from the field name // in order for the reporting area to work properly. The reporting area assumes that the label is the of the format "LBL_" + Name + "_C". L10N.SetTerm("en-US", sMODULE_NAME, "LBL_" + txtNAME.Text.ToUpper() + "_C", txtLABEL.Text); // 01/10/2006 Paul. Clear the cache. SplendidCache.ClearFieldsMetaData(sMODULE_NAME); Clear(); if (Command != null) { Command(this, e); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } } } }