protected void Page_Command(Object sender, CommandEventArgs e) { string sMODULE_NAME = Sql.ToString(ViewState["MODULE_NAME"]); if (e.CommandName == "Save") { if (Page.IsValid) { try { // 04/24/2006 Paul. Upgrade to SugarCRM 4.2 Schema. // 04/24/2006 Paul. We dont 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_Update(gID, Sql.ToInteger(txtMAX_SIZE.Text), chkREQUIRED.Checked, chkAUDITED.Checked, txtDEFAULT_VALUE.Text, false); } else { Int32 nMAX_SIZE = Sql.ToInteger(txtMAX_SIZE.Text); bool bREQUIRED = chkREQUIRED.Checked; bool bAUDITED = chkAUDITED.Checked; string sDEFAULT_VALUE = txtDEFAULT_VALUE.Text; 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_Update"; IDbDataParameter parID = Sql.AddParameter(cmd, "@ID", gID); IDbDataParameter parMODIFIED_USER_ID = Sql.AddParameter(cmd, "@MODIFIED_USER_ID", Security.USER_ID); 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 parMASS_UPDATE = Sql.AddParameter(cmd, "@MASS_UPDATE", bMASS_UPDATE); cmd.ExecuteNonQuery(); } trn.Commit(); } catch (Exception ex) { trn.Rollback(); throw(new Exception(ex.Message, ex.InnerException)); } } } } // 01/10/2006 Paul. Clear the cache. SplendidCache.ClearFieldsMetaData(sMODULE_NAME); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; return; } Response.Redirect("default.aspx?MODULE_NAME=" + sMODULE_NAME); } } else if (e.CommandName == "Cancel") { Response.Redirect("default.aspx?MODULE_NAME=" + sMODULE_NAME); } }
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; } } } }
protected void Page_Command(object sender, CommandEventArgs e) { try { if (e.CommandName == "Search") { if (ctlNewRecord != null) { ctlNewRecord.Clear(); } } else if (e.CommandName == "NewRecord") { FIELDS_META_DATA_Bind(); } else if (e.CommandName == "EditCustomFields.Delete") { Guid gID = Sql.ToGuid(e.CommandArgument); // 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_Delete(gID); } else { 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_Delete"; // 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); cmd.ExecuteNonQuery(); } trn.Commit(); } catch (Exception ex) { trn.Rollback(); throw(new Exception(ex.Message, ex.InnerException)); } } } } // 01/10/2006 Paul. Clear the cache. SplendidCache.ClearFieldsMetaData(sMODULE_NAME); FIELDS_META_DATA_Bind(); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } }