private void lst_OnDataBinding(object sender, EventArgs e) { DataGridItem objContainer = (DataGridItem)lst.NamingContainer; DataRowView row = objContainer.DataItem as DataRowView; ReportFilterGrid grd = objContainer.Parent.Parent as ReportFilterGrid; if (row != null) { // 04/25/2006 Paul. We always need to translate the items, even during postback. // This is because we always build the DropDownList. // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if (L10n == null) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } if (row[sDATA_FIELD] != DBNull.Value) { string sID = Sql.ToString(row["ID"]); string sMODULE = Sql.ToString(row["MODULE_NAME"]); lst.ID = sDATA_FIELD + "_" + sID; try { if (sDATA_FIELD == "MODULE_NAME") { XmlDocument xml = grd.Rdl; /* * // 06/20/2006 Paul. New RdlDocument handles custom properties. * string sRelationships = RdlUtil.GetCustomProperty(xml.DocumentElement, "Relationships"); * if ( !Sql.IsEmptyString(sRelationships) ) * { * XmlDocument xmlRelationship = new XmlDocument(); * xmlRelationship.LoadXml(sRelationships); * dt = XmlUtil.CreateDataTable(xmlRelationship.DocumentElement, "Relationship", new string[] {"MODULE_NAME", "DISPLAY_NAME"}); * lst.AutoPostBack = true; * foreach ( DataRow rowRelationship in dt.Rows ) * { * lst.Items.Add(new ListItem(Sql.ToString(rowRelationship["DISPLAY_NAME"]), Sql.ToString(rowRelationship["MODULE_NAME"]))); * } * } */ } else if (sDATA_FIELD == "DATA_FIELD") { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); string sSQL; sSQL = "select ColumnName as NAME " + ControlChars.CrLf + " , ColumnName as DISPLAY_NAME " + ControlChars.CrLf + " from vwSqlColumns " + ControlChars.CrLf + " where ObjectName = @ObjectName " + ControlChars.CrLf + " and ColumnName not in ('ID', 'ID_C')" + ControlChars.CrLf + " and ColumnName not like '%_ID' " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; DropDownList lstMODULE_NAME = null; // 05/28/2006 Paul. Not sure why, but grd.FindFilterControl() does not work. foreach (DataGridItem itm in objContainer.Parent.Controls) { lstMODULE_NAME = itm.FindControl("MODULE_NAME" + "_" + sID) as DropDownList; if (lstMODULE_NAME != null) { break; } } string sMODULE_NAME = lstMODULE_NAME.SelectedValue; string[] arrModule = sMODULE_NAME.Split(' '); string sModule = arrModule[0]; string sTableAlias = arrModule[0]; if (arrModule.Length > 1) { sTableAlias = arrModule[1].ToUpper(); } Sql.AddParameter(cmd, "@ObjectName", "vw" + sModule); using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; dt = new DataTable(); da.Fill(dt); foreach (DataRow rowColumn in dt.Rows) { rowColumn["NAME"] = sMODULE + "." + Sql.ToString(rowColumn["NAME"]); rowColumn["DISPLAY_NAME"] = L10n.Term(sModule + ".LBL_" + Sql.ToString(rowColumn["DISPLAY_NAME"])).Replace(":", ""); } DataView vwColumns = new DataView(dt); vwColumns.Sort = "DISPLAY_NAME"; foreach (DataRowView rowColumn in vwColumns) { lst.Items.Add(new ListItem(Sql.ToString(rowColumn["DISPLAY_NAME"]), Sql.ToString(rowColumn["NAME"]))); } } } } } } catch { } try { // 04/25/2006 Paul. Don't update values on postback, otherwise it will over-write modified values. if (!objContainer.Page.IsPostBack) { lst.SelectedValue = Sql.ToString(row[sDATA_FIELD]); } } catch { } } /* * // 04/25/2006 Paul. Make sure to translate the text. * // It cannot be translated in InstantiateIn() because the Page is not defined. * foreach(ListItem itm in lst.Items ) * { * itm.Text = L10n.Term(itm.Text); * } */ } }
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. // 07/11/2006 Paul. Users must be able to view and edit their own settings. this.Visible = bMyAccount || SplendidCRM.Security.IS_ADMIN; //(SplendidCRM.Security.GetUserAccess(m_sMODULE, "view") >= 0); if (!this.Visible) { return; } try { gID = Sql.ToGuid(Request["ID"]); if (bMyAccount) { // 11/19/2005 Paul. SugarCRM 3.5.0 allows administrator to duplicate itself. btnDuplicate.Visible = Security.IS_ADMIN; gID = Security.USER_ID; } ctlAccessView.USER_ID = gID; // 12/06/2005 Paul. The password button is only visible if not windows authentication or Admin. // The reason to allow the admin to change a password is so that the admin can prepare to turn off windows authentication. btnChangePassword.Visible = !Security.IsWindowsAuthentication() || Security.IS_ADMIN; btnReset.Visible = Security.IS_ADMIN; if (!Sql.IsEmptyString(txtNEW_PASSWORD.Value)) { bool bValidOldPassword = false; if (!Security.IS_ADMIN) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; // 07/17/2006 Paul. The USER_HASH has been removed from the main vwUSERS view to prevent its use in reports. sSQL = "select * " + ControlChars.CrLf + " from vwUSERS_Login " + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf + " and USER_HASH = @USER_HASH" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gID); Sql.AddParameter(cmd, "@USER_HASH", Security.HashPassword(txtOLD_PASSWORD.Value)); con.Open(); using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { bValidOldPassword = true; } } } } if (!bValidOldPassword) { lblError.Text = L10n.Term("Users.ERR_PASSWORD_INCORRECT_OLD"); } } if (bValidOldPassword || Security.IS_ADMIN) { if (txtNEW_PASSWORD.Value == txtCONFIRM_PASSWORD.Value) { SqlProcs.spUSERS_PasswordUpdate(gID, Security.HashPassword(txtNEW_PASSWORD.Value)); if (bMyAccount) { Response.Redirect("MyAccount.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID.ToString()); } } else { lblError.Text = L10n.Term("Users.ERR_REENTER_PASSWORDS"); } } } if (!IsPostBack) { // 05/09/2006 Paul. We need to always initialize the separators, just in case the user is new. txtGROUP_SEPARATOR.Text = SplendidDefaults.GroupSeparator(); txtDECIMAL_SEPARATOR.Text = SplendidDefaults.DecimalSeparator(); if (!Sql.IsEmptyGuid(gID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwUSERS_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()) { ctlModuleHeader.Title = Sql.ToString(rdr["FULL_NAME"]) + " (" + Sql.ToString(rdr["USER_NAME"]) + ")"; SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); // main txtNAME.Text = Sql.ToString(rdr["FULL_NAME"]); txtUSER_NAME.Text = Sql.ToString(rdr["USER_NAME"]); txtSTATUS.Text = Sql.ToString(L10n.Term(".user_status_dom.", rdr["STATUS"])); // user_settings chkIS_ADMIN.Checked = Sql.ToBoolean(rdr["IS_ADMIN"]); chkPORTAL_ONLY.Checked = Sql.ToBoolean(rdr["PORTAL_ONLY"]); chkRECEIVE_NOTIFICATIONS.Checked = Sql.ToBoolean(rdr["RECEIVE_NOTIFICATIONS"]); this.AppendDetailViewFields(m_sMODULE + ".DetailView", tblMain, rdr); // 08/05/2006 Paul. MailOptions are populated manually. this.AppendDetailViewFields(m_sMODULE + ".MailOptions", tblMailOptions, null); // 01/20/2008 Paul. The mail options panel is manually populated. new DynamicControl(this, "EMAIL1").Text = Sql.ToString(rdr["EMAIL1"]); new DynamicControl(this, "EMAIL2").Text = Sql.ToString(rdr["EMAIL2"]); string sUSER_PREFERENCES = Sql.ToString(rdr["USER_PREFERENCES"]); if (!Sql.IsEmptyString(sUSER_PREFERENCES)) { XmlDocument xml = SplendidInit.InitUserPreferences(sUSER_PREFERENCES); try { // user_settings txtLANGUAGE.Text = L10N.NormalizeCulture(XmlUtil.SelectSingleNode(xml, "culture")); try { DataView vwLanguages = new DataView(SplendidCache.Languages()); vwLanguages.RowFilter = "NAME = '" + txtLANGUAGE.Text + "'"; if (vwLanguages.Count > 0) { txtLANGUAGE.Text = Sql.ToString(vwLanguages[0]["NATIVE_NAME"]); } } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } txtDATEFORMAT.Text = XmlUtil.SelectSingleNode(xml, "dateformat"); txtTIMEFORMAT.Text = XmlUtil.SelectSingleNode(xml, "timeformat"); // 08/05/2006 Paul. Remove stub of unsupported code. Show Gridline is not supported at this time. //chkGRIDLINE .Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "gridline" )); // mail_options new DynamicControl(this, "MAIL_FROMNAME").Text = XmlUtil.SelectSingleNode(xml, "mail_fromname"); new DynamicControl(this, "MAIL_FROMADDRESS").Text = XmlUtil.SelectSingleNode(xml, "mail_fromaddress"); new DynamicControl(this, "MAIL_SENDTYPE").Text = XmlUtil.SelectSingleNode(xml, "mail_sendtype"); new DynamicControl(this, "MAIL_SMTPSERVER").Text = XmlUtil.SelectSingleNode(xml, "mail_smtpserver"); new DynamicControl(this, "MAIL_SMTPPORT").Text = XmlUtil.SelectSingleNode(xml, "mail_smtpport"); new DynamicControl(this, "MAIL_SMTPAUTH_REQ").Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "mail_smtpauth_req")); new DynamicControl(this, "MAIL_SMTPUSER").Text = XmlUtil.SelectSingleNode(xml, "mail_smtpuser"); // freebusy // 08/05/2006 Paul. Remove stub of unsupported code. Calendar Publish Key is not supported at this time. //txtCALENDAR_PUBLISH_KEY .Text = XmlUtil.SelectSingleNode(xml, "calendar_publish_key" ); //txtCALENDAR_PUBLISH_URL .Text = XmlUtil.SelectSingleNode(xml, "calendar_publish_url" ); //txtCALENDAR_SEARCH_URL .Text = XmlUtil.SelectSingleNode(xml, "calendar_search_url" ); // 05/09/2006 Paul. Initialize the numeric separators. txtGROUP_SEPARATOR.Text = XmlUtil.SelectSingleNode(xml, "num_grp_sep"); txtDECIMAL_SEPARATOR.Text = XmlUtil.SelectSingleNode(xml, "dec_sep"); // 05/09/2006 Paul. Check for empty strings as the user may have legacy data. if (Sql.IsEmptyString(txtGROUP_SEPARATOR.Text)) { txtGROUP_SEPARATOR.Text = SplendidDefaults.GroupSeparator(); } if (Sql.IsEmptyString(txtDECIMAL_SEPARATOR.Text)) { txtDECIMAL_SEPARATOR.Text = SplendidDefaults.DecimalSeparator(); } string sTIMEZONE = XmlUtil.SelectSingleNode(xml, "timezone"); DataView vwTimezones = new DataView(SplendidCache.Timezones()); vwTimezones.RowFilter = "ID = '" + sTIMEZONE + "'"; if (vwTimezones.Count > 0) { txtTIMEZONE.Text = Sql.ToString(vwTimezones[0]["NAME"]); } string sCURRENCY = XmlUtil.SelectSingleNode(xml, "currency_id"); DataView vwCurrencies = new DataView(SplendidCache.Currencies()); vwCurrencies.RowFilter = "ID = '" + sCURRENCY + "'"; if (vwCurrencies.Count > 0) { txtCURRENCY.Text = Sql.ToString(vwCurrencies[0]["NAME_SYMBOL"]); } // 08/05/2006 Paul. Remove stub of unsupported code. Reminder is not supported at this time. /* * try * { * int nREMINDER_TIME = Sql.ToInteger(XmlUtil.SelectSingleNode(xml, "reminder_time")); * if ( nREMINDER_TIME > 0 ) * { * txtREMINDER_TIME.Text = L10n.Term(".reminder_time_options." + nREMINDER_TIME.ToString()); * chkREMINDER.Checked = true; * } * } * catch(Exception ex) * { * SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); * } */ } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); } } //txtDESCRIPTION.Text = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String("YToxODp7czo4OiJncmlkbGluZSI7czozOiJvZmYiO3M6ODoibWF4X3RhYnMiO3M6MjoiMTIiO3M6MTI6ImRpc3BsYXlfdGFicyI7YToxNTp7aTowO3M6NDoiSG9tZSI7aToxO3M6NzoiaUZyYW1lcyI7aToyO3M6ODoiQ2FsZW5kYXIiO2k6MztzOjEwOiJBY3Rpdml0aWVzIjtpOjQ7czo4OiJBY2NvdW50cyI7aTo1O3M6NToiTGVhZHMiO2k6NjtzOjEzOiJPcHBvcnR1bml0aWVzIjtpOjc7czo1OiJDYXNlcyI7aTo4O3M6NDoiQnVncyI7aTo5O3M6OToiRG9jdW1lbnRzIjtpOjEwO3M6NjoiRW1haWxzIjtpOjExO3M6OToiQ2FtcGFpZ25zIjtpOjEyO3M6NzoiUHJvamVjdCI7aToxMztzOjU6IkZlZWRzIjtpOjE0O3M6OToiRGFzaGJvYXJkIjt9czoxMzoicmVtaW5kZXJfdGltZSI7czozOiI5MDAiO3M6NToidGltZWYiO3M6MzoiSDppIjtzOjg6ImN1cnJlbmN5IjtzOjM6Ii05OSI7czo1OiJkYXRlZiI7czo1OiJZLW0tZCI7czo1OiJ0aW1leiI7czoxOiIwIjtzOjEzOiJtYWlsX2Zyb21uYW1lIjtzOjQ6IlBhdWwiO3M6MTY6Im1haWxfZnJvbWFkZHJlc3MiO3M6MTM6InBhdWxAcm9ueS5jb20iO3M6MTM6Im1haWxfc2VuZHR5cGUiO3M6NDoiU01UUCI7czoxNToibWFpbF9zbXRwc2VydmVyIjtzOjM6Im5zMSI7czoxMzoibWFpbF9zbXRwcG9ydCI7czoyOiIyMyI7czoxMzoibWFpbF9zbXRwdXNlciI7czo4OiJwYXVscm9ueSI7czoxMzoibWFpbF9zbXRwcGFzcyI7czo3OiJwb2NrZXQxIjtzOjE3OiJtYWlsX3NtdHBhdXRoX3JlcSI7czowOiIiO3M6MTY6Im1haWxfcG9wYXV0aF9yZXEiO3M6MDoiIjtzOjIwOiJjYWxlbmRhcl9wdWJsaXNoX2tleSI7czoxMToicHVibGlzaCBoZXkiO30=")); } } } } } } // 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"]); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwCASES_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 CASE_ID = @CASE_ID" + ControlChars.CrLf; cmd.CommandText += " order by DATE_DUE desc " + ControlChars.CrLf; Sql.AddParameter(cmd, "@CASE_ID", gID); if (bDebug) { RegisterClientScriptBlock("vwCASES_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(); } }
protected override void Page_Command(Object sender, CommandEventArgs e) { try { DataTable dtFields = ViewState["dtFields"] as DataTable; if (e.CommandName == "Layout.Edit") { if (ctlNewRecord != null) { ctlNewRecord.Clear(); int nFieldIndex = Sql.ToInteger(e.CommandArgument); DataView vwFields = new DataView(dtFields); vwFields.RowFilter = "DELETED = 0 and " + LayoutIndexName() + " = " + nFieldIndex.ToString(); if (vwFields.Count == 1) { foreach (DataRowView row in vwFields) { ctlNewRecord.FIELD_ID = Sql.ToGuid(row["ID"]); ctlNewRecord.FIELD_INDEX = Sql.ToInteger(row[LayoutIndexName()]); ctlNewRecord.FIELD_TYPE = Sql.ToString(row[LayoutTypeName()]); ctlNewRecord.DATA_LABEL = Sql.ToString(row["DATA_LABEL"]); ctlNewRecord.DATA_FIELD = Sql.ToString(row["DATA_FIELD"]); ctlNewRecord.DATA_FORMAT = Sql.ToString(row["DATA_FORMAT"]); ctlNewRecord.URL_FIELD = Sql.ToString(row["URL_FIELD"]); ctlNewRecord.URL_FORMAT = Sql.ToString(row["URL_FORMAT"]); ctlNewRecord.URL_TARGET = Sql.ToString(row["URL_TARGET"]); ctlNewRecord.COLSPAN = Sql.ToInteger(row["COLSPAN"]); ctlNewRecord.LIST_NAME = Sql.ToString(row["LIST_NAME"]); ctlNewRecord.Visible = true; break; } } } } else if (e.CommandName == "NewRecord.Save") { if (ctlNewRecord != null) { DataView vwFields = new DataView(dtFields); vwFields.RowFilter = "DELETED = 0 and ID = '" + ctlNewRecord.FIELD_ID + "'"; if (vwFields.Count == 1) { // 01/09/2006 Paul. Make sure to use ToDBString to convert empty stings to NULL. foreach (DataRowView row in vwFields) { row[LayoutTypeName()] = Sql.ToDBString(ctlNewRecord.FIELD_TYPE); row["DATA_LABEL"] = Sql.ToDBString(ctlNewRecord.DATA_LABEL); row["DATA_FIELD"] = Sql.ToDBString(ctlNewRecord.DATA_FIELD); row["DATA_FORMAT"] = Sql.ToDBString(ctlNewRecord.DATA_FORMAT); row["URL_FIELD"] = Sql.ToDBString(ctlNewRecord.URL_FIELD); row["URL_FORMAT"] = Sql.ToDBString(ctlNewRecord.URL_FORMAT); row["URL_TARGET"] = Sql.ToDBString(ctlNewRecord.URL_TARGET); row["COLSPAN"] = Sql.ToDBInteger(ctlNewRecord.COLSPAN); row["LIST_NAME"] = Sql.ToDBString(ctlNewRecord.LIST_NAME); break; } } else { vwFields.RowFilter = "DELETED = 0 and DATA_FIELD = '" + ctlNewRecord.DATA_FIELD + "'"; if (vwFields.Count == 1) { // 01/16/2006 Paul. We cannot use the same field twice. The main reason is because we // name the control after the field and .NET cannot allow two controls with the same name. throw(new Exception(ctlNewRecord.DATA_FIELD + " is already being used in this view.")); } else { // 01/08/2006 Paul. If not found, then insert a new field. if (ctlNewRecord.FIELD_INDEX == -1) { ctlNewRecord.FIELD_INDEX = DynamicTableNewFieldIndex(dtFields); } else { // Make room for the new record. DynamicTableInsert(dtFields, ctlNewRecord.FIELD_INDEX); } // 01/09/2006 Paul. Make sure to use ToDBString to convert empty stings to NULL. DataRow row = dtFields.NewRow(); dtFields.Rows.Add(row); row["ID"] = Guid.NewGuid(); row["DELETED"] = 0; row["DETAIL_NAME"] = Sql.ToString(ViewState["LAYOUT_VIEW_NAME"]); row[LayoutIndexName()] = Sql.ToDBInteger(ctlNewRecord.FIELD_INDEX); row[LayoutTypeName()] = Sql.ToDBString(ctlNewRecord.FIELD_TYPE); row["DATA_LABEL"] = Sql.ToDBString(ctlNewRecord.DATA_LABEL); row["DATA_FIELD"] = Sql.ToDBString(ctlNewRecord.DATA_FIELD); row["DATA_FORMAT"] = Sql.ToDBString(ctlNewRecord.DATA_FORMAT); row["URL_FIELD"] = Sql.ToDBString(ctlNewRecord.URL_FIELD); row["URL_FORMAT"] = Sql.ToDBString(ctlNewRecord.URL_FORMAT); row["URL_TARGET"] = Sql.ToDBString(ctlNewRecord.URL_TARGET); row["COLSPAN"] = Sql.ToDBInteger(ctlNewRecord.COLSPAN); row["LIST_NAME"] = Sql.ToDBString(ctlNewRecord.LIST_NAME); } } ViewState["dtFields"] = dtFields; LayoutView_Bind(dtFields); if (ctlNewRecord != null) { ctlNewRecord.Clear(); } } } else if (e.CommandName == "Defaults") { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwDETAILVIEWS_FIELDS " + ControlChars.CrLf + " where DETAIL_NAME = @DETAIL_NAME" + ControlChars.CrLf + " and DEFAULT_VIEW = 1 " + ControlChars.CrLf + " order by " + LayoutIndexName() + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@DETAIL_NAME", Sql.ToString(ViewState["LAYOUT_VIEW_NAME"])); using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; //dtFields = new DataTable(); // 01/09/2006 Paul. Mark existing records for deletion. // This is so that the save operation can update only records that have changed. foreach (DataRow row in dtFields.Rows) { row["DELETED"] = 1; } da.Fill(dtFields); // 01/09/2006 Paul. We need to change the IDs for two reasons, one is to prevent updating the Default Values, // the second reason is that we need the row to get a Modified state. Otherwise the update loop will skip it. foreach (DataRow row in dtFields.Rows) { if (Sql.ToInteger(row["DELETED"]) == 0) { row["ID"] = Guid.NewGuid(); } } } } } ViewState["dtFields"] = dtFields; LayoutView_Bind(dtFields); if (ctlNewRecord != null) { ctlNewRecord.Clear(); } } else { base.Page_Command(sender, e); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlLayoutButtons.ErrorText = ex.Message; } }
protected void Page_Command(Object sender, CommandEventArgs e) { 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); // 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. this.ValidateEditViewFields(m_sMODULE + ".EditView"); this.ValidateEditViewFields(m_sMODULE + ".EditAddress"); if (Page.IsValid) { string sUSER_PREFERENCES = String.Empty; XmlDocument xml = new XmlDocument(); try { try { sUSER_PREFERENCES = Sql.ToString(ViewState["USER_PREFERENCES"]); xml.LoadXml(sUSER_PREFERENCES); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); xml.AppendChild(xml.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"")); xml.AppendChild(xml.CreateElement("USER_PREFERENCE")); } // user_settings XmlUtil.SetSingleNode(xml, "gridline", chkGRIDLINE.Checked ? "true" : "false"); XmlUtil.SetSingleNode(xml, "culture", lstLANGUAGE.SelectedValue); XmlUtil.SetSingleNode(xml, "theme", lstTHEME.SelectedValue); XmlUtil.SetSingleNode(xml, "dateformat", lstDATE_FORMAT.SelectedValue); XmlUtil.SetSingleNode(xml, "timeformat", lstTIME_FORMAT.SelectedValue); XmlUtil.SetSingleNode(xml, "timezone", lstTIMEZONE.SelectedValue); XmlUtil.SetSingleNode(xml, "currency_id", lstCURRENCY.SelectedValue); XmlUtil.SetSingleNode(xml, "num_grp_sep", txtGROUP_SEPARATOR.Text); XmlUtil.SetSingleNode(xml, "dec_sep", txtDECIMAL_SEPARATOR.Text); // 08/05/2006 Paul. Remove stub of unsupported code. Reminder is not supported at this time. //XmlUtil.SetSingleNode(xml, "reminder_time" , chkSHOULD_REMIND.Checked ? lstREMINDER_TIME.SelectedValue : "0" ); // mail_options string sMAIL_SMTPPASS = Sql.ToString(ViewState["mail_smtppass"]); // 08/06/2005 Paul. Password might be our empty value. TextBox txtMAIL_SMTPPASS = FindControl("MAIL_SMTPPASS") as TextBox; if (txtMAIL_SMTPPASS != null) { // 08/05/2006 Paul. Allow the password to be cleared. if (txtMAIL_SMTPPASS.Text != sEMPTY_PASSWORD) { sMAIL_SMTPPASS = txtMAIL_SMTPPASS.Text; } } XmlUtil.SetSingleNode(xml, "mail_fromname", new DynamicControl(this, "MAIL_FROMNAME").Text); XmlUtil.SetSingleNode(xml, "mail_fromaddress", new DynamicControl(this, "MAIL_FROMADDRESS").Text); XmlUtil.SetSingleNode(xml, "mail_smtpserver", new DynamicControl(this, "MAIL_SMTPSERVER").Text); XmlUtil.SetSingleNode(xml, "mail_smtpport", new DynamicControl(this, "MAIL_SMTPPORT").Text); XmlUtil.SetSingleNode(xml, "mail_sendtype", new DynamicControl(this, "MAIL_SENDTYPE").Text); XmlUtil.SetSingleNode(xml, "mail_smtpauth_req", new DynamicControl(this, "MAIL_SMTPAUTH_REQ").Checked ? "true" : "false"); XmlUtil.SetSingleNode(xml, "mail_smtpuser", new DynamicControl(this, "MAIL_SMTPUSER").Text); XmlUtil.SetSingleNode(xml, "mail_smtppass", sMAIL_SMTPPASS); // freebusy // 08/05/2006 Paul. Remove stub of unsupported code. Calendar Publish Key is not supported at this time. //XmlUtil.SetSingleNode(xml, "calendar_publish_key", txtCALENDAR_PUBLISH_KEY .Text ); //XmlUtil.SetSingleNode(xml, "calendar_publish_url", txtCALENDAR_PUBLISH_URL .Text ); //XmlUtil.SetSingleNode(xml, "calendar_search_url" , txtCALENDAR_SEARCH_URL .Text ); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); } if (Sql.ToBoolean(Application["CONFIG.XML_UserPreferences"])) { sUSER_PREFERENCES = xml.OuterXml; } else { sUSER_PREFERENCES = XmlUtil.ConvertToPHP(xml.DocumentElement); } // 12/06/2005 Paul. Need to prevent duplicate users. string sUSER_NAME = txtUSER_NAME.Text.Trim(); DbProviderFactory dbf = DbProviderFactories.GetFactory(); try { // 11/10/2006 Paul. If the decimal and group separate match, then .NET will not be able to parse decimals. // The exception "Input string was not in a correct format." is thrown. if (txtGROUP_SEPARATOR.Text == txtDECIMAL_SEPARATOR.Text) { throw(new Exception(L10n.Term("Users.LBL_INVALID_DECIMAL"))); } if (!Sql.IsEmptyString(sUSER_NAME)) { using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select USER_NAME " + ControlChars.CrLf + " from vwUSERS " + ControlChars.CrLf + " where USER_NAME = @USER_NAME" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@USER_NAME", sUSER_NAME); if (!Sql.IsEmptyGuid(gID)) { // 12/06/2005 Paul. Only include the ID if it is not null as we cannot compare NULL to anything. cmd.CommandText += " and ID <> @ID" + ControlChars.CrLf; Sql.AddParameter(cmd, "@ID", gID); } con.Open(); using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { string sMESSAGE = String.Empty; sMESSAGE = String.Format(L10n.Term("Users.ERR_USER_NAME_EXISTS_1") + "{0}" + L10n.Term("Users.ERR_USER_NAME_EXISTS_2"), sUSER_NAME); throw(new Exception(sMESSAGE)); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = ex.Message; return; } string sCUSTOM_MODULE = "USERS"; DataTable dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE); 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 vwUSERS_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 { bool bNewUser = Sql.IsEmptyGuid(gID); // 04/24/2006 Paul. Upgrade to SugarCRM 4.2 Schema. // 11/18/2007 Paul. Use the current values for any that are not defined in the edit view. SqlProcs.spUSERS_Update (ref gID , sUSER_NAME , txtFIRST_NAME.Text , txtLAST_NAME.Text , new DynamicControl(this, rowCurrent, "REPORTS_TO_ID").ID , (Security.IS_ADMIN ? chkIS_ADMIN.Checked : Sql.ToBoolean(ViewState["IS_ADMIN"])) , chkRECEIVE_NOTIFICATIONS.Checked , 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 , lstSTATUS.SelectedValue , 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 , sUSER_PREFERENCES , chkPORTAL_ONLY.Checked , new DynamicControl(this, rowCurrent, "EMPLOYEE_STATUS").SelectedValue , new DynamicControl(this, rowCurrent, "MESSENGER_ID").Text , new DynamicControl(this, rowCurrent, "MESSENGER_TYPE").SelectedValue , sMODULE , gPARENT_ID , new DynamicControl(this, rowCurrent, "IS_GROUP").Checked , trn ); SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields); trn.Commit(); // 09/09/2006 Paul. Refresh cached user information. if (bNewUser) { SplendidCache.ClearUsers(); } // 08/27/2005 Paul. Reload session with user preferences. // 08/30/2005 Paul. Only reload preferences the user is editing his own profile. // We want to allow an administrator to update other user profiles. if (Security.USER_ID == gID) { SplendidInit.LoadUserPreferences(gID, lstTHEME.SelectedValue, lstLANGUAGE.SelectedValue); } } catch (Exception ex) { trn.Rollback(); SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = ex.Message; return; } } } if (!Sql.IsEmptyGuid(gPARENT_ID)) { Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString()); } else if (bMyAccount) { Response.Redirect("MyAccount.aspx"); } 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 (bMyAccount) { Response.Redirect("MyAccount.aspx"); } 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) { gID = Sql.ToGuid(Request["ID"]); Guid gLEAD_ID = Sql.ToGuid(txtLEAD_ID.Value); if (!Sql.IsEmptyGuid(gLEAD_ID)) { try { SqlProcs.spEMAILS_LEADS_Update(gID, gLEAD_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 vwEMAILS_LEADS " + ControlChars.CrLf + " where EMAIL_ID = @EMAIL_ID" + ControlChars.CrLf + " order by DATE_ENTERED asc " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@EMAIL_ID", gID); #if DEBUG Page.RegisterClientScriptBlock("vwEMAILS_LEADS", 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) { Utils.SetPageTitle(Page, L10n.Term(".moduleList.Roles")); // 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 { gID = Sql.ToGuid(Request["ID"]); if (!IsPostBack) { ListBox lstLeft = ctlChooser.LeftListBox; ListBox lstRight = ctlChooser.RightListBox; 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 vwROLES_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.Roles") + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; // 01/25/2006 Paul. Need to provide the recordset. this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); } } } sSQL = "select * " + ControlChars.CrLf + " from vwROLES_MODULES " + ControlChars.CrLf + " where ROLE_ID = @ROLE_ID" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ROLE_ID", gID); #if DEBUG Page.RegisterClientScriptBlock("vwROLES_MODULES", Sql.ClientScriptBlock(cmd)); #endif try { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); // 08/05/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["MODULE_NAME"] = L10n.Term(".moduleList.", row["MODULE_NAME"]); } vwLeft = new DataView(dt); vwLeft.RowFilter = "ALLOW = 1"; lstLeft.DataValueField = "MODULE"; lstLeft.DataTextField = "MODULE_NAME"; lstLeft.DataSource = vwLeft; lstLeft.DataBind(); vwRight = new DataView(dt); vwRight.RowFilter = "ALLOW = 0"; lstRight.DataValueField = "MODULE"; lstRight.DataTextField = "MODULE_NAME"; lstRight.DataSource = vwRight; lstRight.DataBind(); } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlEditButtons.ErrorText = ex.Message; } } } } else { this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); DataTable dt = SplendidCache.TabMenu(); foreach (DataRow row in dt.Rows) { string sMODULE_NAME = Sql.ToString(row["MODULE_NAME"]); string sDISPLAY_NAME = L10n.Term(Sql.ToString(row["DISPLAY_NAME"])); lstLeft.Items.Insert(0, new ListItem(sDISPLAY_NAME, sMODULE_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.Roles") + " - " + 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("Currencies.LBL_CURRENCY")); // 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(); reqSYMBOL.DataBind(); reqISO4217.DataBind(); reqCONVERSION_RATE.DataBind(); gID = Sql.ToGuid(Request["ID"]); if (!IsPostBack) { lstSTATUS.DataSource = SplendidCache.List("Currencies", "currency_status_dom"); lstSTATUS.DataBind(); 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 vwCURRENCIES_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 (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { txtNAME.Text = Sql.ToString(rdr["NAME"]); ctlListHeader.Title = L10n.Term("Currencies.LBL_CURRENCY") + ": " + txtNAME.Text; SetPageTitle(L10n.Term("Currencies.LBL_MODULE_NAME") + " - " + txtNAME.Text); txtSYMBOL.Text = Sql.ToString(rdr["SYMBOL"]); txtISO4217.Text = Sql.ToString(rdr["ISO4217"]); txtCONVERSION_RATE.Text = Sql.ToString(rdr["CONVERSION_RATE"]); try { lstSTATUS.SelectedValue = Sql.ToString(rdr["STATUS"]); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } } } } } } } } 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(".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()) { con.Open(); string sSQL; sSQL = "select ID " + ControlChars.CrLf + " , TITLE " + ControlChars.CrLf + " , URL " + ControlChars.CrLf + " from vwFEEDS_MyList " + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf + " and USER_ID = @USER_ID" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gID); Sql.AddParameter(cmd, "@USER_ID", Security.USER_ID); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { btnAdd.Visible = !rdr.Read(); btnDelete.Visible = !btnAdd.Visible; } } sSQL = "select ID " + ControlChars.CrLf + " , TITLE " + ControlChars.CrLf + " , URL " + ControlChars.CrLf + " from vwFEEDS " + 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); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = Sql.ToString(rdr["TITLE"]); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); //Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ctlFeedDetailView.URL = Sql.ToString(rdr["URL"]); } else { // 11/25/2006 Paul. If item is not visible, then don't show its sub panel either. btnDelete.Enabled = false; lblError.Text = 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); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { XmlDocument xml = new XmlDocument(); try { // 09/15/2005 Paul. Values will always be in the query string. int nCHART_LENGTH = Sql.ToInteger(Request.QueryString["CHART_LENGTH"]); DateTime dtDATE_START = T10n.ToServerTime(Sql.ToDateTime(Request.QueryString["DATE_START"])); DateTime dtDATE_END = T10n.ToServerTime(Sql.ToDateTime(Request.QueryString["DATE_END"])); if (dtDATE_START == DateTime.MinValue) { // 09/14/2005 Paul. SugarCRM uses a max date of 01/01/2100. dtDATE_START = DateTime.Today; } if (dtDATE_END == DateTime.MinValue) { // 09/14/2005 Paul. SugarCRM uses a max date of 01/01/2100. dtDATE_END = new DateTime(2100, 1, 1); } // 09/15/2005 Paul. Values will always be in the query string. string[] arrASSIGNED_USER_ID = Request.QueryString.GetValues("ASSIGNED_USER_ID"); // 09/15/2005 Paul. Values will always be in the query string. string[] arrSALES_STAGE = Request.QueryString.GetValues("SALES_STAGE"); xml.LoadXml(SplendidCache.XmlFile(Server.MapPath(Session["themeURL"] + "BarChart.xml"))); XmlNode nodeRoot = xml.SelectSingleNode("graphData"); XmlNode nodeXData = xml.CreateElement("xData"); XmlNode nodeYData = xml.CreateElement("yData"); XmlNode nodeColorLegend = xml.CreateElement("colorLegend"); XmlNode nodeGraphInfo = xml.CreateElement("graphInfo"); XmlNode nodeChartColors = nodeRoot.SelectSingleNode("chartColors"); nodeRoot.InsertBefore(nodeGraphInfo, nodeChartColors); nodeRoot.InsertBefore(nodeColorLegend, nodeGraphInfo); nodeRoot.InsertBefore(nodeXData, nodeColorLegend); nodeRoot.InsertBefore(nodeYData, nodeXData); XmlUtil.SetSingleNodeAttribute(xml, nodeYData, "defaultAltText", L10n.Term("Dashboard.LBL_ROLLOVER_DETAILS")); XmlUtil.SetSingleNodeAttribute(xml, nodeXData, "min", "0"); XmlUtil.SetSingleNodeAttribute(xml, nodeXData, "max", "0"); if (nCHART_LENGTH < 4) { nCHART_LENGTH = 4; } else if (nCHART_LENGTH > 10) { nCHART_LENGTH = 10; } XmlUtil.SetSingleNodeAttribute(xml, nodeXData, "length", nCHART_LENGTH.ToString()); XmlUtil.SetSingleNodeAttribute(xml, nodeXData, "prefix", Sql.ToString(Session["USER_SETTINGS/CURRENCY_SYMBOL"])); XmlUtil.SetSingleNodeAttribute(xml, nodeXData, "suffix", ""); nodeGraphInfo.InnerText = L10n.Term("Dashboard.LBL_DATE_RANGE") + " " + Sql.ToDateString(T10n.FromServerTime(dtDATE_START)) + " " + L10n.Term("Dashboard.LBL_DATE_RANGE_TO") + Sql.ToDateString(T10n.FromServerTime(dtDATE_END)) + "<BR/>" + L10n.Term("Dashboard.LBL_OPP_SIZE") + " " + Strings.FormatCurrency(1, 0, TriState.UseDefault, TriState.UseDefault, TriState.UseDefault) + L10n.Term("Dashboard.LBL_OPP_THOUSANDS"); Hashtable hashUSER = new Hashtable(); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); string sSQL; // 09/19/2005 Paul. Prepopulate the stage rows so that empty rows will appear. The SQL query will not return empty rows. if (arrSALES_STAGE != null) { foreach (string sSALES_STAGE in arrSALES_STAGE) { XmlNode nodeRow = xml.CreateElement("dataRow"); nodeYData.AppendChild(nodeRow); XmlUtil.SetSingleNodeAttribute(xml, nodeRow, "title", Sql.ToString(L10n.Term(".sales_stage_dom.", sSALES_STAGE))); XmlUtil.SetSingleNodeAttribute(xml, nodeRow, "endLabel", "0"); } } // 09/19/2005 Paul. Prepopulate the user key with all the users specified. if (arrASSIGNED_USER_ID != null) { sSQL = "select ID " + ControlChars.CrLf + " , USER_NAME " + ControlChars.CrLf + " from vwUSERS_List" + ControlChars.CrLf + " where 1 = 1 " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AppendGuids(cmd, arrASSIGNED_USER_ID, "ID"); cmd.CommandText += " order by USER_NAME" + ControlChars.CrLf; using (IDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { Guid gUSER_ID = Sql.ToGuid(rdr["ID"]); string sUSER_NAME = Sql.ToString(rdr["USER_NAME"]); if (!hashUSER.ContainsKey(gUSER_ID.ToString())) { XmlNode nodeMapping = xml.CreateElement("mapping"); nodeColorLegend.AppendChild(nodeMapping); XmlUtil.SetSingleNodeAttribute(xml, nodeMapping, "id", gUSER_ID.ToString()); XmlUtil.SetSingleNodeAttribute(xml, nodeMapping, "name", sUSER_NAME); XmlUtil.SetSingleNodeAttribute(xml, nodeMapping, "color", SplendidDefaults.generate_graphcolor(gUSER_ID.ToString(), hashUSER.Count)); hashUSER.Add(gUSER_ID.ToString(), sUSER_NAME); } } } } } sSQL = "select SALES_STAGE " + ControlChars.CrLf + " , ASSIGNED_USER_ID " + ControlChars.CrLf + " , USER_NAME " + ControlChars.CrLf + " , LIST_ORDER " + ControlChars.CrLf + " , sum(AMOUNT_USDOLLAR/1000) as TOTAL " + ControlChars.CrLf + " , count(*) as OPPORTUNITY_COUNT" + ControlChars.CrLf + " from vwOPPORTUNITIES_Pipeline " + ControlChars.CrLf + " where DATE_CLOSED >= @DATE_START " + ControlChars.CrLf + " and DATE_CLOSED <= @DATE_END " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 09/14/2005 Paul. Use add because <= and >= are not supported. Sql.AddParameter(cmd, "@DATE_START", dtDATE_START); Sql.AddParameter(cmd, "@DATE_END", dtDATE_END); // 09/14/2005 Paul. Use append because it supports arrays using the IN clause. Sql.AppendGuids(cmd, arrASSIGNED_USER_ID, "ASSIGNED_USER_ID"); Sql.AppendParameter(cmd, arrSALES_STAGE, "SALES_STAGE"); #if false if (arrSALES_STAGE != null) { nodeGraphInfo.InnerText = "SALES_STAGE = " + String.Join(", ", arrSALES_STAGE); } #endif cmd.CommandText += "" + " group by SALES_STAGE " + ControlChars.CrLf + " , LIST_ORDER " + ControlChars.CrLf + " , ASSIGNED_USER_ID " + ControlChars.CrLf + " , USER_NAME " + ControlChars.CrLf + " order by LIST_ORDER " + ControlChars.CrLf + " , USER_NAME " + ControlChars.CrLf; using (IDataReader rdr = cmd.ExecuteReader()) { double dMAX_TOTAL = 0; double dPIPELINE_TOTAL = 0; while (rdr.Read()) { string sSALES_STAGE = Sql.ToString(rdr["SALES_STAGE"]); double dTOTAL = Sql.ToDouble(rdr["TOTAL"]); int nOPPORTUNITY_COUNT = Sql.ToInteger(rdr["OPPORTUNITY_COUNT"]); Guid gASSIGNED_USER_ID = Sql.ToGuid(rdr["ASSIGNED_USER_ID"]); string sUSER_NAME = Sql.ToString(rdr["USER_NAME"]); dPIPELINE_TOTAL += dTOTAL; if (dTOTAL > dMAX_TOTAL) { dMAX_TOTAL = dTOTAL; } XmlNode nodeRow = nodeYData.SelectSingleNode("dataRow[@title=\'" + Sql.ToString(L10n.Term(".sales_stage_dom.", sSALES_STAGE)).Replace("'", "\'") + "\']"); if (nodeRow == null) { nodeRow = xml.CreateElement("dataRow"); nodeYData.AppendChild(nodeRow); XmlUtil.SetSingleNodeAttribute(xml, nodeRow, "title", Sql.ToString(L10n.Term(".sales_stage_dom.", sSALES_STAGE))); XmlUtil.SetSingleNodeAttribute(xml, nodeRow, "endLabel", dTOTAL.ToString("0")); } else { if (nodeRow.Attributes.GetNamedItem("endLabel") != null) { double dEND_LABEL = Sql.ToDouble(nodeRow.Attributes.GetNamedItem("endLabel").Value); dEND_LABEL += dTOTAL; if (dEND_LABEL > dMAX_TOTAL) { dMAX_TOTAL = dEND_LABEL; } XmlUtil.SetSingleNodeAttribute(xml, nodeRow, "endLabel", dEND_LABEL.ToString("0")); } } if (!hashUSER.ContainsKey(gASSIGNED_USER_ID.ToString())) { XmlNode nodeMapping = xml.CreateElement("mapping"); nodeColorLegend.AppendChild(nodeMapping); XmlUtil.SetSingleNodeAttribute(xml, nodeMapping, "id", gASSIGNED_USER_ID.ToString()); XmlUtil.SetSingleNodeAttribute(xml, nodeMapping, "name", sUSER_NAME); XmlUtil.SetSingleNodeAttribute(xml, nodeMapping, "color", SplendidDefaults.generate_graphcolor(gASSIGNED_USER_ID.ToString(), hashUSER.Count)); hashUSER.Add(gASSIGNED_USER_ID.ToString(), sUSER_NAME); } XmlNode nodeBar = xml.CreateElement("bar"); nodeRow.AppendChild(nodeBar); XmlUtil.SetSingleNodeAttribute(xml, nodeBar, "id", gASSIGNED_USER_ID.ToString()); XmlUtil.SetSingleNodeAttribute(xml, nodeBar, "totalSize", dTOTAL.ToString("0")); XmlUtil.SetSingleNodeAttribute(xml, nodeBar, "altText", sUSER_NAME + ": " + nOPPORTUNITY_COUNT.ToString() + " " + L10n.Term("Dashboard.LBL_OPPS_WORTH") + " " + dTOTAL.ToString("0") + L10n.Term("Dashboard.LBL_OPP_THOUSANDS") + " " + L10n.Term("Dashboard.LBL_OPPS_IN_STAGE") + " " + Sql.ToString(L10n.Term(".sales_stage_dom.", sSALES_STAGE))); XmlUtil.SetSingleNodeAttribute(xml, nodeBar, "url", Sql.ToString(Application["rootURL"]) + "Opportunities/default.aspx?SALES_STAGE=" + Server.UrlEncode(sSALES_STAGE) + "&ASSIGNED_USER_ID=" + gASSIGNED_USER_ID.ToString()); } int nNumLength = Math.Floor(dMAX_TOTAL).ToString("0").Length - 1; double dWhole = Math.Pow(10, nNumLength); double dDecimal = 1 / dWhole; double dMAX_ROUNDED = Math.Ceiling(dMAX_TOTAL * dDecimal) * dWhole; XmlUtil.SetSingleNodeAttribute(xml, nodeXData, "max", dMAX_ROUNDED.ToString("0")); XmlUtil.SetSingleNodeAttribute(xml, nodeRoot, "title", L10n.Term("Dashboard.LBL_TOTAL_PIPELINE") + Strings.FormatCurrency(dPIPELINE_TOTAL, 0, TriState.UseDefault, TriState.UseDefault, TriState.UseDefault) + L10n.Term("Dashboard.LBL_OPP_THOUSANDS")); } } } Response.ContentType = "text/xml"; Response.Write(xml.OuterXml); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); Response.Write(ex.Message); } }
protected override void Page_Command(Object sender, CommandEventArgs e) { try { DataTable dtFields = ViewState["dtFields"] as DataTable; if (e.CommandName == "Layout.Edit") { if (ctlNewRecord != null) { ctlNewRecord.Clear(); int nFieldIndex = Sql.ToInteger(e.CommandArgument); DataView vwFields = new DataView(dtFields); vwFields.RowFilter = "DELETED = 0 and " + LayoutIndexName() + " = " + nFieldIndex.ToString(); if (vwFields.Count == 1) { foreach (DataRowView row in vwFields) { ctlNewRecord.FIELD_ID = Sql.ToGuid(row["ID"]); ctlNewRecord.FIELD_INDEX = Sql.ToInteger(row[LayoutIndexName()]); ctlNewRecord.FIELD_TYPE = Sql.ToString(row[LayoutTypeName()]); ctlNewRecord.DATA_LABEL = Sql.ToString(row["DATA_LABEL"]); ctlNewRecord.DATA_FIELD = Sql.ToString(row["DATA_FIELD"]); ctlNewRecord.DISPLAY_FIELD = Sql.ToString(row["DISPLAY_FIELD"]); ctlNewRecord.LIST_NAME = Sql.ToString(row["LIST_NAME"]); ctlNewRecord.DATA_REQUIRED = Sql.ToBoolean(row["DATA_REQUIRED"]); ctlNewRecord.UI_REQUIRED = Sql.ToBoolean(row["UI_REQUIRED"]); ctlNewRecord.ONCLICK_SCRIPT = Sql.ToString(row["ONCLICK_SCRIPT"]); ctlNewRecord.FORMAT_SCRIPT = Sql.ToString(row["FORMAT_SCRIPT"]); ctlNewRecord.FORMAT_TAB_INDEX = Sql.ToInteger(row["FORMAT_TAB_INDEX"]); ctlNewRecord.FORMAT_MAX_LENGTH = Sql.ToInteger(row["FORMAT_MAX_LENGTH"]); ctlNewRecord.FORMAT_SIZE = Sql.ToInteger(row["FORMAT_SIZE"]); ctlNewRecord.FORMAT_ROWS = Sql.ToInteger(row["FORMAT_ROWS"]); ctlNewRecord.FORMAT_COLUMNS = Sql.ToInteger(row["FORMAT_COLUMNS"]); ctlNewRecord.COLSPAN = Sql.ToInteger(row["COLSPAN"]); ctlNewRecord.ROWSPAN = Sql.ToInteger(row["ROWSPAN"]); ctlNewRecord.Visible = true; break; } } } } else if (e.CommandName == "NewRecord.Save") { if (ctlNewRecord != null) { DataView vwFields = new DataView(dtFields); vwFields.RowFilter = "DELETED = 0 and ID = '" + ctlNewRecord.FIELD_ID + "'"; if (vwFields.Count == 1) { // 01/09/2006 Paul. Make sure to use ToDBString to convert empty stings to NULL. foreach (DataRowView row in vwFields) { row[LayoutTypeName()] = Sql.ToDBString(ctlNewRecord.FIELD_TYPE); row["DATA_LABEL"] = Sql.ToDBString(ctlNewRecord.DATA_LABEL); row["DATA_FIELD"] = Sql.ToDBString(ctlNewRecord.DATA_FIELD); row["DISPLAY_FIELD"] = Sql.ToDBString(ctlNewRecord.DISPLAY_FIELD); row["LIST_NAME"] = Sql.ToDBString(ctlNewRecord.LIST_NAME); // 01/20/2006 Paul. Need to duplicate the the LIST_NAME in the CACHE_NAME as the dynamic code uses CACHE_NAME. row["CACHE_NAME"] = Sql.ToDBString(ctlNewRecord.LIST_NAME); row["DATA_REQUIRED"] = Sql.ToDBBoolean(ctlNewRecord.DATA_REQUIRED); row["UI_REQUIRED"] = Sql.ToDBBoolean(ctlNewRecord.UI_REQUIRED); row["ONCLICK_SCRIPT"] = Sql.ToDBString(ctlNewRecord.ONCLICK_SCRIPT); row["FORMAT_SCRIPT"] = Sql.ToDBString(ctlNewRecord.FORMAT_SCRIPT); row["FORMAT_TAB_INDEX"] = Sql.ToDBInteger(ctlNewRecord.FORMAT_TAB_INDEX); row["FORMAT_MAX_LENGTH"] = Sql.ToDBInteger(ctlNewRecord.FORMAT_MAX_LENGTH); row["FORMAT_SIZE"] = Sql.ToDBInteger(ctlNewRecord.FORMAT_SIZE); row["FORMAT_ROWS"] = Sql.ToDBInteger(ctlNewRecord.FORMAT_ROWS); row["FORMAT_COLUMNS"] = Sql.ToDBInteger(ctlNewRecord.FORMAT_COLUMNS); row["COLSPAN"] = Sql.ToDBInteger(ctlNewRecord.COLSPAN); row["ROWSPAN"] = Sql.ToDBInteger(ctlNewRecord.ROWSPAN); break; } } else { // 01/08/2006 Paul. If not found, then insert a new field. if (ctlNewRecord.FIELD_INDEX == -1) { ctlNewRecord.FIELD_INDEX = DynamicTableNewFieldIndex(dtFields); } else { // Make room for the new record. DynamicTableInsert(dtFields, ctlNewRecord.FIELD_INDEX); } // 01/09/2006 Paul. Make sure to use ToDBString to convert empty stings to NULL. DataRow row = dtFields.NewRow(); dtFields.Rows.Add(row); row["ID"] = Guid.NewGuid(); row["DELETED"] = 0; row["EDIT_NAME"] = Sql.ToDBString(ViewState["LAYOUT_VIEW_NAME"]); row[LayoutIndexName()] = Sql.ToDBInteger(ctlNewRecord.FIELD_INDEX); row[LayoutTypeName()] = Sql.ToDBString(ctlNewRecord.FIELD_TYPE); row["DATA_LABEL"] = Sql.ToDBString(ctlNewRecord.DATA_LABEL); row["DATA_FIELD"] = Sql.ToDBString(ctlNewRecord.DATA_FIELD); row["DISPLAY_FIELD"] = Sql.ToDBString(ctlNewRecord.DISPLAY_FIELD); row["LIST_NAME"] = Sql.ToDBString(ctlNewRecord.LIST_NAME); // 01/20/2006 Paul. Need to duplicate the the LIST_NAME in the CACHE_NAME as the dynamic code uses CACHE_NAME. row["CACHE_NAME"] = Sql.ToDBString(ctlNewRecord.LIST_NAME); row["DATA_REQUIRED"] = Sql.ToDBBoolean(ctlNewRecord.DATA_REQUIRED); row["UI_REQUIRED"] = Sql.ToDBBoolean(ctlNewRecord.UI_REQUIRED); row["ONCLICK_SCRIPT"] = Sql.ToDBString(ctlNewRecord.ONCLICK_SCRIPT); row["FORMAT_SCRIPT"] = Sql.ToDBString(ctlNewRecord.FORMAT_SCRIPT); row["FORMAT_TAB_INDEX"] = Sql.ToDBInteger(ctlNewRecord.FORMAT_TAB_INDEX); row["FORMAT_MAX_LENGTH"] = Sql.ToDBInteger(ctlNewRecord.FORMAT_MAX_LENGTH); row["FORMAT_SIZE"] = Sql.ToDBInteger(ctlNewRecord.FORMAT_SIZE); row["FORMAT_ROWS"] = Sql.ToDBInteger(ctlNewRecord.FORMAT_ROWS); row["FORMAT_COLUMNS"] = Sql.ToDBInteger(ctlNewRecord.FORMAT_COLUMNS); row["COLSPAN"] = Sql.ToDBInteger(ctlNewRecord.COLSPAN); row["ROWSPAN"] = Sql.ToDBInteger(ctlNewRecord.ROWSPAN); } ViewState["dtFields"] = dtFields; LayoutView_Bind(dtFields); if (ctlNewRecord != null) { ctlNewRecord.Clear(); } } } else if (e.CommandName == "Defaults") { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwEDITVIEWS_FIELDS " + ControlChars.CrLf + " where EDIT_NAME = @EDIT_NAME " + ControlChars.CrLf + " and DEFAULT_VIEW = 1 " + ControlChars.CrLf + " order by " + LayoutIndexName() + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@EDIT_NAME", Sql.ToString(ViewState["LAYOUT_VIEW_NAME"])); using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; //dtFields = new DataTable(); // 01/09/2006 Paul. Mark existing records for deletion. // This is so that the save operation can update only records that have changed. foreach (DataRow row in dtFields.Rows) { row["DELETED"] = 1; } da.Fill(dtFields); // 01/09/2006 Paul. We need to change the IDs for two reasons, one is to prevent updating the Default Values, // the second reason is that we need the row to get a Modified state. Otherwise the update loop will skip it. foreach (DataRow row in dtFields.Rows) { if (Sql.ToInteger(row["DELETED"]) == 0) { row["ID"] = Guid.NewGuid(); } } } } } ViewState["dtFields"] = dtFields; LayoutView_Bind(dtFields); if (ctlNewRecord != null) { ctlNewRecord.Clear(); } } else { base.Page_Command(sender, e); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlLayoutButtons.ErrorText = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { try { gID = Sql.ToGuid(Request["ID"]); if (!IsPostBack) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwINBOUND_EMAILS_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("vwINBOUND_EMAILS_Edit", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { string sSERVER_URL = Sql.ToString(rdr["SERVER_URL"]); string sEMAIL_USER = Sql.ToString(rdr["EMAIL_USER"]); string sEMAIL_PASSWORD = Sql.ToString(rdr["EMAIL_PASSWORD"]); int nPORT = Sql.ToInteger(rdr["PORT"]); string sSERVICE = Sql.ToString(rdr["SERVICE"]); bool bMAILBOX_SSL = Sql.ToBoolean(rdr["MAILBOX_SSL"]); ViewState["SERVER_URL"] = sSERVER_URL; ViewState["EMAIL_USER"] = sEMAIL_USER; ViewState["EMAIL_PASSWORD"] = sEMAIL_PASSWORD; ViewState["PORT"] = nPORT; ViewState["SERVICE"] = sSERVICE; ViewState["MAILBOX_SSL"] = bMAILBOX_SSL; } } } } } else { if (ViewState["Inbox"] != null) { dtMain = ViewState["Inbox"] as DataTable; } } } 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(".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) { Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; // 02/09/2006 Paul. SugarCRM uses the CONTACTS_USERS table to allow each user to // choose the contacts they want sync'd with Outlook. // 02/09/2006 Paul. Need to allow SYNC_USER_ID to be NULL, // otherwise we will not get any results if the contact is not sync'd. // 03/06/2006 Paul. The join to CONTACTS_USERS must occur external to the view. // This is the only way to ensure that the record is always returned, with the sync flag set. // 04/23/2006 Paul. Bug fix. vwCONTACTS_USERS does not have an ID, use CONTACT_ID instead. sSQL = "select vwCONTACTS_Edit.* " + ControlChars.CrLf + " , (case when vwCONTACTS_USERS.CONTACT_ID is null then 0 else 1 end) as SYNC_CONTACT" + ControlChars.CrLf + " from vwCONTACTS_Edit " + ControlChars.CrLf + " left outer join vwCONTACTS_USERS " + ControlChars.CrLf + " on vwCONTACTS_USERS.CONTACT_ID = vwCONTACTS_Edit.ID " + ControlChars.CrLf + " and vwCONTACTS_USERS.USER_ID = @SYNC_USER_ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@SYNC_USER_ID", Security.USER_ID); // 11/24/2006 Paul. Use new Security.Filter() function to apply Team and ACL security rules. Security.Filter(cmd, m_sMODULE, "edit"); cmd.CommandText += " and vwCONTACTS_Edit.ID = @ID" + ControlChars.CrLf; 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 = Sql.ToString(rdr["SALUTATION"]) + " " + Sql.ToString(rdr["FIRST_NAME"]) + " " + Sql.ToString(rdr["LAST_NAME"]); SetPageTitle(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); this.AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, rdr); this.AppendEditViewFields(m_sMODULE + ".EditDescription", tblDescription, rdr); } else { // 11/25/2006 Paul. If item is not visible, then don't allow save ctlEditButtons.DisableAll(); ctlEditButtons.ErrorText = L10n.Term("ACL.LBL_NO_ACCESS"); } } } } } else { this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); this.AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, null); this.AppendEditViewFields(m_sMODULE + ".EditDescription", tblDescription, null); // 03/27/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") { new DynamicControl(this, "ACCOUNT_ID").ID = gPARENT_ID; new DynamicControl(this, "ACCOUNT_NAME").Text = sPARENT_NAME; // 12/31/2007 Paul. spacecowboy suggested that we prepopulate the address fields from the account. DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwACCOUNTS_Edit" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Security.Filter(cmd, "Accounts", "view"); Sql.AppendParameter(cmd, gPARENT_ID, "ID", false); con.Open(); if (bDebug) { RegisterClientScriptBlock("vwACCOUNTS_Edit", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { new DynamicControl(this, "PRIMARY_ADDRESS_STREET").Text = Sql.ToString(rdr["BILLING_ADDRESS_STREET"]); new DynamicControl(this, "PRIMARY_ADDRESS_CITY").Text = Sql.ToString(rdr["BILLING_ADDRESS_CITY"]); new DynamicControl(this, "PRIMARY_ADDRESS_STATE").Text = Sql.ToString(rdr["BILLING_ADDRESS_STATE"]); new DynamicControl(this, "PRIMARY_ADDRESS_POSTALCODE").Text = Sql.ToString(rdr["BILLING_ADDRESS_POSTALCODE"]); new DynamicControl(this, "PRIMARY_ADDRESS_COUNTRY").Text = Sql.ToString(rdr["BILLING_ADDRESS_COUNTRY"]); } } } } } // 06/09/2006 Paul. If the parent is a contact, then that becomes the Reports To. // This is a bug that exists in SugarCRM 4.2. else if (!Sql.IsEmptyGuid(gPARENT_ID) && sMODULE == "Contacts") { new DynamicControl(this, "REPORTS_TO_ID").ID = gPARENT_ID; new DynamicControl(this, "REPORTS_TO_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"]); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = 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) { Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; // 08/10/2006 Paul. Need to filter on ID, not 1 = 1. sSQL = "select * " + ControlChars.CrLf + " from vwPRODUCTS_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); this.AppendEditViewFields(m_sMODULE + ".CostView", tblCost, rdr); this.AppendEditViewFields(m_sMODULE + ".MftView", tblManufacturer, rdr); // 07/05/2006 Paul. The Product Name should be editable. TextBox txtNAME = FindControl("NAME") as TextBox; if (txtNAME != null) { txtNAME.ReadOnly = false; } } } } } } else { this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); this.AppendEditViewFields(m_sMODULE + ".CostView", tblCost, null); this.AppendEditViewFields(m_sMODULE + ".MftView", tblManufacturer, null); // 07/05/2006 Paul. The Product Name should be editable. TextBox txtNAME = FindControl("NAME") as TextBox; if (txtNAME != null) { txtNAME.ReadOnly = false; } // 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") { new DynamicControl(this, "ACCOUNT_ID").ID = gPARENT_ID; new DynamicControl(this, "ACCOUNT_NAME").Text = sPARENT_NAME; } else if (!Sql.IsEmptyGuid(gPARENT_ID) && sMODULE == "Contacts") { new DynamicControl(this, "CONTACT_ID").ID = gPARENT_ID; new DynamicControl(this, "CONTACT_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); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlEditButtons.ErrorText = ex.Message; } }
public void AddParameter(string name, object value) { name = name.TrimStart('@').ToLower(); Sql.AddParameter("@" + name, ColumnType[name], value); }
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; } }
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 (bDebug) { RegisterClientScriptBlock("vwINVITEES", Sql.ClientScriptBlock(cmd)); } 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 (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); 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 // 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); lblError.Text = ex.Message; } } } }
private void Page_Load(object sender, System.EventArgs e) { // 01/24/2006 Paul. Only a developer/administrator should see this. //if ( !SplendidCRM.Security.IS_ADMIN || Request.ServerVariables["SERVER_NAME"] != "localhost" ) // 01/27/2006 Paul. Just require admin. if (!SplendidCRM.Security.IS_ADMIN) { return; } try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbCommand cmd = con.CreateCommand()) { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; string sSQL; string sNAME = Sql.ToString(Request.QueryString["NAME"]); if (Sql.IsEmptyString(sNAME)) { sSQL = "select * " + ControlChars.CrLf + " from vwGRIDVIEWS" + ControlChars.CrLf + " order by NAME " + ControlChars.CrLf; cmd.CommandText = sSQL; using (SqlDataReader rdr = (SqlDataReader)cmd.ExecuteReader()) { Response.Write("<html><body><h1>GridViews</h1>"); while (rdr.Read()) { Response.Write("<a href=\"GridViews.aspx?NAME=" + rdr.GetString(rdr.GetOrdinal("NAME")) + "\">" + rdr.GetString(rdr.GetOrdinal("NAME")) + "</a><br>" + ControlChars.CrLf); } Response.Write("</body></html>"); } } else { Response.ContentType = "text/xml"; Response.AddHeader("Content-Disposition", "attachment;filename=" + sNAME + ".Mapping.xml"); XmlDocument xml = new XmlDocument(); xml.AppendChild(xml.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"")); xml.AppendChild(xml.CreateElement("SplendidTest.Dictionary")); XmlAttribute aName = xml.CreateAttribute("Name"); aName.Value = sNAME + ".Mapping.xml"; xml.DocumentElement.Attributes.Append(aName); sSQL = "select DATA_FIELD " + ControlChars.CrLf + " , URL_FIELD " + ControlChars.CrLf + " from vwGRIDVIEWS_COLUMNS " + ControlChars.CrLf + " where GRID_NAME = @GRID_NAME" + ControlChars.CrLf + " and DEFAULT_VIEW = 0 " + ControlChars.CrLf + " and DATA_FIELD is not null " + ControlChars.CrLf + " order by COLUMN_INDEX " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@GRID_NAME", sNAME); using (SqlDataReader rdr = (SqlDataReader)cmd.ExecuteReader()) { while (rdr.Read()) { string sDATA_FIELD = rdr.GetString(rdr.GetOrdinal("DATA_FIELD")); Utils.AppendDictionaryEntry(xml, sDATA_FIELD, "ctlListView_" + sDATA_FIELD); if (!rdr.IsDBNull(rdr.GetOrdinal("URL_FIELD"))) { string sURL_FIELD = rdr.GetString(rdr.GetOrdinal("URL_FIELD")); if (sDATA_FIELD != sURL_FIELD) { Utils.AppendDictionaryEntry(xml, sURL_FIELD, "ctlListView_" + sURL_FIELD); } } } } StringBuilder sb = new StringBuilder(); if (xml != null && xml.DocumentElement != null) { XmlUtil.Dump(ref sb, "", xml.DocumentElement); } Response.Write(sb.ToString()); } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); Response.Write(ex.Message + ControlChars.CrLf); } }
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) { 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 vwPROJECTS_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); } } } } } else { this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); } } 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; } }
public void BindGrid() { // 12/07/2006 Paul. We need to be able to force the grid to be rebound when its data has changed. Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; if (!Sql.IsEmptyGuid(gUSER_ID)) { sSQL = "select MODULE_NAME " + ControlChars.CrLf + " , DISPLAY_NAME " + ControlChars.CrLf + " , ACLACCESS_ADMIN " + ControlChars.CrLf + " , ACLACCESS_ACCESS " + ControlChars.CrLf + " , ACLACCESS_VIEW " + ControlChars.CrLf + " , ACLACCESS_LIST " + ControlChars.CrLf + " , ACLACCESS_EDIT " + ControlChars.CrLf + " , ACLACCESS_DELETE " + ControlChars.CrLf + " , ACLACCESS_IMPORT " + ControlChars.CrLf + " , ACLACCESS_EXPORT " + ControlChars.CrLf + " from vwACL_ACCESS_ByUser " + ControlChars.CrLf + " where USER_ID = @USER_ID " + ControlChars.CrLf + " order by MODULE_NAME " + ControlChars.CrLf; } else if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { sSQL = "select MODULE_NAME " + ControlChars.CrLf + " , DISPLAY_NAME " + ControlChars.CrLf + " , ACLACCESS_ADMIN " + ControlChars.CrLf + " , ACLACCESS_ACCESS " + ControlChars.CrLf + " , ACLACCESS_VIEW " + ControlChars.CrLf + " , ACLACCESS_LIST " + ControlChars.CrLf + " , ACLACCESS_EDIT " + ControlChars.CrLf + " , ACLACCESS_DELETE " + ControlChars.CrLf + " , ACLACCESS_IMPORT " + ControlChars.CrLf + " , ACLACCESS_EXPORT " + ControlChars.CrLf + " from vwACL_ACCESS_ByRole " + ControlChars.CrLf + " where ROLE_ID = @ROLE_ID " + ControlChars.CrLf + " order by MODULE_NAME " + ControlChars.CrLf; } else { sSQL = "select MODULE_NAME " + ControlChars.CrLf + " , DISPLAY_NAME " + ControlChars.CrLf + " , ACLACCESS_ADMIN " + ControlChars.CrLf + " , ACLACCESS_ACCESS " + ControlChars.CrLf + " , ACLACCESS_VIEW " + ControlChars.CrLf + " , ACLACCESS_LIST " + ControlChars.CrLf + " , ACLACCESS_EDIT " + ControlChars.CrLf + " , ACLACCESS_DELETE " + ControlChars.CrLf + " , ACLACCESS_IMPORT " + ControlChars.CrLf + " , ACLACCESS_EXPORT " + ControlChars.CrLf + " from vwACL_ACCESS_ByModule" + ControlChars.CrLf + " order by MODULE_NAME " + ControlChars.CrLf; } using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; if (!Sql.IsEmptyGuid(gUSER_ID)) { Sql.AddParameter(cmd, "@USER_ID", gUSER_ID); gID = Guid.Empty; } else if (!Sql.IsEmptyGuid(gDuplicateID)) { Sql.AddParameter(cmd, "@ROLE_ID", gDuplicateID); gID = Guid.Empty; } else if (!Sql.IsEmptyGuid(gID)) { Sql.AddParameter(cmd, "@ROLE_ID", gID); } 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; grdACL.DataSource = vwMain; // 04/26/2006 Paul. Normally, we would only bind if not a postback, // but the ACL grid knows how to handle the postback state, so we must always bind. grdACL.DataBind(); } } } } }
protected void BindGrid() { plcWeekRows.Controls.Clear(); try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; DataTable dtUsers = new DataTable(); DateTime dtDATE_START = new DateTime(Math.Max(1753, dtCurrentWeek.Year), dtCurrentWeek.Month, dtCurrentWeek.Day, 0, 0, 0); DateTime dtDATE_END = dtDATE_START.AddDays(7); sSQL = "select distinct " + ControlChars.CrLf + " ASSIGNED_USER_ID " + ControlChars.CrLf + " , ASSIGNED_FULL_NAME " + ControlChars.CrLf + " from vwACTIVITIES_List " + ControlChars.CrLf + " where ( 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; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@DATE_START", dtDATE_START); Sql.AddParameter(cmd, "@DATE_END", dtDATE_END); Sql.AppendGuids(cmd, lstUSERS, "ASSIGNED_USER_ID"); cmd.CommandText += " order by ASSIGNED_FULL_NAME" + ControlChars.CrLf; #if DEBUG Page.RegisterClientScriptBlock("vwACTIVITIES_List.Users", Sql.ClientScriptBlock(cmd)); #endif using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; da.Fill(dtUsers); } } sSQL = "select * " + ControlChars.CrLf + " from vwACTIVITIES_List " + ControlChars.CrLf + " where ( 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; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@DATE_START", dtDATE_START); Sql.AddParameter(cmd, "@DATE_END", dtDATE_END); Sql.AppendGuids(cmd, lstUSERS, "ASSIGNED_USER_ID"); cmd.CommandText += " order by ASSIGNED_FULL_NAME asc, DATE_START asc, NAME asc" + ControlChars.CrLf; #if DEBUG Page.RegisterClientScriptBlock("vwACTIVITIES_List.Data", Sql.ClientScriptBlock(cmd)); #endif 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; } } foreach (DataRow rowUser in dtUsers.Rows) { Guid gASSIGNED_USER_ID = Sql.ToGuid(rowUser["ASSIGNED_USER_ID"]); string sASSIGNED_FULL_NAME = Sql.ToString(rowUser["ASSIGNED_FULL_NAME"]); HtmlGenericControl h5User = new HtmlGenericControl("h5"); h5User.Attributes.Add("class", "calSharedUser"); h5User.Controls.Add(new LiteralControl(sASSIGNED_FULL_NAME)); plcWeekRows.Controls.Add(h5User); HtmlTable tblUserWeek = new HtmlTable(); plcWeekRows.Controls.Add(tblUserWeek); tblUserWeek.Border = 0; tblUserWeek.CellPadding = 0; tblUserWeek.CellSpacing = 1; tblUserWeek.Width = "100%"; HtmlTableRow tr = new HtmlTableRow(); tblUserWeek.Rows.Add(tr); CultureInfo ciEnglish = CultureInfo.CreateSpecificCulture("en-US"); for (int iDay = 0; iDay < 7; iDay++) { DataView vwMain = new DataView(dt); DateTime dtDAY_START = dtCurrentWeek; dtDAY_START = dtDAY_START.AddDays(iDay); DateTime dtDAY_END = dtDAY_START.AddDays(1); HtmlTableCell cell = new HtmlTableCell(); tr.Cells.Add(cell); cell.Width = "14%"; cell.VAlign = "top"; cell.Attributes.Add("class", "dailyCalBodyItems"); cell.Controls.Add(new LiteralControl(dtDAY_START.ToString("ddd d"))); // 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. // 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 sDAY_START = dtDAY_START.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat); string sDAY_END = dtDAY_END.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat); vwMain.RowFilter = "ASSIGNED_USER_ID = '" + gASSIGNED_USER_ID.ToString() + "'" + ControlChars.CrLf + "and ( DATE_START >= #" + sDAY_START + "# and DATE_START < #" + sDAY_END + "#" + ControlChars.CrLf + " or DATE_END >= #" + sDAY_START + "# and DATE_END <= #" + sDAY_END + "#" + ControlChars.CrLf + " or DATE_START < #" + sDAY_START + "# and DATE_END > #" + sDAY_END + "#" + ControlChars.CrLf + " )" + ControlChars.CrLf; #if DEBUG // Page.RegisterClientScriptBlock("vwACTIVITIES_List" + dtDAY_START.ToOADate().ToString(), Sql.EscapeJavaScript(vwMain.RowFilter)); #endif if (vwMain.Count > 0) { SharedCell ctlSharedCell = LoadControl("SharedCell.ascx") as SharedCell; ctlSharedCell.DataSource = vwMain; cell.Controls.Add(ctlSharedCell); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } } } } 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("ProductCategories.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"]); reqLIST_ORDER.DataBind(); if (!IsPostBack) { 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 vwPRODUCT_CATEGORIES" + 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("ProductCategories.LBL_NAME") + " " + txtNAME.Text; txtPARENT_ID.Value = Sql.ToString(rdr["PARENT_ID"]); txtPARENT_NAME.Text = Sql.ToString(rdr["PARENT_NAME"]); txtDESCRIPTION.Text = Sql.ToString(rdr["DESCRIPTION"]); txtLIST_ORDER.Text = Sql.ToString(rdr["LIST_ORDER"]); } } } } } } } 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(".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. // 07/11/2006 Paul. Users must be able to view and edit their own settings. this.Visible = bMyAccount || SplendidCRM.Security.IS_ADMIN; //(SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!this.Visible) { return; } reqUSER_NAME.DataBind(); reqLAST_NAME.DataBind(); 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 (bMyAccount) { gID = Security.USER_ID; } // 07/12/2006 Paul. Status can only be edited by an administrator. lstSTATUS.Enabled = false; // 12/06/2005 Paul. A user can only edit his own user name if Windows Authentication is off. if (Security.IS_ADMIN) { // 12/06/2005 Paul. An administrator can always edit the user name. This is to allow him to pre-add any NTLM users. txtUSER_NAME.Enabled = true; lstSTATUS.Enabled = true; } else if (gID == Security.USER_ID) { // 12/06/2005 Paul. If editing yourself, then you can only edit if not NTLM. // txtUSER_NAME.Enabled = !Security.IsWindowsAuthentication(); // 11/26/2006 Paul. A user cannot edit their own user name. This is a job for the admin. txtUSER_NAME.Enabled = false; } else { // 12/06/2005 Paul. If not an administrator and not editing yourself, then the name cannot be edited. txtUSER_NAME.Enabled = false; } if (!IsPostBack) { // 'date_formats' => array('Y-m-d'=>'2006-12-23', 'm-d-Y'=>'12-23-2006', 'Y/m/d'=>'2006/12/23', 'm/d/Y'=>'12/23/2006') // 'time_formats' => array('H:i'=>'23:00', 'h:ia'=>'11:00pm', 'h:iA'=>'11:00PM', 'H.i'=>'23.00', 'h.ia'=>'11.00pm', 'h.iA'=>'11.00PM' ) lstSTATUS.DataSource = SplendidCache.List("user_status_dom"); lstSTATUS.DataBind(); // 08/05/2006 Paul. Remove stub of unsupported code. Reminder is not supported at this time. //lstREMINDER_TIME .DataSource = SplendidCache.List("reminder_time_dom"); //lstREMINDER_TIME .DataBind(); lstTIMEZONE.DataSource = SplendidCache.TimezonesListbox(); lstTIMEZONE.DataBind(); lstCURRENCY.DataSource = SplendidCache.Currencies(); lstCURRENCY.DataBind(); // 05/09/2006 Paul. We need to always initialize the separators, just in case the user is new. txtGROUP_SEPARATOR.Text = SplendidDefaults.GroupSeparator(); txtDECIMAL_SEPARATOR.Text = SplendidDefaults.DecimalSeparator(); lstLANGUAGE.DataSource = SplendidCache.Languages(); lstLANGUAGE.DataBind(); lstLANGUAGE_Changed(null, null); lstTHEME.DataSource = SplendidCache.Themes(); lstTHEME.DataBind(); 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 vwUSERS_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 (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = Sql.ToString(rdr["FULL_NAME"]); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title + " (" + Sql.ToString(rdr["USER_NAME"]) + ")"); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); this.AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, rdr); // 08/05/2006 Paul. Use the dynamic grid to create the fields, but populate manually. this.AppendEditViewFields(m_sMODULE + ".EditMailOptions", tblMailOptions, null); // 01/20/2008 Paul. The mail options panel is manually populated. new DynamicControl(this, "EMAIL1").Text = Sql.ToString(rdr["EMAIL1"]); new DynamicControl(this, "EMAIL2").Text = Sql.ToString(rdr["EMAIL2"]); // main txtUSER_NAME.Text = Sql.ToString(rdr["USER_NAME"]); txtFIRST_NAME.Text = Sql.ToString(rdr["FIRST_NAME"]); txtLAST_NAME.Text = Sql.ToString(rdr["LAST_NAME"]); // user_settings chkIS_ADMIN.Checked = Sql.ToBoolean(rdr["IS_ADMIN"]); chkPORTAL_ONLY.Checked = Sql.ToBoolean(rdr["PORTAL_ONLY"]); chkRECEIVE_NOTIFICATIONS.Checked = Sql.ToBoolean(rdr["RECEIVE_NOTIFICATIONS"]); // 12/04/2005 Paul. Only allow the admin flag to be changed if the current user is an admin. chkIS_ADMIN.Enabled = Security.IS_ADMIN; // 12/04/2005 Paul. Save admin flag in ViewState to prevent hacking. ViewState["IS_ADMIN"] = Sql.ToBoolean(rdr["IS_ADMIN"]); try { lstSTATUS.SelectedValue = Sql.ToString(rdr["STATUS"]); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } string sUSER_PREFERENCES = Sql.ToString(rdr["USER_PREFERENCES"]); if (!Sql.IsEmptyString(sUSER_PREFERENCES)) { XmlDocument xml = SplendidInit.InitUserPreferences(sUSER_PREFERENCES); try { ViewState["USER_PREFERENCES"] = xml.OuterXml; // user_settings chkGRIDLINE.Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "gridline")); try { lstLANGUAGE.SelectedValue = L10N.NormalizeCulture(XmlUtil.SelectSingleNode(xml, "culture")); lstLANGUAGE_Changed(null, null); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } try { lstLANGUAGE.SelectedValue = XmlUtil.SelectSingleNode(xml, "theme"); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } try { lstDATE_FORMAT.SelectedValue = XmlUtil.SelectSingleNode(xml, "dateformat"); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } try { lstTIME_FORMAT.SelectedValue = XmlUtil.SelectSingleNode(xml, "timeformat"); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } try { lstTIMEZONE.SelectedValue = XmlUtil.SelectSingleNode(xml, "timezone"); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } try { lstCURRENCY.SelectedValue = XmlUtil.SelectSingleNode(xml, "currency_id"); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } // mail_options new DynamicControl(this, "MAIL_FROMNAME").Text = XmlUtil.SelectSingleNode(xml, "mail_fromname"); new DynamicControl(this, "MAIL_FROMADDRESS").Text = XmlUtil.SelectSingleNode(xml, "mail_fromaddress"); new DynamicControl(this, "MAIL_SENDTYPE").Text = XmlUtil.SelectSingleNode(xml, "mail_sendtype"); new DynamicControl(this, "MAIL_SMTPSERVER").Text = XmlUtil.SelectSingleNode(xml, "mail_smtpserver"); new DynamicControl(this, "MAIL_SMTPPORT").Text = XmlUtil.SelectSingleNode(xml, "mail_smtpport"); new DynamicControl(this, "MAIL_SMTPAUTH_REQ").Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "mail_smtpauth_req")); new DynamicControl(this, "MAIL_SMTPUSER").Text = XmlUtil.SelectSingleNode(xml, "mail_smtpuser"); new DynamicControl(this, "MAIL_SMTPPASS").Text = XmlUtil.SelectSingleNode(xml, "mail_smtppass"); ViewState["mail_smtppass"] = XmlUtil.SelectSingleNode(xml, "mail_smtppass"); // 08/06/2005 Paul. Never return password to user. TextBox txtMAIL_SMTPPASS = FindControl("MAIL_SMTPPASS") as TextBox; if (txtMAIL_SMTPPASS != null) { if (!Sql.IsEmptyString(txtMAIL_SMTPPASS.Text)) { txtMAIL_SMTPPASS.Text = sEMPTY_PASSWORD; } } // 05/09/2006 Paul. Initialize the numeric separators. txtGROUP_SEPARATOR.Text = XmlUtil.SelectSingleNode(xml, "num_grp_sep"); txtDECIMAL_SEPARATOR.Text = XmlUtil.SelectSingleNode(xml, "dec_sep"); // 05/09/2006 Paul. Check for empty strings as the user may have legacy data. if (Sql.IsEmptyString(txtGROUP_SEPARATOR.Text)) { txtGROUP_SEPARATOR.Text = SplendidDefaults.GroupSeparator(); } if (Sql.IsEmptyString(txtDECIMAL_SEPARATOR.Text)) { txtDECIMAL_SEPARATOR.Text = SplendidDefaults.DecimalSeparator(); } // freebusy // 08/05/2006 Paul. Remove stub of unsupported code. Calendar Publish Key is not supported at this time. //txtCALENDAR_PUBLISH_KEY .Text = XmlUtil.SelectSingleNode(xml, "calendar_publish_key" ); //txtCALENDAR_PUBLISH_URL .Text = XmlUtil.SelectSingleNode(xml, "calendar_publish_url" ); //txtCALENDAR_SEARCH_URL .Text = XmlUtil.SelectSingleNode(xml, "calendar_search_url" ); // 08/05/2006 Paul. Remove stub of unsupported code. Reminder is not supported at this time. /* * try * { * int nREMINDER_TIME = Sql.ToInteger(XmlUtil.SelectSingleNode(xml, "reminder_time")); * if ( nREMINDER_TIME > 0 ) * { * lstREMINDER_TIME.SelectedValue = nREMINDER_TIME.ToString(); * chkSHOULD_REMIND.Checked = true; * } * } * catch(Exception ex) * { * SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); * } */ } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); } } } } } } } else { this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); this.AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, null); this.AppendEditViewFields(m_sMODULE + ".EditMailOptions", tblMailOptions, null); try { lstTHEME.SelectedValue = SplendidDefaults.Theme(); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } try { string sDefaultLanguage = Sql.ToString(Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"]); if (Sql.IsEmptyString(sDefaultLanguage)) { sDefaultLanguage = "en-US"; } lstLANGUAGE.SelectedValue = sDefaultLanguage; } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } lstLANGUAGE_Changed(null, null); } } 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"]); 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 BindGrid() { plcWeekRows.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, dtCurrentWeek.Year), dtCurrentWeek.Month, dtCurrentWeek.Day, 0, 0, 0); DateTime dtDATE_END = dtDATE_START.AddDays(7); // 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; } } CultureInfo ciEnglish = CultureInfo.CreateSpecificCulture("en-US"); for (int iDay = 0; iDay < 7; iDay++) { DataView vwMain = new DataView(dt); DateTime dtDAY_START = dtCurrentWeek; dtDAY_START = dtDAY_START.AddDays(iDay); DateTime dtDAY_END = dtDAY_START.AddDays(1); // 03/19/2007 Paul. Need to query activities based on server time. DateTime dtDAY_START_ServerTime = T10n.ToServerTime(dtDAY_START); DateTime dtDAY_END_ServerTime = T10n.ToServerTime(dtDAY_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. // 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 sDAY_START_ServerTime = dtDAY_START_ServerTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat); string sDAY_END_ServerTime = dtDAY_END_ServerTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat); vwMain.RowFilter = " DATE_START >= #" + sDAY_START_ServerTime + "# and DATE_START < #" + sDAY_END_ServerTime + "#" + ControlChars.CrLf + "or DATE_END > #" + sDAY_START_ServerTime + "# and DATE_END <= #" + sDAY_END_ServerTime + "#" + ControlChars.CrLf + "or DATE_START < #" + sDAY_START_ServerTime + "# and DATE_END > #" + sDAY_END_ServerTime + "#" + ControlChars.CrLf; #if DEBUG // RegisterClientScriptBlock("vwACTIVITIES_List" + dtDAY_START.ToOADate().ToString(), Sql.EscapeJavaScript(vwMain.RowFilter)); #endif WeekRow ctlWeekRow = LoadControl("WeekRow.ascx") as WeekRow; // 06/09/2006 Paul. Add to controls list before bindging. plcWeekRows.Controls.Add(ctlWeekRow); ctlWeekRow.DATE_START = dtDAY_START; //ctlWeekRow.DATE_END = dtDAY_END; ctlWeekRow.DataSource = vwMain; // 06/09/2006 Paul. Need to bind after specifying the data source. ctlWeekRow.DataBind(); //ctlWeekRow.DATE_START = new DateTime(dtCurrentDate.Year, dtCurrentDate.Month, dtCurrentDate.Day, iHour, 0, 0); //ctlWeekRow.DATE_END = ctlWeekRow.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; } }
private void Page_Load(object sender, System.EventArgs e) { // 01/11/2006 Paul. Only a developer/administrator should see this. if (!SplendidCRM.Security.IS_ADMIN || Request.ServerVariables["SERVER_NAME"] != "localhost") { return; } try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbCommand cmd = con.CreateCommand()) { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; string sSQL; string sLANG = Sql.ToString(Request.QueryString["Lang"]); if (Sql.IsEmptyString(sLANG)) { sSQL = "select * " + ControlChars.CrLf + " from vwLANGUAGES" + ControlChars.CrLf + " order by NAME " + ControlChars.CrLf; cmd.CommandText = sSQL; using (SqlDataReader rdr = (SqlDataReader)cmd.ExecuteReader()) { Response.Write("<html><body><h1>Terminology</h1>"); while (rdr.Read()) { Response.Write("<a href=\"Terminology.aspx?Lang=" + rdr.GetString(rdr.GetOrdinal("NAME")) + "\">" + rdr.GetString(rdr.GetOrdinal("DISPLAY_NAME")) + "</a><br>" + ControlChars.CrLf); } Response.Write("</body></html>"); } } else { Response.ContentType = "text/sql"; Response.AddHeader("Content-Disposition", "attachment;filename=TERMINOLOGY " + sLANG + ".2.sql"); if (Sql.IsOracle(cmd)) { Response.Write("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS';" + ControlChars.CrLf); Response.Write("BEGIN" + ControlChars.CrLf); } else { Response.Write("/* -- #if IBM_DB2" + ControlChars.CrLf); Response.Write("call dbo.spSqlDropProcedure('spTERMINOLOGY_Defaults')" + ControlChars.CrLf); Response.Write("/" + ControlChars.CrLf); Response.Write("" + ControlChars.CrLf); Response.Write("Create Procedure dbo.spTERMINOLOGY_Defaults()" + ControlChars.CrLf); Response.Write("language sql" + ControlChars.CrLf); Response.Write(" begin" + ControlChars.CrLf); Response.Write("-- #endif IBM_DB2 */" + ControlChars.CrLf); Response.Write("" + ControlChars.CrLf); Response.Write("/* -- #if Oracle" + ControlChars.CrLf); Response.Write("BEGIN" + ControlChars.CrLf); Response.Write("-- #endif Oracle */" + ControlChars.CrLf); Response.Write("print 'TERMINOLOGY " + sLANG + "';" + ControlChars.CrLf); Response.Write("GO" + ControlChars.CrLf); Response.Write(ControlChars.CrLf); Response.Write("set nocount on;" + ControlChars.CrLf); Response.Write("GO" + ControlChars.CrLf); Response.Write(ControlChars.CrLf); } sSQL = "select NAME " + ControlChars.CrLf + " , LCID " + ControlChars.CrLf + " , ACTIVE " + ControlChars.CrLf + " , NATIVE_NAME " + ControlChars.CrLf + " , DISPLAY_NAME " + ControlChars.CrLf + " from LANGUAGES " + ControlChars.CrLf + " where lower(NAME) = @NAME" + ControlChars.CrLf; cmd.CommandText = sSQL; // 03/06/2006 Paul. Oracle is case sensitive, and we modify the case of L10n.NAME to be lower. Sql.AddParameter(cmd, "@NAME", sLANG.ToLower()); DumpTerminology(cmd, "spLANGUAGES_InsertOnly", sLANG.Length); sSQL = "select max(len(NAME)) " + ControlChars.CrLf + " from TERMINOLOGY " + ControlChars.CrLf + " where lower(LANG) = @LANG" + ControlChars.CrLf; cmd.CommandText = sSQL; cmd.Parameters.Clear(); // 03/06/2006 Paul. Oracle is case sensitive, and we modify the case of L10n.NAME to be lower. Sql.AddParameter(cmd, "@LANG", sLANG.ToLower()); int nNAME_MaxLength = Sql.ToInteger(cmd.ExecuteScalar()) + 2; sSQL = "select NAME " + ControlChars.CrLf + " , LANG " + ControlChars.CrLf + " , MODULE_NAME " + ControlChars.CrLf + " , LIST_NAME " + ControlChars.CrLf + " , LIST_ORDER " + ControlChars.CrLf + " , DISPLAY_NAME " + ControlChars.CrLf + " from vwTERMINOLOGY " + ControlChars.CrLf + " where lower(LANG) = @LANG " + ControlChars.CrLf + " order by LANG, MODULE_NAME, LIST_NAME, LIST_ORDER, NAME" + ControlChars.CrLf; cmd.CommandText = sSQL; cmd.Parameters.Clear(); // 03/06/2006 Paul. Oracle is case sensitive, and we modify the case of L10n.NAME to be lower. Sql.AddParameter(cmd, "@LANG", sLANG.ToLower()); DumpTerminology(cmd, "spTERMINOLOGY_InsertOnly", nNAME_MaxLength); Response.Write(ControlChars.CrLf); Response.Write("set nocount off;" + ControlChars.CrLf); Response.Write("GO" + ControlChars.CrLf); Response.Write(ControlChars.CrLf); if (Sql.IsOracle(cmd)) { Response.Write(" COMMIT WORK;"+ ControlChars.CrLf); Response.Write("END;" + ControlChars.CrLf); Response.Write("/" + ControlChars.CrLf); } else { Response.Write("/* -- #if Oracle" + ControlChars.CrLf); Response.Write(" COMMIT WORK;"+ ControlChars.CrLf); Response.Write("END;" + ControlChars.CrLf); Response.Write("/" + ControlChars.CrLf); Response.Write("-- #endif Oracle */" + ControlChars.CrLf); Response.Write("" + ControlChars.CrLf); Response.Write("/* -- #if IBM_DB2" + ControlChars.CrLf); Response.Write(" commit;"+ ControlChars.CrLf); Response.Write(" end" + ControlChars.CrLf); Response.Write("/" + ControlChars.CrLf); Response.Write("" + ControlChars.CrLf); Response.Write("call dbo.spTERMINOLOGY_Defaults()" + ControlChars.CrLf); Response.Write("/" + ControlChars.CrLf); Response.Write("" + ControlChars.CrLf); Response.Write("call dbo.spSqlDropProcedure('spTERMINOLOGY_Defaults')" + ControlChars.CrLf); Response.Write("/" + ControlChars.CrLf); Response.Write("-- #endif IBM_DB2 */" + ControlChars.CrLf); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); Response.Write(ex.Message + ControlChars.CrLf); } }
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) { lstVariableModule.Items.Add(new ListItem(L10n.Term(".LBL_ACCOUNT"), "Accounts")); lstVariableModule.Items.Add(new ListItem(L10n.Term("EmailTemplates.LBL_CONTACT_AND_OTHERS"), "Contacts")); lstVariableModule_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 vwEMAIL_TEMPLATES_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; // 03/04/2006 Paul. Name was not being set. txtNAME.Text = Sql.ToString(rdr["NAME"]); txtDESCRIPTION.Text = Sql.ToString(rdr["DESCRIPTION"]); txtSUBJECT.Text = Sql.ToString(rdr["SUBJECT"]); // 04/21/2006 Paul. Change BODY to BODY_HTML. txtBODY.Value = Sql.ToString(rdr["BODY_HTML"]); } } } } } } 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; } }
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 + " 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; DateTime dtDATE_START = new DateTime(Math.Max(1753, dtCurrentDate.Year), dtCurrentDate.Month, dtCurrentDate.Day, 0, 0, 0); DateTime dtDATE_END = dtDATE_START.AddDays(1); Sql.AddParameter(cmd, "@ASSIGNED_USER_ID", Security.USER_ID); Sql.AddParameter(cmd, "@DATE_START", dtDATE_START); Sql.AddParameter(cmd, "@DATE_END", dtDATE_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); // 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 // Page.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.Message); lblError.Text = ex.Message; } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
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; 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"); Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false); cmd.CommandText += " and DATE_START < @DATE_START" + ControlChars.CrLf; cmd.CommandText += " order by DATE_START asc " + ControlChars.CrLf; // 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 (bDebug) { RegisterClientScriptBlock("vwACTIVITIES_MyList", Sql.ClientScriptBlock(cmd)); } 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); 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) { gID = Sql.ToGuid(Request["ID"]); Guid gCASE_ID = Sql.ToGuid(txtCASE_ID.Value); if (!Sql.IsEmptyGuid(gCASE_ID)) { try { SqlProcs.spACCOUNTS_CASES_Update(gID, gCASE_ID); Response.Redirect("view.aspx?ID=" + gID.ToString()); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } } DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwACCOUNTS_CASES " + 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. Security.Filter(cmd, m_sMODULE, "list"); cmd.CommandText += " and ACCOUNT_ID = @ACCOUNT_ID" + ControlChars.CrLf; cmd.CommandText += " order by CASE_NUMBER " + ControlChars.CrLf; Sql.AddParameter(cmd, "@ACCOUNT_ID", gID); if (bDebug) { RegisterClientScriptBlock("vwACCOUNTS_CASES", Sql.ClientScriptBlock(cmd)); } 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); 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, "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) { 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 vwCASES_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, "edit"); if (!Sql.IsEmptyGuid(gDuplicateID)) { Sql.AppendParameter(cmd, gDuplicateID, "ID", false); gID = Guid.Empty; } else { 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); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); } else { // 11/25/2006 Paul. If item is not visible, then don't allow save ctlEditButtons.DisableAll(); ctlEditButtons.ErrorText = L10n.Term("ACL.LBL_NO_ACCESS"); } } } } } else { this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); // 10/14/2006 Paul. Prepopulate the Account when created from Account or Contact. 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") { new DynamicControl(this, "ACCOUNT_ID").ID = gPARENT_ID; new DynamicControl(this, "ACCOUNT_NAME").Text = sPARENT_NAME; } else if (!Sql.IsEmptyGuid(gPARENT_ID) && sMODULE == "Contacts") { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwCONTACTS" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gPARENT_ID); con.Open(); using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { new DynamicControl(this, "ACCOUNT_ID").ID = Sql.ToGuid(rdr["ID"]); new DynamicControl(this, "ACCOUNT_NAME").Text = Sql.ToString(rdr["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"]); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = ex.Message; } }