private void Page_Load(object sender, System.EventArgs e) { Utils.SetPageTitle(Page, L10n.Term(m_sMODULE + ".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.GetUserAccess(m_sMODULE, "list") >= 0); if (!this.Visible) { return; } try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwIFRAMES_List" + ControlChars.CrLf + " where 1 = 1 " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; #if DEBUG Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); #endif using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); // 08/01/2005 Paul. Convert the term here so that sorting will apply. foreach (DataRow row in dt.Rows) { // 08/17/2005 Paul. Don't convert if NULL. // 02/23/2005 Paul. These lists are not part of the iFrame module. row["TYPE"] = L10n.Term(".DROPDOWN_TYPE.", row["TYPE"]); row["PLACEMENT"] = L10n.Term(".DROPDOWN_PLACEMENT.", row["PLACEMENT"]); } vwMain = dt.DefaultView; grdMain.DataSource = vwMain; if (!IsPostBack) { grdMain.SortColumn = "NAME"; grdMain.SortOrder = "asc"; grdMain.ApplySort(); grdMain.DataBind(); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
protected void Page_Command(object sender, CommandEventArgs e) { try { if (e.CommandName == "Search") { // 10/13/2005 Paul. Make sure to clear the page index prior to applying search. grdMain.CurrentPageIndex = 0; grdMain.ApplySort(); grdMain.DataBind(); } // 12/14/2007 Paul. We need to capture the sort event from the SearchView. else if (e.CommandName == "SortGrid") { grdMain.SetSortFields(e.CommandArgument as string[]); } else if (e.CommandName == "MassUpdate") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { // 10/26/2007 Paul. Use a stack to run the update in blocks of under 200 IDs. //string sIDs = Utils.ValidateIDs(arrID); System.Collections.Stack stk = Utils.FilterByACL_Stack(m_sMODULE, "edit", arrID, "ACCOUNTS"); if (stk.Count > 0) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbTransaction trn = con.BeginTransaction()) { try { while (stk.Count > 0) { string sIDs = Utils.BuildMassIDs(stk); // 09/11/2007 Paul. Mass update of teams is now available. SqlProcs.spACCOUNTS_MassUpdate(sIDs, ctlMassUpdate.ASSIGNED_USER_ID, ctlMassUpdate.ACCOUNT_TYPE, ctlMassUpdate.INDUSTRY, ctlMassUpdate.TEAM_ID, trn); } trn.Commit(); } catch (Exception ex) { trn.Rollback(); throw(new Exception(ex.Message, ex.InnerException)); } } } Response.Redirect("default.aspx"); } } } else if (e.CommandName == "MassDelete") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { // 10/26/2007 Paul. Use a stack to run the update in blocks of under 200 IDs. //string sIDs = Utils.ValidateIDs(arrID); System.Collections.Stack stk = Utils.FilterByACL_Stack(m_sMODULE, "delete", arrID, "ACCOUNTS"); if (stk.Count > 0) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbTransaction trn = con.BeginTransaction()) { try { while (stk.Count > 0) { string sIDs = Utils.BuildMassIDs(stk); SqlProcs.spACCOUNTS_MassDelete(sIDs, trn); } trn.Commit(); } catch (Exception ex) { trn.Rollback(); throw(new Exception(ex.Message, ex.InnerException)); } } } Response.Redirect("default.aspx"); } } } else if (e.CommandName == "Export") { // 11/03/2006 Paul. Apply ACL rules to Export. int nACLACCESS = SplendidCRM.Security.GetUserAccess(m_sMODULE, "export"); if (nACLACCESS >= 0) { if (nACLACCESS == ACL_ACCESS.OWNER) { vwMain.RowFilter = "ASSIGNED_USER_ID = '" + Security.USER_ID.ToString() + "'"; } string[] arrID = Request.Form.GetValues("chkMain"); SplendidExport.Export(vwMain, m_sMODULE, ctlExportHeader.ExportFormat, ctlExportHeader.ExportRange, grdMain.CurrentPageIndex, grdMain.PageSize, arrID); } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } }
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, lstDROPDOWN_LIST.SelectedValue, false); } else { 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_Update"; // 01/06/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 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); // 01/10/2007 Paul. DROPDOWN_LIST was added as it can be modified. IDbDataParameter parDROPDOWN_LIST = Sql.AddParameter(cmd, "@DROPDOWN_LIST", sDROPDOWN_LIST, 50); 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); 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); } }
private void Page_Load(object sender, System.EventArgs e) { Utils.SetPageTitle(Page, L10n.Term(m_sMODULE + ".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.GetUserAccess(m_sMODULE, "list") >= 0); if (!this.Visible) { return; } try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwCONTACTS_List" + ControlChars.CrLf + " where 1 = 1 " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; int nACLACCESS = Security.GetUserAccess(m_sMODULE, "list"); if (nACLACCESS == ACL_ACCESS.OWNER) { Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false); } ctlSearch.SqlSearchClause(cmd); #if DEBUG Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); #endif using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); vwMain = dt.DefaultView; grdMain.DataSource = vwMain; if (!IsPostBack) { grdMain.SortColumn = "NAME"; grdMain.SortOrder = "asc"; grdMain.ApplySort(); grdMain.DataBind(); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term(".moduleList." + m_sMODULE)); // 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.GetUserAccess(m_sMODULE, "view") >= 0); if (!this.Visible) { return; } try { gID = Sql.ToGuid(Request["ID"]); // 11/28/2005 Paul. We must always populate the table, otherwise it will disappear during event processing. //if ( !IsPostBack ) { if (!Sql.IsEmptyGuid(gID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwQUOTES_Edit" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 11/24/2006 Paul. Use new Security.Filter() function to apply Team and ACL security rules. Security.Filter(cmd, m_sMODULE, "view"); Sql.AppendParameter(cmd, gID, "ID", false); con.Open(); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = Sql.ToString(rdr["NAME"]); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); this.AppendDetailViewFields(m_sMODULE + ".DetailView", tblMain, rdr, new CommandEventHandler(Page_Command)); this.AppendDetailViewFields(m_sMODULE + ".SummaryView", tblSummary, rdr, new CommandEventHandler(Page_Command)); ctlDetailButtons.SetUserAccess(m_sMODULE, Sql.ToGuid(rdr["ASSIGNED_USER_ID"])); } else { // 11/25/2006 Paul. If item is not visible, then don't show its sub panel either. plcSubPanel.Visible = false; ctlDetailButtons.DisableAll(); ctlDetailButtons.ErrorText = L10n.Term("ACL.LBL_NO_ACCESS"); } } } } } } // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlDetailButtons.ErrorText = ex.Message; } }
protected void Page_Command(Object sender, CommandEventArgs e) { // 06/08/2006 Paul. Redirect to parent if that is where the note was originated. Guid gPARENT_ID = Sql.ToGuid(Request["PARENT_ID"]); string sMODULE = String.Empty; string sPARENT_TYPE = String.Empty; string sPARENT_NAME = String.Empty; try { SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); // The only possible error is a connection failure, so just ignore all errors. gPARENT_ID = Guid.Empty; } if (e.CommandName == "Save") { SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this); SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditAddress", this); SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditDescription", this); if (Page.IsValid) { string sCUSTOM_MODULE = "QUOTES"; DataTable dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbTransaction trn = con.BeginTransaction()) { try { SqlProcs.spQUOTES_Update (ref gID , new DynamicControl(this, "ASSIGNED_USER_ID").ID , new DynamicControl(this, "NAME").Text , new DynamicControl(this, "OPPORTUNITY_ID").ID , new DynamicControl(this, "QUOTE_TYPE").SelectedValue , new DynamicControl(this, "PAYMENT_TERMS").SelectedValue , new DynamicControl(this, "ORDER_STAGE").SelectedValue , new DynamicControl(this, "QUOTE_STAGE").SelectedValue , new DynamicControl(this, "PURCHASE_ORDER_NUM").Text , new DynamicControl(this, "ORIGINAL_PO_DATE").DateValue , new DynamicControl(this, "DATE_QUOTE_CLOSED").DateValue , new DynamicControl(this, "DATE_QUOTE_EXPECTED_CLOSED").DateValue , new DynamicControl(this, "DATE_ORDER_SHIPPED").DateValue , new DynamicControl(this, "SHOW_LINE_NUMS").Checked , new DynamicControl(this, "CALC_GRAND_TOTAL").Checked , new DynamicControl(this, "CURRENCY_ID").ID , new DynamicControl(this, "TAXRATE_ID").ID , new DynamicControl(this, "SHIPPER_ID").ID , new DynamicControl(this, "SUBTOTAL").DecimalValue , new DynamicControl(this, "SHIPPING").DecimalValue , new DynamicControl(this, "TAX").DecimalValue , new DynamicControl(this, "TOTAL").DecimalValue , new DynamicControl(this, "BILLING_ACCOUNT_ID").ID , new DynamicControl(this, "BILLING_CONTACT_ID").ID , new DynamicControl(this, "BILLING_ADDRESS_STREET").Text , new DynamicControl(this, "BILLING_ADDRESS_CITY").Text , new DynamicControl(this, "BILLING_ADDRESS_STATE").Text , new DynamicControl(this, "BILLING_ADDRESS_POSTALCODE").Text , new DynamicControl(this, "BILLING_ADDRESS_COUNTRY").Text , new DynamicControl(this, "SHIPPING_ACCOUNT_ID").ID , new DynamicControl(this, "SHIPPING_CONTACT_ID").ID , new DynamicControl(this, "SHIPPING_ADDRESS_STREET").Text , new DynamicControl(this, "SHIPPING_ADDRESS_CITY").Text , new DynamicControl(this, "SHIPPING_ADDRESS_STATE").Text , new DynamicControl(this, "SHIPPING_ADDRESS_POSTALCODE").Text , new DynamicControl(this, "SHIPPING_ADDRESS_COUNTRY").Text , new DynamicControl(this, "DESCRIPTION").Text , trn ); SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields); trn.Commit(); } catch (Exception ex) { trn.Rollback(); SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlEditButtons.ErrorText = ex.Message; return; } } } if (!Sql.IsEmptyGuid(gPARENT_ID)) { Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString()); } else { Response.Redirect("view.aspx?ID=" + gID.ToString()); } } } else if (e.CommandName == "Cancel") { if (!Sql.IsEmptyGuid(gPARENT_ID)) { Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString()); } else if (Sql.IsEmptyGuid(gID)) { Response.Redirect("default.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID.ToString()); } } }
private void Page_Load(object sender, System.EventArgs e) { Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE)); // 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.GetUserAccess(m_sMODULE, "edit") >= 0); if (!this.Visible) { return; } try { gID = Sql.ToGuid(Request["ID"]); if (!IsPostBack) { // 07/29/2005 Paul. SugarCRM 3.0 does not allow the NONE option. //lstPARENT_TYPE .Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), "")); Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwTASKS_Edit" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; if (!Sql.IsEmptyGuid(gDuplicateID)) { Sql.AddParameter(cmd, "@ID", gDuplicateID); gID = Guid.Empty; } else { Sql.AddParameter(cmd, "@ID", gID); } con.Open(); #if DEBUG Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); #endif using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = Sql.ToString(rdr["NAME"]); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); // 07/15/2006 Paul. Contacts are not valid parents for a Task. // Manually remove them as the list record_type_display is common across all other parents. DropDownList lstPARENT_TYPE = FindControl("PARENT_TYPE") as DropDownList; if (lstPARENT_TYPE != null) { lstPARENT_TYPE.Items.Remove("Contacts"); } // 03/04/2006 Paul. The close button on the Tasks List is used to edit and set STATUS to Completed. // 06/21/2006 Paul. Change parameter to Close so that the same parameter can be used for Calls, Meetings and Tasks. // 08/08/2006 Paul. SugarCRM uses Completed in its URL, so we will do the same. if (Sql.ToString(Request["Status"]) == "Completed") { new DynamicControl(this, "STATUS").SelectedValue = "Completed"; } } } } } } else { this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); // 07/15/2006 Paul. Contacts are not valid parents for a Task. // Manually remove them as the list record_type_display is common across all other parents. DropDownList lstPARENT_TYPE = FindControl("PARENT_TYPE") as DropDownList; if (lstPARENT_TYPE != null) { lstPARENT_TYPE.Items.Remove("Contacts"); } Guid gPARENT_ID = Sql.ToGuid(Request["PARENT_ID"]); Guid gCONTACT_ID = Sql.ToGuid(Request["CONTACT_ID"]); if (!Sql.IsEmptyGuid(gPARENT_ID)) { string sMODULE = String.Empty; string sPARENT_TYPE = String.Empty; string sPARENT_NAME = String.Empty; SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME); if (!Sql.IsEmptyGuid(gPARENT_ID)) { // 07/15/2006 Paul. If the parent is a contact, then convert to a contact. if (sPARENT_TYPE == "Contacts") { gCONTACT_ID = gPARENT_ID; } else { new DynamicControl(this, "PARENT_ID").ID = gPARENT_ID; new DynamicControl(this, "PARENT_NAME").Text = sPARENT_NAME; new DynamicControl(this, "PARENT_TYPE").SelectedValue = sPARENT_TYPE; } } } if (!Sql.IsEmptyGuid(gCONTACT_ID)) { string sMODULE = String.Empty; string sCONTACT_TYPE = String.Empty; string sCONTACT_NAME = String.Empty; SqlProcs.spPARENT_Get(ref gCONTACT_ID, ref sMODULE, ref sCONTACT_TYPE, ref sCONTACT_NAME); if (!Sql.IsEmptyGuid(gCONTACT_ID)) { new DynamicControl(this, "CONTACT_ID").ID = gCONTACT_ID; new DynamicControl(this, "CONTACT_NAME").Text = sCONTACT_NAME; } } try { // 12/04/2005 Paul. Default value is Medium. new DynamicControl(this, "PRIORITY").SelectedValue = "Medium"; } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message); } try { // 12/04/2005 Paul. Default value is Not Started. new DynamicControl(this, "STATUS").SelectedValue = "Not Started"; } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message); } } } else { // 12/02/2005 Paul. When validation fails, the header title does not retain its value. Update manually. ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlEditButtons.ErrorText = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term("Bugs.LBL_LIST_FORM_TITLE")); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwBUGS_List" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 11/24/2006 Paul. Use new Security.Filter() function to apply Team and ACL security rules. Security.Filter(cmd, "Bugs", "list"); ctlSearchView.SqlSearchClause(cmd); if (bDebug) { Page.ClientScript.RegisterClientScriptBlock(System.Type.GetType("System.String"), "SQLCode", Sql.ClientScriptBlock(cmd)); } try { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); // 08/01/2005 Paul. Convert the term here so that sorting will apply. foreach (DataRow row in dt.Rows) { // 08/17/2005 Paul. Don't convert if NULL. row["STATUS"] = L10n.Term(".bug_status_dom.", row["STATUS"]); row["TYPE"] = L10n.Term(".bug_type_dom.", row["TYPE"]); row["PRIORITY"] = L10n.Term(".bug_priority_dom.", row["PRIORITY"]); } vwMain = dt.DefaultView; grdMain.DataSource = vwMain; if (!IsPostBack) { // 12/14/2007 Paul. Only set the default sort if it is not already set. It may have been set by SearchView. if (String.IsNullOrEmpty(grdMain.SortColumn)) { grdMain.SortColumn = "NAME"; grdMain.SortOrder = "asc"; } grdMain.ApplySort(); grdMain.DataBind(); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } } } if (!IsPostBack) { Page.DataBind(); } }
private void Page_Load(object sender, System.EventArgs e) { Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE)); // 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.GetUserAccess(m_sMODULE, "view") >= 0); if (!this.Visible) { return; } try { gID = Sql.ToGuid(Request["ID"]); // 12/06/2005 Paul. A user can edit himself. btnEdit.Visible = !PrintView && (SplendidCRM.Security.IS_ADMIN || gID == Security.USER_ID); btnDuplicate.Visible = !PrintView && SplendidCRM.Security.IS_ADMIN; btnReset.Visible = !PrintView && SplendidCRM.Security.IS_ADMIN; // 11/28/2005 Paul. We must always populate the table, otherwise it will disappear during event processing. //if ( !IsPostBack ) { if (!Sql.IsEmptyGuid(gID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwEMPLOYEES_Edit" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gID); con.Open(); #if DEBUG Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); #endif using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = Sql.ToString(rdr["FULL_NAME"]); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); this.AppendDetailViewFields(m_sMODULE + ".DetailView", tblMain, rdr); } } } } } } // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
protected void BindGrid() { plcDayRows.Controls.Clear(); try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwACTIVITIES_List " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; DateTime dtDATE_START = new DateTime(Math.Max(1753, dtCurrentDate.Year), dtCurrentDate.Month, dtCurrentDate.Day, 0, 0, 0); DateTime dtDATE_END = dtDATE_START.AddDays(1); // 11/27/2006 Paul. Make sure to filter relationship data based on team access rights. Security.Filter(cmd, "Calls", "list"); // 01/16/2007 Paul. Use AppendParameter so that duplicate ASSIGNED_USER_ID can be avoided. // 01/19/2007 Paul. Fix AppendParamenter. @ should not be used in field name. Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID"); cmd.CommandText += " and ( DATE_START >= @DATE_START and DATE_START < @DATE_END" + ControlChars.CrLf; cmd.CommandText += " or DATE_END >= @DATE_START and DATE_END < @DATE_END" + ControlChars.CrLf; cmd.CommandText += " or DATE_START < @DATE_START and DATE_END > @DATE_END" + ControlChars.CrLf; cmd.CommandText += " ) " + ControlChars.CrLf; cmd.CommandText += " order by DATE_START asc, NAME asc " + ControlChars.CrLf; // 03/19/2007 Paul. Need to query activities based on server time. Sql.AddParameter(cmd, "@DATE_START", T10n.ToServerTime(dtDATE_START)); Sql.AddParameter(cmd, "@DATE_END", T10n.ToServerTime(dtDATE_END)); if (bDebug) { RegisterClientScriptBlock("vwACTIVITIES_List", Sql.ClientScriptBlock(cmd)); } try { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); // 07/24/2005 Paul. Since this is not a dynamic grid, we must convert the status manually. foreach (DataRow row in dt.Rows) { switch (Sql.ToString(row["ACTIVITY_TYPE"])) { case "Calls": row["STATUS"] = L10n.Term("Call") + " " + L10n.Term(".call_status_dom.", row["STATUS"]); break; case "Meetings": row["STATUS"] = L10n.Term("Meeting") + " " + L10n.Term(".meeting_status_dom.", row["STATUS"]); break; } } int nHourMin = 8; int nHourMax = 18; if (dt.Rows.Count > 0) { DateTime dtMin = Sql.ToDateTime(dt.Rows[0]["DATE_START"]); DateTime dtMax = Sql.ToDateTime(dt.Rows[dt.Rows.Count - 1]["DATE_END"]); nHourMin = Math.Min(dtMin.Hour, nHourMin); nHourMax = Math.Max(dtMax.Hour, nHourMax); } CultureInfo ciEnglish = CultureInfo.CreateSpecificCulture("en-US"); for (int iHour = nHourMin; iHour <= nHourMax; iHour++) { DataView vwMain = new DataView(dt); DateTime dtHOUR_START = new DateTime(dtCurrentDate.Year, dtCurrentDate.Month, dtCurrentDate.Day, iHour, 0, 0); DateTime dtHOUR_END = dtHOUR_START.AddHours(1); DateTime dtHOUR_START_ServerTime = T10n.ToServerTime(dtHOUR_START); DateTime dtHOUR_END_ServerTime = T10n.ToServerTime(dtHOUR_END); // 09/27/2005 Paul. System.Data.DataColumn.Expression documentation has description how to define dates and strings. // 01/21/2006 Paul. Brazilian culture is having a problem with date formats. Try using the european format yyyy/MM/dd HH:mm:ss. // 06/09/2006 Paul. Fix so that a 1 hour meeting does not span two hours. DATE_END should not allow DATE_END = HOUR_START. // 06/13/2006 Paul. Italian has a problem with the time separator. Use the value from the culture from CalendarControl.SqlDateTimeFormat. // 06/14/2006 Paul. The Italian problem was that it was using the culture separator, but DataView only supports the en-US format. string sHOUR_START_ServerTime = dtHOUR_START_ServerTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat); string sHOUR_END_ServerTime = dtHOUR_END_ServerTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat); vwMain.RowFilter = " DATE_START >= #" + sHOUR_START_ServerTime + "# and DATE_START < #" + sHOUR_END_ServerTime + "#" + ControlChars.CrLf + "or DATE_END > #" + sHOUR_START_ServerTime + "# and DATE_END <= #" + sHOUR_END_ServerTime + "#" + ControlChars.CrLf + "or DATE_START < #" + sHOUR_START_ServerTime + "# and DATE_END > #" + sHOUR_END_ServerTime + "#" + ControlChars.CrLf; #if DEBUG // RegisterClientScriptBlock("vwACTIVITIES_List" + dtHOUR_START.ToOADate().ToString(), Sql.EscapeJavaScript(vwMain.RowFilter)); #endif DayRow ctlDayRow = LoadControl("DayRow.ascx") as DayRow; // 06/09/2006 Paul. Add to controls list before bindging. plcDayRows.Controls.Add(ctlDayRow); ctlDayRow.Command = new CommandEventHandler(Page_Command); ctlDayRow.DATE_START = dtHOUR_START; //ctlDayRow.DATE_END = dtHOUR_END; ctlDayRow.DataSource = vwMain; // 06/09/2006 Paul. Need to bind after specifying the data source. ctlDayRow.DataBind(); //ctlDayRow.DATE_START = new DateTime(dtCurrentDate.Year, dtCurrentDate.Month, dtCurrentDate.Day, iHour, 0, 0); //ctlDayRow.DATE_END = ctlDayRow.DATE_START.AddHours(1); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } }
protected void Page_Command(object sender, CommandEventArgs e) { try { switch (e.CommandName) { case "Day.Previous": { dtCurrentDate = dtCurrentDate.AddDays(-1); ViewState["CurrentDate"] = dtCurrentDate; // 06/15/2006 Paul. There seems to be a conflict with binding the DayGrid inside InitializeComponent(). // Binding early is required to enable the button events, but the ViewState is not available, so the query is invalid. Response.Redirect("default.aspx?" + CalendarQueryString(dtCurrentDate)); break; } case "Day.Next": { dtCurrentDate = dtCurrentDate.AddDays(1); ViewState["CurrentDate"] = dtCurrentDate; // 06/15/2006 Paul. There seems to be a conflict with binding the DayGrid inside InitializeComponent(). // Binding early is required to enable the button events, but the ViewState is not available, so the query is invalid. Response.Redirect("default.aspx?" + CalendarQueryString(dtCurrentDate)); break; } case "Day.Current": { ViewState["CurrentDate"] = dtCurrentDate; // 06/15/2006 Paul. There seems to be a conflict with binding the DayGrid inside InitializeComponent(). // Binding early is required to enable the button events, but the ViewState is not available, so the query is invalid. Response.Redirect("default.aspx?" + CalendarQueryString(dtCurrentDate)); break; } case "Week.Current": { Response.Redirect("Week.aspx?" + CalendarQueryString(dtCurrentDate)); break; } case "Month.Current": { Response.Redirect("Month.aspx?" + CalendarQueryString(dtCurrentDate)); break; } case "Year.Current": { Response.Redirect("Year.aspx?" + CalendarQueryString(dtCurrentDate)); break; } case "Shared.Current": { Response.Redirect("Shared.aspx?" + CalendarQueryString(dtCurrentDate)); break; } case "Save": { Response.Redirect("default.aspx?" + CalendarQueryString(dtCurrentDate)); break; } } BindGrid(); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { gID = Sql.ToGuid(Request["ID"]); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwORDERS_ACTIVITIES" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 11/27/2006 Paul. Make sure to filter relationship data based on team access rights. // 12/07/2006 Paul. This view has an alternate assigned id. Security.Filter(cmd, m_sMODULE, "list", "ACTIVITY_ASSIGNED_USER_ID"); cmd.CommandText += " and ORDER_ID = @ORDER_ID " + ControlChars.CrLf; cmd.CommandText += " order by DATE_DUE desc " + ControlChars.CrLf; Sql.AddParameter(cmd, "@ORDER_ID", gID); if (bDebug) { RegisterClientScriptBlock("vwORDERS_ACTIVITIES", Sql.ClientScriptBlock(cmd)); } try { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); // 11/26/2005 Paul. Convert the term here so that sorting will apply. foreach (DataRow row in dt.Rows) { // 11/26/2005 Paul. Status is translated differently for each type. switch (Sql.ToString(row["ACTIVITY_TYPE"])) { // 07/15/2006 Paul. Translation of Call status remains here because it is more complex than the standard list translation. case "Calls": row["STATUS"] = L10n.Term(".call_direction_dom.", row["DIRECTION"]) + " " + L10n.Term(".call_status_dom.", row["STATUS"]); break; //case "Meetings": row["STATUS"] = L10n.Term("Meeting") + " " + L10n.Term(".meeting_status_dom.", row["STATUS"]); break; //case "Tasks" : row["STATUS"] = L10n.Term("Task" ) + " " + L10n.Term(".task_status_dom." , row["STATUS"]); break; } } vwOpen = new DataView(dt); vwOpen.RowFilter = "IS_OPEN = 1"; grdOpen.DataSource = vwOpen; vwHistory = new DataView(dt); vwHistory.RowFilter = "IS_OPEN = 0"; grdHistory.DataSource = vwHistory; // 09/05/2005 Paul. LinkButton controls will not fire an event unless the the grid is bound. //if ( !IsPostBack ) { grdOpen.SortColumn = "DATE_DUE"; grdOpen.SortOrder = "desc"; grdOpen.ApplySort(); grdOpen.DataBind(); grdHistory.SortColumn = "DATE_MODIFIED"; grdHistory.SortOrder = "desc"; grdHistory.ApplySort(); grdHistory.DataBind(); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } } } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term(m_sMODULE + ".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.GetUserAccess(m_sMODULE, "list") >= 0); if (!this.Visible) { return; } try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwEMAIL_MARKETING_List" + ControlChars.CrLf + " where 1 = 1 " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 12/29/2007 Paul. EMAIL_MARKETING does not have a TEAM_ID or a USER_ASSIGNED_ID, so we cannot use Security.Filter(). ctlSearchView.SqlSearchClause(cmd); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); vwMain = dt.DefaultView; grdMain.DataSource = vwMain; if (!IsPostBack) { // 12/14/2007 Paul. Only set the default sort if it is not already set. It may have been set by SearchView. if (String.IsNullOrEmpty(grdMain.SortColumn)) { grdMain.SortColumn = "DATE_START"; grdMain.SortOrder = "desc"; } grdMain.ApplySort(); grdMain.DataBind(); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
private void Bind() { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; // 04/04/2006 Paul. Start with today in ZoneTime and not ServerTime. DateTime dtZONE_NOW = T10n.FromUniversalTime(DateTime.Now.ToUniversalTime()); DateTime dtZONE_TODAY = new DateTime(dtZONE_NOW.Year, dtZONE_NOW.Month, dtZONE_NOW.Day); DateTime dtDATE_START = dtZONE_TODAY; switch (lstTHROUGH.SelectedValue) { case "today": dtDATE_START = dtZONE_TODAY; break; case "tomorrow": dtDATE_START = dtDATE_START.AddDays(1); break; case "this Saturday": dtDATE_START = dtDATE_START.AddDays(DayOfWeek.Saturday - dtDATE_START.DayOfWeek); break; case "next Saturday": dtDATE_START = dtDATE_START.AddDays(DayOfWeek.Saturday - dtDATE_START.DayOfWeek).AddDays(7); break; case "last this_month": dtDATE_START = new DateTime(dtZONE_TODAY.Year, dtZONE_TODAY.Month, DateTime.DaysInMonth(dtZONE_TODAY.Year, dtZONE_TODAY.Month)); break; case "last next_month": dtDATE_START = new DateTime(dtZONE_TODAY.Year, dtZONE_TODAY.Month, DateTime.DaysInMonth(dtZONE_TODAY.Year, dtZONE_TODAY.Month)).AddMonths(1); break; } // 04/04/2006 Paul. Now that we are using ZoneTime, we don't need to convert it to server time when displaying the date. txtTHROUGH.Text = "(" + Sql.ToDateString(dtDATE_START) + ")"; sSQL = "select * " + ControlChars.CrLf + " from vwACTIVITIES_MyList " + ControlChars.CrLf + " where ASSIGNED_USER_ID = @ASSIGNED_USER_ID" + ControlChars.CrLf + " and DATE_START < @DATE_START " + ControlChars.CrLf + " order by DATE_START asc " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ASSIGNED_USER_ID", Security.USER_ID); // 04/04/2006 Paul. DATE_START is not including all records for today. // 04/04/2006 Paul. Instead of using DATE_START <= @DATE_START, change to DATE_START < @DATE_START and increase the start date to tomorrow. // 04/04/2006 Paul. Here we do need to convert it to ServerTime because that is all that the database understands. Sql.AddParameter(cmd, "@DATE_START", T10n.ToServerTime(dtDATE_START.AddDays(1))); #if DEBUG Page.RegisterClientScriptBlock("vwACTIVITIES_MyList", Sql.ClientScriptBlock(cmd)); #endif try { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); vwMain = dt.DefaultView; grdMain.DataSource = vwMain; if (!IsPostBack) { //grdMain.SortColumn = "DATE_START"; //grdMain.SortOrder = "desc" ; } // 09/15/2005 Paul. We must always bind, otherwise a Dashboard refresh will display the grid with empty rows. grdMain.DataBind(); } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } } } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term(m_sMODULE + ".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.GetUserAccess(m_sMODULE, "list") >= 0); if (!this.Visible) { return; } nACLACCESS_Export = Security.GetUserAccess(m_sMODULE, "export"); try { sMODULE_NAME = Sql.ToString(Request["MODULE_NAME"]); ctlListHeaderMySaved.Title = ".saved_reports_dom." + sMODULE_NAME; ctlListHeaderPublished.Title = ".published_reports_dom." + sMODULE_NAME; DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwREPORTS_List" + ControlChars.CrLf + " where 1 = 1 " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AppendParameter(cmd, sMODULE_NAME, "MODULE_NAME"); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); // 06/18/2006 Paul. Translate the report type. foreach (DataRow row in dt.Rows) { row["REPORT_TYPE"] = L10n.Term(".dom_report_types.", row["REPORT_TYPE"]); } vwMySaved = new DataView(dt); vwMySaved.RowFilter = "PUBLISHED = 0 and ASSIGNED_USER_ID = '" + Security.USER_ID.ToString() + "'"; grdMySaved.DataSource = vwMySaved; if (!IsPostBack) { grdMySaved.SortColumn = "NAME"; grdMySaved.SortOrder = "asc"; grdMySaved.ApplySort(); grdMySaved.DataBind(); } vwPublished = new DataView(dt); // 05/18/2006 Paul. Lets include unassigned so that they don't get lost. vwPublished.RowFilter = "PUBLISHED = 1 or ASSIGNED_USER_ID is null"; grdPublished.DataSource = vwPublished; if (!IsPostBack) { grdPublished.SortColumn = "NAME"; grdPublished.SortOrder = "asc"; grdPublished.ApplySort(); grdPublished.DataBind(); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
public void BuildSchedule() { try { dtSCHEDULE_START = new DateTime(dtDATE_START.Year, dtDATE_START.Month, dtDATE_START.Day, dtDATE_START.Hour, 0, 0, 0); // 01/16/2006 Paul. Date may not allow adding hours. It may already be at the minimum. Just ignore the error. dtSCHEDULE_START = dtSCHEDULE_START.AddHours(-4); dtSCHEDULE_END = dtSCHEDULE_START.AddHours(9); } catch { return; } try { tblSchedule.Rows.Clear(); HtmlTableRow rowHeader = new HtmlTableRow(); tblSchedule.Rows.Add(rowHeader); HtmlTableCell cellHeader = new HtmlTableCell(); rowHeader.Cells.Add(cellHeader); rowHeader.Attributes.Add("class", "schedulerTopRow"); cellHeader.Attributes.Add("class", "schedulerTopDateCell"); cellHeader.Align = "middle"; cellHeader.Height = "20"; cellHeader.ColSpan = (dtSCHEDULE_END - dtSCHEDULE_START).Hours * 4 + 2; // 38; cellHeader.InnerText = dtDATE_START.ToLongDateString(); HtmlTableRow rowTime = new HtmlTableRow(); tblSchedule.Rows.Add(rowTime); HtmlTableCell cellTime = new HtmlTableCell(); cellTime.Attributes.Add("class", "schedulerAttendeeHeaderCell"); rowTime.Cells.Add(cellTime); for (DateTime dtHOUR_START = dtSCHEDULE_START; dtHOUR_START < dtSCHEDULE_END; dtHOUR_START = dtHOUR_START.AddHours(1)) { cellTime = new HtmlTableCell(); cellTime.Attributes.Add("class", "schedulerTimeCell"); cellTime.ColSpan = 4; cellTime.InnerText = dtHOUR_START.ToShortTimeString(); rowTime.Cells.Add(cellTime); } cellTime = new HtmlTableCell(); cellTime.Attributes.Add("class", "schedulerDeleteHeaderCell"); rowTime.Cells.Add(cellTime); if (arrINVITEES != null) { foreach (string sINVITEE_ID in arrINVITEES) { Guid gINVITEE_ID = Guid.Empty; try { gINVITEE_ID = Sql.ToGuid(sINVITEE_ID); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); } if (!Sql.IsEmptyGuid(gINVITEE_ID)) { AddInvitee(gINVITEE_ID); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE)); // 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.GetUserAccess(m_sMODULE, "edit") >= 0); if (!this.Visible) { return; } try { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); gID = Sql.ToGuid(Request["ID"]); if (!IsPostBack) { CURRENCY_ID.DataSource = SplendidCache.Currencies(); CURRENCY_ID.DataBind(); TAXRATE_ID.DataSource = SplendidCache.TaxRates(); TAXRATE_ID.DataBind(); TAXRATE_ID.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), "")); SHIPPER_ID.DataSource = SplendidCache.Shippers(); SHIPPER_ID.DataBind(); SHIPPER_ID.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), "")); Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwQUOTES_Edit" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; if (!Sql.IsEmptyGuid(gDuplicateID)) { Sql.AddParameter(cmd, "@ID", gDuplicateID); gID = Guid.Empty; } else { Sql.AddParameter(cmd, "@ID", gID); } con.Open(); #if DEBUG Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); #endif using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = Sql.ToString(rdr["NAME"]); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; ViewState["BILLING_ACCOUNT_ID"] = Sql.ToGuid(rdr["BILLING_ACCOUNT_ID"]); ViewState["SHIPPING_ACCOUNT_ID"] = Sql.ToGuid(rdr["SHIPPING_ACCOUNT_ID"]); this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); this.AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, rdr); this.AppendEditViewFields(m_sMODULE + ".EditDescription", tblDescription, rdr); new DynamicControl(this, "SHOW_LINE_NUMS").Checked = Sql.ToBoolean(rdr["SHOW_LINE_NUMS"]); new DynamicControl(this, "CALC_GRAND_TOTAL").Checked = Sql.ToBoolean(rdr["CALC_GRAND_TOTAL"]); try { new DynamicControl(this, "CURRENCY_ID").SelectedValue = Sql.ToString(rdr["CURRENCY_ID"]); } catch { } try { new DynamicControl(this, "TAXRATE_ID").SelectedValue = Sql.ToString(rdr["TAXRATE_ID"]); } catch { } try { new DynamicControl(this, "SHIPPER_ID").SelectedValue = Sql.ToString(rdr["SHIPPER_ID"]); } catch { } } } } } } else { this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); this.AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, null); this.AppendEditViewFields(m_sMODULE + ".EditDescription", tblDescription, null); // 06/08/2006 Paul. Prepopulate the Account. Guid gPARENT_ID = Sql.ToGuid(Request["PARENT_ID"]); if (!Sql.IsEmptyGuid(gPARENT_ID)) { string sMODULE = String.Empty; string sPARENT_TYPE = String.Empty; string sPARENT_NAME = String.Empty; SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME); if (!Sql.IsEmptyGuid(gPARENT_ID) && sMODULE == "Accounts") { UpdateAccount(gPARENT_ID, true, true); } if (!Sql.IsEmptyGuid(gPARENT_ID) && sMODULE == "Contacts") { UpdateContact(gPARENT_ID, true, true); } else if (!Sql.IsEmptyGuid(gPARENT_ID) && sMODULE == "Opportunities") { new DynamicControl(this, "OPPORTUNITY_ID").ID = gPARENT_ID; new DynamicControl(this, "OPPORTUNITY_NAME").Text = sPARENT_NAME; } } } } else { // 12/02/2005 Paul. When validation fails, the header title does not retain its value. Update manually. ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); DynamicControl ctlBILLING_ACCOUNT_ID = new DynamicControl(this, "BILLING_ACCOUNT_ID"); DynamicControl ctlSHIPPING_ACCOUNT_ID = new DynamicControl(this, "SHIPPING_ACCOUNT_ID"); if (Sql.ToGuid(ViewState["BILLING_ACCOUNT_ID"]) != ctlBILLING_ACCOUNT_ID.ID) { UpdateAccount(ctlBILLING_ACCOUNT_ID.ID, true, true); ViewState["BILLING_ACCOUNT_ID"] = ctlBILLING_ACCOUNT_ID.ID; ViewState["SHIPPING_ACCOUNT_ID"] = ctlBILLING_ACCOUNT_ID.ID; } if (Sql.ToGuid(ViewState["SHIPPING_ACCOUNT_ID"]) != ctlSHIPPING_ACCOUNT_ID.ID) { UpdateAccount(ctlSHIPPING_ACCOUNT_ID.ID, false, true); ViewState["SHIPPING_ACCOUNT_ID"] = ctlSHIPPING_ACCOUNT_ID.ID; } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlEditButtons.ErrorText = ex.Message; } }
private void AddInvitee(Guid gUSER_ID) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); string sSQL; string sFULL_NAME = String.Empty; string sINVITEE_TYPE = String.Empty; sSQL = "select * " + ControlChars.CrLf + " from vwINVITEES" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gUSER_ID); #if DEBUG Page.RegisterClientScriptBlock("vwINVITEES", Sql.ClientScriptBlock(cmd)); #endif using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { sFULL_NAME = Sql.ToString(rdr["FULL_NAME"]); sINVITEE_TYPE = Sql.ToString(rdr["INVITEE_TYPE"]); } } } sSQL = "select * " + ControlChars.CrLf + " from vwACTIVITIES_List " + ControlChars.CrLf + " where ASSIGNED_USER_ID = @ASSIGNED_USER_ID " + ControlChars.CrLf + " and ( DATE_START >= @DATE_START and DATE_START < @DATE_END" + ControlChars.CrLf + " or DATE_END >= @DATE_START and DATE_END < @DATE_END" + ControlChars.CrLf + " or DATE_START < @DATE_START and DATE_END > @DATE_END" + ControlChars.CrLf + " ) " + ControlChars.CrLf + " order by DATE_START asc, NAME asc " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ASSIGNED_USER_ID", gUSER_ID); Sql.AddParameter(cmd, "@DATE_START", T10n.ToServerTime(dtSCHEDULE_START)); Sql.AddParameter(cmd, "@DATE_END", T10n.ToServerTime(dtSCHEDULE_END)); #if DEBUG Page.RegisterClientScriptBlock("vwACTIVITIES_List", Sql.ClientScriptBlock(cmd)); #endif try { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); HtmlTableRow rowInvitee = new HtmlTableRow(); tblSchedule.Rows.Add(rowInvitee); rowInvitee.Attributes.Add("class", "schedulerAttendeeRow"); HtmlTableCell cellInvitee = new HtmlTableCell(); rowInvitee.Cells.Add(cellInvitee); cellInvitee.Attributes.Add("class", "schedulerAttendeeCell"); Literal litFULL_NAME = new Literal(); Image imgInvitee = new Image(); cellInvitee.Controls.Add(imgInvitee); cellInvitee.Controls.Add(litFULL_NAME); imgInvitee.Width = 16; imgInvitee.Height = 16; imgInvitee.ImageAlign = ImageAlign.AbsMiddle; imgInvitee.ImageUrl = Session["themeURL"] + "images/" + sINVITEE_TYPE + ".gif"; litFULL_NAME.Text = sFULL_NAME; if (dt.Rows.Count > 0) { DataView vwMain = new DataView(dt); CultureInfo ciEnglish = CultureInfo.CreateSpecificCulture("en-US"); for (DateTime dtHOUR_START = dtSCHEDULE_START; dtHOUR_START < dtSCHEDULE_END; dtHOUR_START = dtHOUR_START.AddMinutes(15)) { DateTime dtHOUR_END = dtHOUR_START.AddMinutes(15); DateTime dtHOUR_START_ServerTime = T10n.ToServerTime(dtHOUR_START); DateTime dtHOUR_END_ServerTime = T10n.ToServerTime(dtHOUR_END); // 09/27/2005 Paul. System.Data.DataColumn.Expression documentation has description how to define dates and strings. // 08/08/2006 Paul. Use the same ServerTime logic as DayGrid.ascx.cs to solve date formatting issues on international systems. string sHOUR_START_ServerTime = dtHOUR_START_ServerTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat); string sHOUR_END_ServerTime = dtHOUR_END_ServerTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat); vwMain.RowFilter = " DATE_START >= #" + sHOUR_START_ServerTime + "# and DATE_START < #" + sHOUR_END_ServerTime + "#" + ControlChars.CrLf + "or DATE_END > #" + sHOUR_START_ServerTime + "# and DATE_END <= #" + sHOUR_END_ServerTime + "#" + ControlChars.CrLf + "or DATE_START < #" + sHOUR_START_ServerTime + "# and DATE_END > #" + sHOUR_END_ServerTime + "#" + ControlChars.CrLf; #if DEBUG // Page.RegisterClientScriptBlock("vwACTIVITIES_List" + dtHOUR_START.ToOADate().ToString(), Sql.EscapeJavaScript(vwMain.RowFilter)); #endif cellInvitee = new HtmlTableCell(); rowInvitee.Cells.Add(cellInvitee); if (dtHOUR_START == dtDATE_END) { cellInvitee.Attributes.Add("class", "schedulerSlotCellEndTime"); } else if (dtHOUR_START == dtDATE_START) { cellInvitee.Attributes.Add("class", "schedulerSlotCellStartTime"); } else { cellInvitee.Attributes.Add("class", "schedulerSlotCellHour"); } if (vwMain.Count > 0) { if (dtHOUR_START >= dtDATE_START && dtHOUR_START < dtDATE_END) { cellInvitee.Attributes.Add("style", "BACKGROUND-COLOR: #aa4d4d"); } else { cellInvitee.Attributes.Add("style", "BACKGROUND-COLOR: #4d5eaa"); } } else { if (dtHOUR_START >= dtDATE_START && dtHOUR_START < dtDATE_END) { cellInvitee.Attributes.Add("style", "BACKGROUND-COLOR: #ffffff"); } } } } else { for (DateTime dtHOUR_START = dtSCHEDULE_START; dtHOUR_START < dtSCHEDULE_END; dtHOUR_START = dtHOUR_START.AddMinutes(15)) { DateTime dtHOUR_END = dtHOUR_START.AddMinutes(15); cellInvitee = new HtmlTableCell(); rowInvitee.Cells.Add(cellInvitee); if (dtHOUR_START == dtDATE_END) { cellInvitee.Attributes.Add("class", "schedulerSlotCellEndTime"); } else if (dtHOUR_START == dtDATE_START) { cellInvitee.Attributes.Add("class", "schedulerSlotCellStartTime"); } else { cellInvitee.Attributes.Add("class", "schedulerSlotCellHour"); } if (dtHOUR_START >= dtDATE_START && dtHOUR_START < dtDATE_END) { cellInvitee.Attributes.Add("style", "BACKGROUND-COLOR: #ffffff"); } } } cellInvitee = new HtmlTableCell(); rowInvitee.Cells.Add(cellInvitee); cellInvitee.Attributes.Add("class", "schedulerAttendeeDeleteCell"); ImageButton btnDelete = new ImageButton(); Literal litSpace = new Literal(); LinkButton lnkDelete = new LinkButton(); btnDelete.CommandName = "Invitees.Delete"; lnkDelete.CommandName = "Invitees.Delete"; btnDelete.CommandArgument = gUSER_ID.ToString(); lnkDelete.CommandArgument = gUSER_ID.ToString(); btnDelete.Command += new CommandEventHandler(this.Page_Command); lnkDelete.Command += new CommandEventHandler(this.Page_Command); btnDelete.CssClass = "listViewTdToolsS1"; lnkDelete.CssClass = "listViewTdToolsS1"; Guid gID = Sql.ToGuid(Request["ID"]); if (Sql.IsEmptyGuid(gID)) { btnDelete.AlternateText = L10n.Term(".LNK_REMOVE"); lnkDelete.Text = L10n.Term(".LNK_REMOVE"); } else { btnDelete.AlternateText = L10n.Term(".LNK_DELETE"); lnkDelete.Text = L10n.Term(".LNK_DELETE"); } litSpace.Text = " "; btnDelete.ImageUrl = Session["themeURL"] + "images/delete_inline.gif"; btnDelete.BorderWidth = 0; btnDelete.Width = 12; btnDelete.Height = 12; btnDelete.ImageAlign = ImageAlign.AbsMiddle; cellInvitee.Controls.Add(btnDelete); cellInvitee.Controls.Add(litSpace); cellInvitee.Controls.Add(lnkDelete); } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } } } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term("Terminology.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 { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwTERMINOLOGY_List" + ControlChars.CrLf + " where 1 = 1 " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 01/12/2006 Paul. ctlSearch.LANGUAGE is not working. if (!IsPostBack) { Sql.AppendParameter(cmd, L10N.NormalizeCulture(L10n.NAME), 10, Sql.SqlFilterMode.Exact, "LANG"); //ctlSearch.LANGUAGE = L10n.NAME; } else { ctlSearch.SqlSearchClause(cmd); } if (ctlSearch.GLOBAL_TERMS) { cmd.CommandText += " and MODULE_NAME is null" + ControlChars.CrLf; } if (!ctlSearch.INCLUDE_LISTS) { cmd.CommandText += " and LIST_NAME is null" + ControlChars.CrLf; } if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); vwMain = dt.DefaultView; grdMain.DataSource = vwMain; if (!IsPostBack) { // 12/14/2007 Paul. Only set the default sort if it is not already set. It may have been set by SearchView. if (String.IsNullOrEmpty(grdMain.SortColumn)) { grdMain.SortColumn = "NAME"; grdMain.SortOrder = "asc"; } grdMain.ApplySort(); grdMain.DataBind(); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
private void Page_Load(object sender, System.EventArgs e) { try { gID = Sql.ToGuid(Request["ID"]); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE)); if (!IsPostBack) { lblDATEFORMAT.Text = "(" + Session["USER_SETTINGS/DATEFORMAT"] + ")"; lstOPPORTUNITY_SALES_STAGE.DataSource = SplendidCache.List("sales_stage_dom"); lstOPPORTUNITY_SALES_STAGE.DataBind(); chkCreateAccount.Attributes.Add("onclick", "return ToggleCreateAccount();"); chkCreateOpportunity.Attributes.Add("onclick", "return toggleDisplay('divCreateOpportunity');"); chkCreateAppointment.Attributes.Add("onclick", "return toggleDisplay('divCreateAppointment');"); Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwLEADS_Convert" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; if (!Sql.IsEmptyGuid(gDuplicateID)) { Sql.AddParameter(cmd, "@ID", gDuplicateID); gID = Guid.Empty; } else { Sql.AddParameter(cmd, "@ID", gID); } con.Open(); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = L10n.Term("Leads.LBL_CONVERTLEAD"); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); txtACCOUNT_NAME.Text = Sql.ToString(rdr["ACCOUNT_NAME"]); txtACCOUNT_PHONE_WORK.Text = Sql.ToString(rdr["PHONE_WORK"]); // 01/31/2006 Paul. Default start date and time is now. ctlAPPOINTMENT_DATE_START.Value = T10n.FromServerTime(DateTime.Now); txtAPPOINTMENT_TIME_START.Text = T10n.FromServerTime(DateTime.Now).ToShortTimeString(); this.AppendEditViewFields(m_sMODULE + ".ConvertView", tblMain, rdr); // 01/31/2006 Paul. Save all data to be used later. for (int i = 0; i < rdr.FieldCount; i++) { ViewState[rdr.GetName(i)] = rdr.GetValue(i); } } } } } } else { this.AppendEditViewFields(m_sMODULE + ".ConvertView", tblMain, null); } } else { // 12/02/2005 Paul. When validation fails, the header title does not retain its value. Update manually. ctlModuleHeader.Title = L10n.Term("Leads.LBL_CONVERTLEAD"); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = ex.Message; } }
protected void Page_Command(Object sender, CommandEventArgs e) { // 08/21/2005 Paul. Redirect to parent if that is where the note was originated. Guid gPARENT_ID = Sql.ToGuid(Request["PARENT_ID"]); Guid gCONTACT_ID = Sql.ToGuid(Request["CONTACT_ID"]); string sMODULE = String.Empty; string sPARENT_TYPE = String.Empty; string sPARENT_NAME = String.Empty; try { SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); // The only possible error is a connection failure, so just ignore all errors. gPARENT_ID = Guid.Empty; } if (e.CommandName == "Save") { // 01/16/2006 Paul. Enable validator before validating page. SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this); if (Page.IsValid) { string sCUSTOM_MODULE = "TASKS"; DataTable dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbTransaction trn = con.BeginTransaction()) { try { SqlProcs.spTASKS_Update (ref gID , new DynamicControl(this, "ASSIGNED_USER_ID").ID , new DynamicControl(this, "NAME").Text , new DynamicControl(this, "STATUS").SelectedValue , new DynamicControl(this, "DATE_DUE").DateValue , new DynamicControl(this, "DATE_START").DateValue , new DynamicControl(this, "PARENT_TYPE").SelectedValue , new DynamicControl(this, "PARENT_ID").ID , new DynamicControl(this, "CONTACT_ID").ID , new DynamicControl(this, "PRIORITY").SelectedValue , new DynamicControl(this, "DESCRIPTION").Text , trn ); SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields); trn.Commit(); } catch (Exception ex) { trn.Rollback(); SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlEditButtons.ErrorText = ex.Message; return; } } } if (!Sql.IsEmptyGuid(gPARENT_ID)) { Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString()); } else if (!Sql.IsEmptyGuid(gCONTACT_ID)) { Response.Redirect("~/Contacts/view.aspx?ID=" + gCONTACT_ID.ToString()); } else { Response.Redirect("view.aspx?ID=" + gID.ToString()); } } } else if (e.CommandName == "Cancel") { if (!Sql.IsEmptyGuid(gPARENT_ID)) { Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString()); } else if (!Sql.IsEmptyGuid(gCONTACT_ID)) { Response.Redirect("~/Contacts/view.aspx?ID=" + gCONTACT_ID.ToString()); } else if (Sql.IsEmptyGuid(gID)) { Response.Redirect("default.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID.ToString()); } } }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "Save") { // 01/31/2006 Paul. Enable validator before validating page. this.ValidateEditViewFields(m_sMODULE + ".ConvertView"); if (Page.IsValid) { // 02/27/2006 Paul. Fix condition on notes. Enable only if text exists. txtCONTACT_NOTES_NAME_DESCRIPTION.Text = txtCONTACT_NOTES_NAME_DESCRIPTION.Text.Trim(); reqCONTACT_NOTES_NAME.Enabled = !Sql.IsEmptyString(txtCONTACT_NOTES_NAME_DESCRIPTION.Text); reqCONTACT_NOTES_NAME.Validate(); txtACCOUNT_NOTES_NAME_DESCRIPTION.Text = txtACCOUNT_NOTES_NAME_DESCRIPTION.Text.Trim(); reqACCOUNT_NOTES_NAME.Enabled = !Sql.IsEmptyString(txtACCOUNT_NOTES_NAME_DESCRIPTION.Text); reqACCOUNT_NOTES_NAME.Validate(); txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text = txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text.Trim(); reqOPPORTUNITY_NOTES_NAME.Enabled = !Sql.IsEmptyString(txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text); reqOPPORTUNITY_NOTES_NAME.Validate(); // 01/31/2006 Paul. SelectAccount is required if not creating an account but creating an opportunity. reqSELECT_ACCOUNT_ID.Enabled = !chkCreateAccount.Checked && chkCreateOpportunity.Checked; reqSELECT_ACCOUNT_ID.Validate(); reqACCOUNT_NAME.Enabled = chkCreateAccount.Checked; reqACCOUNT_NAME.Validate(); reqOPPORTUNITY_NAME.Enabled = chkCreateOpportunity.Checked; reqOPPORTUNITY_NAME.Validate(); reqOPPORTUNITY_AMOUNT.Enabled = chkCreateOpportunity.Checked; reqOPPORTUNITY_AMOUNT.Validate(); reqAPPOINTMENT_NAME.Enabled = chkCreateAppointment.Checked; reqAPPOINTMENT_NAME.Validate(); reqAPPOINTMENT_TIME_START.Enabled = chkCreateAppointment.Checked; reqAPPOINTMENT_TIME_START.Validate(); if (chkCreateAppointment.Checked) { ctlAPPOINTMENT_DATE_START.Validate(); } } if (Page.IsValid) { string sCUSTOM_MODULE = "LEADS"; DataTable dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbTransaction trn = con.BeginTransaction()) { try { Guid gCONTACT_ID = Guid.Empty; Guid gACCOUNT_ID = Guid.Empty; Guid gOPPORTUNITY_ID = Guid.Empty; Guid gAPPOINTMENT_ID = Guid.Empty; // 01/31/2006 Paul. Create the contact first so that it can be used as the parent of the related records. // We would normally create the related records second, but then it will become a pain to update the Contact ACCOUNT_ID field. SqlProcs.spCONTACTS_New (ref gCONTACT_ID , new DynamicControl(this, "FIRST_NAME").Text , new DynamicControl(this, "LAST_NAME").Text , new DynamicControl(this, "PHONE_WORK").Text , new DynamicControl(this, "EMAIL1").Text , trn ); if (chkCreateAccount.Checked) { SqlProcs.spACCOUNTS_Update (ref gACCOUNT_ID , Security.USER_ID , txtACCOUNT_NAME.Text , String.Empty , Guid.Empty , String.Empty , String.Empty , Sql.ToString(ViewState["PHONE_FAX"]) , Sql.ToString(ViewState["BILLING_ADDRESS_STREET"]) , Sql.ToString(ViewState["BILLING_ADDRESS_CITY"]) , Sql.ToString(ViewState["BILLING_ADDRESS_STATE"]) , Sql.ToString(ViewState["BILLING_ADDRESS_POSTALCODE"]) , Sql.ToString(ViewState["BILLING_ADDRESS_COUNTRY"]) , txtACCOUNT_DESCRIPTION.Text , String.Empty , txtACCOUNT_PHONE_WORK.Text , Sql.ToString(ViewState["PHONE_OTHER"]) , Sql.ToString(ViewState["EMAIL1"]) , Sql.ToString(ViewState["EMAIL2"]) , txtACCOUNT_WEBSITE.Text , String.Empty , String.Empty , String.Empty , String.Empty , Sql.ToString(ViewState["SHIPPING_ADDRESS_STREET"]) , Sql.ToString(ViewState["SHIPPING_ADDRESS_CITY"]) , Sql.ToString(ViewState["SHIPPING_ADDRESS_STATE"]) , Sql.ToString(ViewState["SHIPPING_ADDRESS_POSTALCODE"]) , Sql.ToString(ViewState["SHIPPING_ADDRESS_COUNTRY"]) , new DynamicControl(this, "TEAM_ID").ID , trn ); if (!Sql.IsEmptyString(txtACCOUNT_NOTES_NAME.Text)) { Guid gNOTE_ID = Guid.Empty; SqlProcs.spNOTES_Update (ref gNOTE_ID , txtACCOUNT_NOTES_NAME.Text , "Accounts" , gACCOUNT_ID , Guid.Empty , txtACCOUNT_NOTES_NAME_DESCRIPTION.Text , new DynamicControl(this, "TEAM_ID").ID , trn ); } } else { gACCOUNT_ID = Sql.ToGuid(txtSELECT_ACCOUNT_ID.Value); } if (chkCreateOpportunity.Checked) { SqlProcs.spOPPORTUNITIES_Update (ref gOPPORTUNITY_ID , Security.USER_ID , gACCOUNT_ID , txtOPPORTUNITY_NAME.Text , String.Empty , new DynamicControl(this, "LEAD_SOURCE").SelectedValue , Sql.ToDecimal(txtOPPORTUNITY_AMOUNT.Text) , Guid.Empty , T10n.ToServerTime(ctlOPPORTUNITY_DATE_CLOSED.Value) , String.Empty , lstOPPORTUNITY_SALES_STAGE.SelectedValue , (float)0.0 , txtOPPORTUNITY_DESCRIPTION.Text , String.Empty , Guid.Empty , String.Empty // 11/02/2006 Paul. ACCOUNT_NAME is only used for import. , new DynamicControl(this, "TEAM_ID").ID , trn ); if (!Sql.IsEmptyString(txtOPPORTUNITY_NOTES_NAME.Text)) { Guid gNOTE_ID = Guid.Empty; SqlProcs.spNOTES_Update (ref gNOTE_ID , txtOPPORTUNITY_NOTES_NAME.Text , "Opportunities" , gOPPORTUNITY_ID , Guid.Empty , txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text , new DynamicControl(this, "TEAM_ID").ID , trn ); } // 03/04/2006 Paul. Must be included in the transaction, otherwise entire operation will fail with a timeout message. SqlProcs.spOPPORTUNITIES_CONTACTS_Update(gOPPORTUNITY_ID, gCONTACT_ID, String.Empty, trn); } if (chkCreateAppointment.Checked) { DateTime dtDATE_START = T10n.ToServerTime(Sql.ToDateTime(ctlAPPOINTMENT_DATE_START.DateText + " " + txtAPPOINTMENT_TIME_START.Text)); if (radScheduleCall.Checked) { SqlProcs.spCALLS_Update (ref gAPPOINTMENT_ID , Security.USER_ID , txtAPPOINTMENT_NAME.Text , 1 , 0 , dtDATE_START , "Accounts" , Guid.Empty , "Planned" , "Outbound" , -1 , txtAPPOINTMENT_DESCRIPTION.Text , gCONTACT_ID.ToString() // 01/31/2006 Paul. This is were we relate this call to the contact. , new DynamicControl(this, "TEAM_ID").ID , trn ); } else { SqlProcs.spMEETINGS_Update (ref gAPPOINTMENT_ID , Security.USER_ID , txtAPPOINTMENT_NAME.Text , String.Empty , 1 , 0 , dtDATE_START , "Planned" , "Accounts" , Guid.Empty , -1 , txtAPPOINTMENT_DESCRIPTION.Text , gCONTACT_ID.ToString() // 01/31/2006 Paul. This is were we relate this meeting to the contact. , new DynamicControl(this, "TEAM_ID").ID , trn ); } } SqlProcs.spCONTACTS_ConvertLead (ref gCONTACT_ID , gID // 01/31/2006 Paul. Update the Lead with this contact. , Security.USER_ID , new DynamicControl(this, "SALUTATION").SelectedValue , new DynamicControl(this, "FIRST_NAME").Text , new DynamicControl(this, "LAST_NAME").Text , gACCOUNT_ID , new DynamicControl(this, "LEAD_SOURCE").SelectedValue , new DynamicControl(this, "TITLE").Text , new DynamicControl(this, "DEPARTMENT").Text , new DynamicControl(this, "DO_NOT_CALL").Checked , new DynamicControl(this, "PHONE_HOME").Text , new DynamicControl(this, "PHONE_MOBILE").Text , new DynamicControl(this, "PHONE_WORK").Text , new DynamicControl(this, "PHONE_OTHER").Text , new DynamicControl(this, "PHONE_FAX").Text , new DynamicControl(this, "EMAIL1").Text , new DynamicControl(this, "EMAIL2").Text , new DynamicControl(this, "EMAIL_OPT_OUT").Checked , new DynamicControl(this, "INVALID_EMAIL").Checked , new DynamicControl(this, "PRIMARY_ADDRESS_STREET").Text , new DynamicControl(this, "PRIMARY_ADDRESS_CITY").Text , new DynamicControl(this, "PRIMARY_ADDRESS_STATE").Text , new DynamicControl(this, "PRIMARY_ADDRESS_POSTALCODE").Text , new DynamicControl(this, "PRIMARY_ADDRESS_COUNTRY").Text , Sql.ToString(ViewState["ALT_ADDRESS_STREET"]) , Sql.ToString(ViewState["ALT_ADDRESS_CITY"]) , Sql.ToString(ViewState["ALT_ADDRESS_STATE"]) , Sql.ToString(ViewState["ALT_ADDRESS_POSTALCODE"]) , Sql.ToString(ViewState["ALT_ADDRESS_COUNTRY"]) , new DynamicControl(this, "DESCRIPTION").Text , gOPPORTUNITY_ID , txtOPPORTUNITY_NAME.Text , txtOPPORTUNITY_AMOUNT.Text , Sql.ToGuid(ViewState["CAMPAIGN_ID"]) // 09/10/2007 Paul. Add Campaign tracking. , new DynamicControl(this, "TEAM_ID").ID , trn ); if (!Sql.IsEmptyString(txtCONTACT_NOTES_NAME.Text)) { Guid gNOTE_ID = Guid.Empty; SqlProcs.spNOTES_Update (ref gNOTE_ID , txtCONTACT_NOTES_NAME.Text , String.Empty , Guid.Empty , gCONTACT_ID , txtCONTACT_NOTES_NAME_DESCRIPTION.Text , new DynamicControl(this, "TEAM_ID").ID , trn ); } SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields); trn.Commit(); } catch (Exception ex) { trn.Rollback(); SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = ex.Message; return; } } } Response.Redirect("view.aspx?ID=" + gID.ToString()); } } else if (e.CommandName == "Cancel") { if (Sql.IsEmptyGuid(gID)) { Response.Redirect("default.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID.ToString()); } } }
protected void Page_Command(object sender, CommandEventArgs e) { try { if (e.CommandName == "AdvancedSearch") { Response.Redirect("default.aspx?Advanced=1"); } else if (e.CommandName == "BasicSearch") { Response.Redirect("default.aspx?Advanced=0"); } else if (e.CommandName == "Clear") { ctlSearch.ClearForm(); Server.Transfer("default.aspx?Advanced=" + nAdvanced.ToString()); } else if (e.CommandName == "Search") { // 10/13/2005 Paul. Make sure to clear the page index prior to applying search. grdMain.CurrentPageIndex = 0; grdMain.ApplySort(); grdMain.DataBind(); } else if (e.CommandName == "MassUpdate") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { string sIDs = Utils.ValidateIDs(arrID); sIDs = Utils.FilterByACL(m_sMODULE, "edit", arrID, "CONTACTS"); if (!Sql.IsEmptyString(sIDs)) { SqlProcs.spCONTACTS_MassUpdate(sIDs, ctlMassUpdate.ASSIGNED_USER_ID, ctlMassUpdate.ACCOUNT_ID, ctlMassUpdate.LEAD_SOURCE, ctlMassUpdate.REPORTS_TO_ID); Response.Redirect("default.aspx"); } } } else if (e.CommandName == "MassDelete") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { string sIDs = Utils.ValidateIDs(arrID); sIDs = Utils.FilterByACL(m_sMODULE, "delete", arrID, "CONTACTS"); if (!Sql.IsEmptyString(sIDs)) { SqlProcs.spCONTACTS_MassDelete(sIDs); Response.Redirect("default.aspx"); } } } else if (e.CommandName == "Sync") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { string sIDs = Utils.ValidateIDs(arrID); if (!Sql.IsEmptyString(sIDs)) { SqlProcs.spCONTACTS_MassSync(sIDs); Response.Redirect("default.aspx"); } } } else if (e.CommandName == "Unsync") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { string sIDs = Utils.ValidateIDs(arrID); if (!Sql.IsEmptyString(sIDs)) { SqlProcs.spCONTACTS_MassUnsync(sIDs); Response.Redirect("default.aspx"); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { Utils.SetPageTitle(Page, L10n.Term("Manufacturers.LBL_NAME")); // 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 { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); // 09/03/2005 Paul. DataBind is required in order for the RequiredFieldValidators to work. // 07/02/2006 Paul. The required fields need to be bound manually. reqNAME.DataBind(); reqLIST_ORDER.DataBind(); gID = Sql.ToGuid(Request["ID"]); if (!IsPostBack) { lstSTATUS.DataSource = SplendidCache.List("manufacturer_status_dom"); lstSTATUS.DataBind(); Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwMANUFACTURERS" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gID); con.Open(); #if DEBUG Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); #endif using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { txtNAME.Text = Sql.ToString(rdr["NAME"]); ctlListHeader.Title = L10n.Term("Manufacturers.LBL_NAME") + " " + txtNAME.Text; txtLIST_ORDER.Text = Sql.ToString(rdr["LIST_ORDER"]); try { lstSTATUS.SelectedValue = Sql.ToString(rdr["STATUS"]); } catch { } } } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term(m_sMODULE + ".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.GetUserAccess(m_sMODULE, "list") >= 0); if (!this.Visible) { return; } try { // 11/15/2007 Paul. Hide the checkbox column on a mobile browser. if (this.IsMobile && grdMain.Columns.Count > 0) { grdMain.Columns[0].Visible = false; } DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwACCOUNTS_List" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 11/24/2006 Paul. Use new Security.Filter() function to apply Team and ACL security rules. Security.Filter(cmd, m_sMODULE, "list"); ctlSearchView.SqlSearchClause(cmd); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); vwMain = dt.DefaultView; grdMain.DataSource = vwMain; if (!IsPostBack) { // 12/14/2007 Paul. Only set the default sort if it is not already set. It may have been set by SearchView. if (String.IsNullOrEmpty(grdMain.SortColumn)) { grdMain.SortColumn = "NAME"; grdMain.SortOrder = "asc"; } grdMain.ApplySort(); grdMain.DataBind(); } } } } } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { gID = Sql.ToGuid(Request["ID"]); Guid gCONTACT_ID = Sql.ToGuid(txtCONTACT_ID.Value); if (!Sql.IsEmptyGuid(gCONTACT_ID)) { try { SqlProcs.spACCOUNTS_CONTACTS_Update(gID, gCONTACT_ID); Response.Redirect("view.aspx?ID=" + gID.ToString()); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } } DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwACCOUNTS_CONTACTS " + ControlChars.CrLf + " where ACCOUNT_ID = @ACCOUNT_ID" + ControlChars.CrLf + " order by DATE_ENTERED asc " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ACCOUNT_ID", gID); #if DEBUG Page.RegisterClientScriptBlock("vwACCOUNTS_CONTACTS", Sql.ClientScriptBlock(cmd)); #endif try { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); vwMain = dt.DefaultView; grdMain.DataSource = vwMain; // 09/05/2005 Paul. LinkButton controls will not fire an event unless the the grid is bound. //if ( !IsPostBack ) { grdMain.DataBind(); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } } } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term(".moduleList.EditCustomFields")); // 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 { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); gID = Sql.ToGuid(Request["ID"]); if (!IsPostBack) { // 01/10/2007 Paul. Use cached data to populate the pick list. lstDROPDOWN_LIST.DataSource = SplendidCache.TerminologyPickLists(); lstDROPDOWN_LIST.DataBind(); lstDROPDOWN_LIST_Changed(null, null); Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwFIELDS_META_DATA_Edit" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gID); con.Open(); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ViewState["MODULE_NAME"] = Sql.ToString(rdr["CUSTOM_MODULE"]); txtNAME.Text = Sql.ToString(rdr["NAME"]); SetPageTitle(L10n.Term("EditCustomFields.LBL_MODULE_NAME") + " - " + txtNAME.Text); txtLABEL.Text = Sql.ToString(rdr["LABEL"]); txtMAX_SIZE.Text = Sql.ToString(rdr["MAX_SIZE"]); txtDEFAULT_VALUE.Text = Sql.ToString(rdr["DEFAULT_VALUE"]); chkAUDITED.Checked = Sql.ToBoolean(rdr["AUDITED"]); chkREQUIRED.Checked = (Sql.ToString(rdr["REQUIRED_OPTION"]) == "required") ? true : false; try { lstDATA_TYPE.SelectedValue = Sql.ToString(rdr["DATA_TYPE"]); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } try { if (lstDATA_TYPE.SelectedValue == "enum") { lstDROPDOWN_LIST.SelectedValue = Sql.ToString(rdr["EXT1"]); } } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } trDROPDOWN_LIST.Visible = (lstDATA_TYPE.SelectedValue == "enum"); trMAX_SIZE.Visible = (lstDATA_TYPE.SelectedValue == "varchar"); lstDROPDOWN_LIST_Changed(null, null); } } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term("Contacts.LBL_LIST_FORM_TITLE")); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { using (IDbCommand cmd = con.CreateCommand()) { try { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dtCombined = new DataTable()) { // 12/19/2006 Paul. As much as we would like to combine the threee separate queries into // a single query using a union, we cannot because the Security.Filter rules must be applied separately. // We simply combine three DataTables as quickly and efficiently as possible. cmd.CommandText = "select * " + ControlChars.CrLf + " , N'Contacts' as ADDRESS_TYPE" + ControlChars.CrLf + " from vwCONTACTS_EmailList " + ControlChars.CrLf; Security.Filter(cmd, "Contacts", "list"); ctlSearchView.SqlSearchClause(cmd); if (bDebug) { Page.ClientScript.RegisterClientScriptBlock(System.Type.GetType("System.String"), "vwCONTACTS_EmailList", Sql.ClientScriptBlock(cmd)); } da.Fill(dtCombined); cmd.Parameters.Clear(); cmd.CommandText = "select * " + ControlChars.CrLf + " , N'Leads' as ADDRESS_TYPE" + ControlChars.CrLf + " from vwLEADS_EmailList " + ControlChars.CrLf; Security.Filter(cmd, "Leads", "list"); ctlSearchView.SqlSearchClause(cmd); if (bDebug) { Page.ClientScript.RegisterClientScriptBlock(System.Type.GetType("System.String"), "vwLEADS_EmailList", Sql.ClientScriptBlock(cmd)); } using (DataTable dt = new DataTable()) { da.Fill(dt); foreach (DataRow row in dt.Rows) { DataRow rowNew = dtCombined.NewRow(); //rowNew.ItemArray = row.ItemArray; // 12/19/2006 Paul. Using the ItemArray would certainly be faster, // but someone may accidentally modify one of the columns of the three views, // so we shall be safe and check each column before setting its value. foreach (DataColumn col in dt.Columns) { if (dtCombined.Columns.Contains(col.ColumnName)) { rowNew[col.ColumnName] = row[col.ColumnName]; } } dtCombined.Rows.Add(rowNew); } } cmd.Parameters.Clear(); cmd.CommandText = "select * " + ControlChars.CrLf + " , N'Prospects' as ADDRESS_TYPE" + ControlChars.CrLf + " from vwPROSPECTS_EmailList " + ControlChars.CrLf; Security.Filter(cmd, "Prospects", "list"); ctlSearchView.SqlSearchClause(cmd); if (bDebug) { Page.ClientScript.RegisterClientScriptBlock(System.Type.GetType("System.String"), "vwPROSPECTS_EmailList", Sql.ClientScriptBlock(cmd)); } using (DataTable dt = new DataTable()) { da.Fill(dt); foreach (DataRow row in dt.Rows) { DataRow rowNew = dtCombined.NewRow(); //rowNew.ItemArray = row.ItemArray; // 12/19/2006 Paul. Using the ItemArray would certainly be faster, // but someone may accidentally modify one of the columns of the three views, // so we shall be safe and check each column before setting its value. foreach (DataColumn col in dt.Columns) { if (dtCombined.Columns.Contains(col.ColumnName)) { rowNew[col.ColumnName] = row[col.ColumnName]; } } dtCombined.Rows.Add(rowNew); } } vwMain = dtCombined.DefaultView; grdMain.DataSource = vwMain; if (!IsPostBack) { // 12/14/2007 Paul. Only set the default sort if it is not already set. It may have been set by SearchView. if (String.IsNullOrEmpty(grdMain.SortColumn)) { grdMain.SortColumn = "NAME"; grdMain.SortOrder = "asc"; } grdMain.ApplySort(); grdMain.DataBind(); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } } } if (!IsPostBack) { Page.DataBind(); } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term(".moduleList." + m_sMODULE)); // 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.GetUserAccess(m_sMODULE, "view") >= 0); if (!this.Visible) { return; } try { gID = Sql.ToGuid(Request["ID"]); // 11/28/2005 Paul. We must always populate the table, otherwise it will disappear during event processing. //if ( !IsPostBack ) { if (!Sql.IsEmptyGuid(gID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwEMAILS_Edit" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 11/24/2006 Paul. Use new Security.Filter() function to apply Team and ACL security rules. Security.Filter(cmd, m_sMODULE, "view"); Sql.AppendParameter(cmd, gID, "ID", false); con.Open(); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = Sql.ToString(rdr["NAME"]); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); this.AppendDetailViewFields(m_sMODULE + ".DetailView", tblMain, rdr); // 11/17/2005 Paul. Archived emails allow editing of the Date & Time Sent. string sEMAIL_TYPE = Sql.ToString(rdr["TYPE"]).ToLower(); ctlModuleHeader.EnableModuleLabel = false; switch (sEMAIL_TYPE) { case "archived": ctlModuleHeader.Title = L10n.Term("Emails.LBL_ARCHIVED_MODULE_NAME") + ":" + ctlModuleHeader.Title; Response.Redirect("view.aspx?ID=" + gID.ToString()); break; case "inbound": // 06/28/2007 Paul. Inbound emails should not automatically go to edit mode. ctlModuleHeader.Title = L10n.Term("Emails.LBL_INBOUND_TITLE") + ":" + ctlModuleHeader.Title; break; case "out": ctlModuleHeader.Title = L10n.Term("Emails.LBL_LIST_FORM_SENT_TITLE") + ":" + ctlModuleHeader.Title; Response.Redirect("view.aspx?ID=" + gID.ToString()); break; case "sent": ctlModuleHeader.Title = L10n.Term("Emails.LBL_LIST_FORM_SENT_TITLE") + ":" + ctlModuleHeader.Title; Response.Redirect("view.aspx?ID=" + gID.ToString()); break; case "campaign": // 01/13/2008 Paul. Campaign emails should be treated the same as outbound emails. ctlModuleHeader.Title = L10n.Term("Emails.LBL_LIST_FORM_SENT_TITLE") + ":" + ctlModuleHeader.Title; Response.Redirect("view.aspx?ID=" + gID.ToString()); break; default: sEMAIL_TYPE = "draft"; ctlModuleHeader.Title = L10n.Term("Emails.LBL_COMPOSE_MODULE_NAME") + ":" + ctlModuleHeader.Title; // 01/21/2006 Paul. Draft messages go directly to edit mode. Response.Redirect("edit.aspx?ID=" + gID.ToString()); break; } } else { // 11/25/2006 Paul. If item is not visible, then don't show its sub panel either. plcSubPanel.Visible = false; ctlInboundButtons.DisableAll(); ctlInboundButtons.ErrorText = L10n.Term("ACL.LBL_NO_ACCESS"); } } } sSQL = "select * " + ControlChars.CrLf + " from vwEMAILS_Attachments" + ControlChars.CrLf + " where EMAIL_ID = @EMAIL_ID" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@EMAIL_ID", gID); if (bDebug) { RegisterClientScriptBlock("vwEMAILS_Attachments", Sql.ClientScriptBlock(cmd)); } using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); ctlAttachments.DataSource = dt.DefaultView; ctlAttachments.DataBind(); } } } } } } // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlInboundButtons.ErrorText = ex.Message; } }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "Save") { // 01/16/2006 Paul. Enable validator before validating page. this.ValidateEditViewFields(m_sMODULE + ".EditView"); this.ValidateEditViewFields(m_sMODULE + ".EditAddress"); if (Page.IsValid) { string sCUSTOM_MODULE = "USERS"; DataTable dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); // 11/18/2007 Paul. Use the current values for any that are not defined in the edit view. DataRow rowCurrent = null; DataTable dtCurrent = new DataTable(); if (!Sql.IsEmptyGuid(gID)) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwEMPLOYEES_Edit" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Security.Filter(cmd, m_sMODULE, "edit"); Sql.AppendParameter(cmd, gID, "ID", false); using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; da.Fill(dtCurrent); if (dtCurrent.Rows.Count > 0) { rowCurrent = dtCurrent.Rows[0]; } else { // 11/19/2007 Paul. If the record is not found, clear the ID so that the record cannot be updated. // It is possible that the record exists, but that ACL rules prevent it from being selected. gID = Guid.Empty; } } } } using (IDbTransaction trn = con.BeginTransaction()) { try { // 11/18/2007 Paul. Use the current values for any that are not defined in the edit view. SqlProcs.spEMPLOYEES_Update (ref gID , new DynamicControl(this, rowCurrent, "FIRST_NAME").Text , new DynamicControl(this, rowCurrent, "LAST_NAME").Text , new DynamicControl(this, rowCurrent, "REPORTS_TO_ID").ID , new DynamicControl(this, rowCurrent, "DESCRIPTION").Text , new DynamicControl(this, rowCurrent, "TITLE").Text , new DynamicControl(this, rowCurrent, "DEPARTMENT").Text , new DynamicControl(this, rowCurrent, "PHONE_HOME").Text , new DynamicControl(this, rowCurrent, "PHONE_MOBILE").Text , new DynamicControl(this, rowCurrent, "PHONE_WORK").Text , new DynamicControl(this, rowCurrent, "PHONE_OTHER").Text , new DynamicControl(this, rowCurrent, "PHONE_FAX").Text , new DynamicControl(this, rowCurrent, "EMAIL1").Text , new DynamicControl(this, rowCurrent, "EMAIL2").Text , new DynamicControl(this, rowCurrent, "ADDRESS_STREET").Text , new DynamicControl(this, rowCurrent, "ADDRESS_CITY").Text , new DynamicControl(this, rowCurrent, "ADDRESS_STATE").Text , new DynamicControl(this, rowCurrent, "ADDRESS_POSTALCODE").Text , new DynamicControl(this, rowCurrent, "ADDRESS_COUNTRY").Text , new DynamicControl(this, rowCurrent, "EMPLOYEE_STATUS").SelectedValue , new DynamicControl(this, rowCurrent, "MESSENGER_ID").Text , new DynamicControl(this, rowCurrent, "MESSENGER_TYPE").SelectedValue , trn ); SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields); trn.Commit(); } catch (Exception ex) { trn.Rollback(); SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = ex.Message; return; } } } Response.Redirect("view.aspx?ID=" + gID.ToString()); } } else if (e.CommandName == "Cancel") { if (Sql.IsEmptyGuid(gID)) { Response.Redirect("default.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID.ToString()); } } }