private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { lstSALES_STAGE.DataSource = SplendidCache.List("sales_stage_dom"); lstSALES_STAGE.DataBind(); lstUSERS.DataSource = SplendidCache.ActiveUsers(); lstUSERS.DataBind(); // 09/14/2005 Paul. Default to today, and all sales stages. foreach (ListItem item in lstSALES_STAGE.Items) { item.Selected = true; } foreach (ListItem item in lstUSERS.Items) { item.Selected = true; } // 07/09/2006 Paul. The date is passed as TimeZone time, so convert from server time. ctlDATE_START.Value = T10n.FromServerTime(DateTime.Today); ctlDATE_END.Value = T10n.FromServerTime(new DateTime(2100, 1, 1)); // 09/15/2005 Paul. Maintain the pipeline query string separately so that we can respond to specific submit requests // and ignore all other control events on the page. ViewState["PipelineBySalesStageQueryString"] = PipelineQueryString(); } }
private void Page_Load(object sender, System.EventArgs e) { // 06/04/2006 Paul. NewRecord should not be displayed if the user does not have edit rights. this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!this.Visible) { return; } // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //this.DataBind(); // Need to bind so that Text of the Button gets updated. reqNAME.ErrorMessage = L10n.Term(".ERR_MISSING_REQUIRED_FIELDS") + " " + L10n.Term("Meetings.LBL_LIST_SUBJECT") + "<br>"; reqDATE_START.ErrorMessage = L10n.Term(".ERR_MISSING_REQUIRED_FIELDS") + " " + L10n.Term("Meetings.LBL_LIST_DATE") + "<br>"; reqTIME_START.ErrorMessage = L10n.Term(".ERR_MISSING_REQUIRED_FIELDS") + " " + L10n.Term("Meetings.LBL_LIST_TIME") + "<br>"; // 08/31/2006 Paul. Need to bind the text. valDATE_START.ErrorMessage = L10n.Term(".ERR_INVALID_DATE") + "<br>"; valTIME_START.ErrorMessage = L10n.Term(".ERR_INVALID_TIME") + "<br>"; if (!IsPostBack) { DateTime dt1100PM = DateTime.Today.AddHours(23); lblDATEFORMAT.Text = "(" + Session["USER_SETTINGS/DATEFORMAT"] + ")"; lblTIMEFORMAT.Text = "(" + dt1100PM.ToShortTimeString() + ")"; DateTime dtNow = T10n.FromServerTime(DateTime.Now); ctlDATE_START.Value = dtNow; txtTIME_START.Text = Sql.ToTimeString(dtNow); } }
public override void SqlSearchClause(IDbCommand cmd) { // 07/18/2006 Paul. SqlFilterMode.Contains behavior has be deprecated. It is now the same as SqlFilterMode.StartsWith. Sql.AppendParameter(cmd, txtNAME.Text, 50, Sql.SqlFilterMode.StartsWith, "NAME"); Sql.AppendParameter(cmd, txtMFT_PART_NUM.Text, 50, Sql.SqlFilterMode.StartsWith, "MFT_PART_NUM"); Sql.AppendParameter(cmd, txtVENDOR_PART_NUM.Text, 50, Sql.SqlFilterMode.StartsWith, "VENDOR_PART_NUM"); Sql.AppendParameter(cmd, txtSUPPORT_CONTACT.Text, 50, Sql.SqlFilterMode.StartsWith, "SUPPORT_CONTACT"); Sql.AppendParameter(cmd, txtWEBSITE.Text, 255, Sql.SqlFilterMode.StartsWith, "WEBSITE"); Sql.AppendParameter(cmd, txtSUPPORT_TERM.Text, 25, Sql.SqlFilterMode.StartsWith, "SUPPORT_TERM"); Sql.AppendParameter(cmd, lstTAX_CLASS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "TAX_CLASS"); Sql.AppendParameter(cmd, lstSTATUS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "STATUS"); if (!Sql.IsEmptyGuid(lstCATEGORY.SelectedValue)) { Sql.AppendParameter(cmd, Sql.ToGuid(lstCATEGORY.SelectedValue), "CATEGORY_ID"); } if (!Sql.IsEmptyGuid(lstMANUFACTURER.SelectedValue)) { Sql.AppendParameter(cmd, Sql.ToGuid(lstMANUFACTURER.SelectedValue), "MANUFACTURER_ID"); } if (!Sql.IsEmptyGuid(lstTYPE.SelectedValue)) { Sql.AppendParameter(cmd, Sql.ToGuid(lstTYPE.SelectedValue), "TYPE_ID"); } // 07/09/2006 Paul. Date is no longer converted in the DatePicker control, so convert it here to server time. Sql.AppendParameter(cmd, T10n.ToServerTime(ctlDATE_COST_PRICE.Value), "DATE_COST_PRICE"); Sql.AppendParameter(cmd, T10n.ToServerTime(ctlDATE_AVAILABLE.Value), "DATE_AVAILABLE"); }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "NewRecord") { reqNAME.Enabled = true; reqEND_DATE.Enabled = true; valEND_DATE.Enabled = true; reqNAME.Validate(); reqEND_DATE.Validate(); valEND_DATE.Validate(); if (Page.IsValid) { Guid gID = Guid.Empty; try { SqlProcs.spCAMPAIGNS_New(ref gID, txtNAME.Text, T10n.ToServerTime(ctlEND_DATE.Value), lstSTATUS.SelectedValue, lstCAMPAIGN_TYPE.SelectedValue); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } if (!Sql.IsEmptyGuid(gID)) { Response.Redirect("~/Campaigns/view.aspx?ID=" + gID.ToString()); } } } }
protected void Page_Command(object sender, CommandEventArgs e) { try { if (e.CommandName == "AdvancedSearch") { Response.Redirect("default.aspx?Advanced=1"); } else if (e.CommandName == "BasicSearch") { Response.Redirect("default.aspx?Advanced=0"); } else if (e.CommandName == "Clear") { ctlSearch.ClearForm(); Server.Transfer("default.aspx?Advanced=" + nAdvanced.ToString()); } else if (e.CommandName == "Search") { // 10/13/2005 Paul. Make sure to clear the page index prior to applying search. grdMain.CurrentPageIndex = 0; grdMain.ApplySort(); grdMain.DataBind(); } else if (e.CommandName == "MassUpdate") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { string sIDs = Utils.ValidateIDs(arrID); sIDs = Utils.FilterByACL(m_sMODULE, "edit", arrID, "DOCUMENTS"); if (!Sql.IsEmptyString(sIDs)) { // 07/09/2006 Paul. The date conversion was moved out of the MassUpdate control. SqlProcs.spDOCUMENTS_MassUpdate(sIDs, T10n.ToServerTime(ctlMassUpdate.ACTIVE_DATE), T10n.ToServerTime(ctlMassUpdate.EXP_DATE), ctlMassUpdate.CATEGORY_ID, ctlMassUpdate.SUBCATEGORY_ID, ctlMassUpdate.STATUS); Response.Redirect("default.aspx"); } } } else if (e.CommandName == "MassDelete") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { string sIDs = Utils.ValidateIDs(arrID); sIDs = Utils.FilterByACL(m_sMODULE, "delete", arrID, "DOCUMENTS"); if (!Sql.IsEmptyString(sIDs)) { SqlProcs.spDOCUMENTS_MassDelete(sIDs); Response.Redirect("default.aspx"); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
protected void Page_Command(object sender, CommandEventArgs e) { if (e.CommandName == "Save") { if (!Sql.IsEmptyString(txtNAME.Text) && Information.IsDate(e.CommandArgument)) { // 06/09/2006 Paul. Add code to create call or meeting. This code did not make the 1.0 release. dtDATE_START = Sql.ToDateTime(e.CommandArgument); if (radScheduleCall.Checked) { Guid gID = Guid.Empty; SqlProcs.spCALLS_New(ref gID, txtNAME.Text, T10n.ToServerTime(dtDATE_START)); } else if (radScheduleMeeting.Checked) { Guid gID = Guid.Empty; SqlProcs.spMEETINGS_New(ref gID, txtNAME.Text, T10n.ToServerTime(dtDATE_START)); } } } if (Command != null) { Command(this, e); } }
protected void lstLANGUAGE_Changed(Object sender, EventArgs e) { if (lstLANGUAGE.SelectedValue.Length > 0) { CultureInfo oldCulture = Thread.CurrentThread.CurrentCulture; CultureInfo oldUICulture = Thread.CurrentThread.CurrentUICulture; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lstLANGUAGE.SelectedValue); Thread.CurrentThread.CurrentUICulture = new CultureInfo(lstLANGUAGE.SelectedValue); DateTime dtNow = T10n.FromServerTime(DateTime.Now); DateTimeFormatInfo oDateInfo = Thread.CurrentThread.CurrentCulture.DateTimeFormat; NumberFormatInfo oNumberInfo = Thread.CurrentThread.CurrentCulture.NumberFormat; String[] aDateTimePatterns = oDateInfo.GetAllDateTimePatterns(); lstDATE_FORMAT.Items.Clear(); lstTIME_FORMAT.Items.Clear(); foreach (string sPattern in aDateTimePatterns) { // 11/12/2005 Paul. Only allow patterns that have a full year. if (sPattern.IndexOf("yyyy") >= 0 && sPattern.IndexOf("dd") >= 0 && sPattern.IndexOf("mm") < 0) { lstDATE_FORMAT.Items.Add(new ListItem(sPattern + " " + dtNow.ToString(sPattern), sPattern)); } if (sPattern.IndexOf("yy") < 0 && sPattern.IndexOf("mm") >= 0) { lstTIME_FORMAT.Items.Add(new ListItem(sPattern + " " + dtNow.ToString(sPattern), sPattern)); } } Thread.CurrentThread.CurrentCulture = oldCulture; Thread.CurrentThread.CurrentCulture = oldUICulture; } }
public override void SqlSearchClause(IDbCommand cmd) { Sql.AppendParameter(cmd, txtDOCUMENT_NAME.Text, 255, Sql.SqlFilterMode.StartsWith, "DOCUMENT_NAME"); Sql.AppendParameter(cmd, lstCATEGORY_ID.SelectedValue, 25, Sql.SqlFilterMode.Exact, "CATEGORY_ID"); Sql.AppendParameter(cmd, lstSUBCATEGORY_ID.SelectedValue, 25, Sql.SqlFilterMode.Exact, "SUBCATEGORY_ID"); Sql.AppendParameter(cmd, T10n.ToServerTime(Sql.ToDateTime(txtACTIVE_DATE.Text)), "ACTIVE_DATE"); Sql.AppendParameter(cmd, T10n.ToServerTime(Sql.ToDateTime(txtEXP_DATE.Text)), "EXP_DATE"); }
public override void SqlSearchClause(IDbCommand cmd) { Sql.AppendParameter(cmd, txtNAME.Text, 255, Sql.SqlFilterMode.StartsWith, "NAME"); Sql.AppendParameter(cmd, lstSTATUS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "STATUS"); Sql.AppendParameter(cmd, lstCAMPAIGN_TYPE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "CAMPAIGN_TYPE"); // 07/09/2006 Paul. Date is no longer converted in the DatePicker control, so convert it here to server time. Sql.AppendParameter(cmd, T10n.ToServerTime(ctlSTART_DATE.Value), "START_DATE"); Sql.AppendParameter(cmd, T10n.ToServerTime(ctlEND_DATE.Value), "END_DATE"); Sql.AppendGuids(cmd, lstASSIGNED_USER_ID, "ASSIGNED_USER_ID"); }
private void Page_Load(object sender, System.EventArgs e) { bool bEnableTeamManagement = Crm.Config.enable_team_management(); if (!bEnableTeamManagement) { this.Visible = false; return; } try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwTEAM_NOTICES_MyList" + ControlChars.CrLf + " inner join vwTEAM_MEMBERSHIPS " + ControlChars.CrLf + " on vwTEAM_MEMBERSHIPS.MEMBERSHIP_TEAM_ID = TEAM_ID" + ControlChars.CrLf + " and vwTEAM_MEMBERSHIPS.MEMBERSHIP_USER_ID = @MEMBERSHIP_USER_ID" + ControlChars.CrLf + " where @CURRENT_DATE between DATE_START and DATE_END" + ControlChars.CrLf + " order by DATE_START " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@MEMBERSHIP_USER_ID", Security.USER_ID); Sql.AddParameter(cmd, "@CURRENT_DATE", T10n.ToServerTime(DateTime.Now)); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); vwTeamNotices = dt.DefaultView; ctlRepeater.DataSource = vwTeamNotices; if (!IsPostBack) { ctlRepeater.DataBind(); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); } }
public override void SqlSearchClause(IDbCommand cmd) { // 07/18/2006 Paul. SqlFilterMode.Contains behavior has be deprecated. It is now the same as SqlFilterMode.StartsWith. Sql.AppendParameter(cmd, txtNAME.Text, 255, Sql.SqlFilterMode.StartsWith, "NAME"); Sql.AppendParameter(cmd, txtACCOUNT_NAME.Text, 100, Sql.SqlFilterMode.StartsWith, "ACCOUNT_NAME"); Sql.AppendParameter(cmd, lstSTATUS.SelectedValue, 25, Sql.SqlFilterMode.Exact, "STATUS"); // 07/09/2006 Paul. Date is no longer converted in the DatePicker control, so convert it here to server time. Sql.AppendParameter(cmd, T10n.ToServerTime(ctlSTART_DATE.Value), "START_DATE"); Sql.AppendParameter(cmd, T10n.ToServerTime(ctlEND_DATE.Value), "END_DATE"); Sql.AppendGuids(cmd, lstASSIGNED_USER_ID, "ASSIGNED_USER_ID"); }
protected void Page_Command(object sender, CommandEventArgs e) { try { if (e.CommandName == "Clear") { Server.Transfer("default.aspx"); } else if (e.CommandName == "TeamNotices.Delete") { Guid gID = Sql.ToGuid(e.CommandArgument); SqlProcs.spTEAM_NOTICES_Delete(gID); grdMain.CurrentPageIndex = 0; grdMain.ApplySort(); grdMain.DataBind(); Response.Redirect("default.aspx"); } else if (e.CommandName == "MassUpdate") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { string sIDs = Utils.ValidateIDs(arrID); if (!Sql.IsEmptyString(sIDs)) { SqlProcs.spTEAM_NOTICES_MassUpdate(sIDs, T10n.ToServerTime(ctlMassUpdate.DATE_START), T10n.ToServerTime(ctlMassUpdate.DATE_END)); Response.Redirect("default.aspx"); } } } else if (e.CommandName == "MassDelete") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { string sIDs = Utils.ValidateIDs(arrID); if (!Sql.IsEmptyString(sIDs)) { SqlProcs.spTEAM_NOTICES_MassDelete(sIDs); Response.Redirect("default.aspx"); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "NewRecord") { reqNAME.Enabled = true; reqDATE_START.Enabled = true; reqTIME_START.Enabled = true; valDATE_START.Enabled = true; valTIME_START.Enabled = true; reqNAME.Validate(); reqDATE_START.Validate(); reqTIME_START.Validate(); valDATE_START.Validate(); valTIME_START.Validate(); if (Page.IsValid) { Guid gID = Guid.Empty; try { // 02/28/2006 Paul. The easiest way to parse the two separate date/time fields is to combine the text. DateTime dtDATE_START = T10n.ToServerTime(Sql.ToDateTime(ctlDATE_START.DateText + " " + txtTIME_START.Text)); if (radScheduleCall.Checked) { SqlProcs.spCALLS_New(ref gID, txtNAME.Text, dtDATE_START); } else { SqlProcs.spMEETINGS_New(ref gID, txtNAME.Text, dtDATE_START); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } if (!Sql.IsEmptyGuid(gID)) { if (radScheduleCall.Checked) { Response.Redirect("~/Calls/view.aspx?ID=" + gID.ToString()); } else { Response.Redirect("~/Meetings/view.aspx?ID=" + gID.ToString()); } } } } }
public override void SqlSearchClause(IDbCommand cmd) { Sql.AppendParameter(cmd, Sql.ToInteger(txtQUOTE_NUM.Text), "QUOTE_NUM", Sql.IsEmptyString(txtQUOTE_NUM.Text)); Sql.AppendParameter(cmd, Sql.ToDecimal(txtTOTAL.Text), "TOTAL", Sql.IsEmptyString(txtTOTAL.Text)); // 07/18/2006 Paul. SqlFilterMode.Contains behavior has be deprecated. It is now the same as SqlFilterMode.StartsWith. Sql.AppendParameter(cmd, txtNAME.Text, 50, Sql.SqlFilterMode.StartsWith, "NAME"); Sql.AppendParameter(cmd, txtACCOUNT_NAME.Text, 150, Sql.SqlFilterMode.StartsWith, new string[] { "SHIPPING_ACCOUNT_NAME", "BILLING_ACCOUNT_NAME" }); Sql.AppendParameter(cmd, txtNEXT_STEP.Text, 255, Sql.SqlFilterMode.StartsWith, "NEXT_STEP"); Sql.AppendParameter(cmd, lstQUOTE_TYPE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "QUOTE_TYPE"); Sql.AppendParameter(cmd, lstLEAD_SOURCE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "LEAD_SOURCE"); Sql.AppendParameter(cmd, lstQUOTE_STAGE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "QUOTE_STAGE"); // 07/09/2006 Paul. Date is no longer converted in the DatePicker control, so convert it here to server time. Sql.AppendParameter(cmd, T10n.ToServerTime(ctlDATE_QUOTE_EXPECTED_CLOSED.Value), "DATE_QUOTE_EXPECTED_CLOSED"); Sql.AppendGuids(cmd, lstASSIGNED_USER_ID, "ASSIGNED_USER_ID"); }
public override void SqlSearchClause(IDbCommand cmd) { // 09/13/2006 Paul. Change FIRST_NAME to NAME. Sql.AppendParameter(cmd, txtNAME.Text, 25, Sql.SqlFilterMode.StartsWith, "NAME"); Sql.AppendParameter(cmd, Sql.ToDecimal(txtAMOUNT.Text), "AMOUNT", Sql.IsEmptyString(txtAMOUNT.Text)); Sql.AppendParameter(cmd, T10n.ToServerTime(Sql.ToDateTime(txtDATE_CLOSED.Text)), "DATE_CLOSED"); Sql.AppendParameter(cmd, txtNEXT_STEP.Text, 25, Sql.SqlFilterMode.StartsWith, "NEXT_STEP"); Sql.AppendParameter(cmd, txtACCOUNT_NAME.Text, 150, Sql.SqlFilterMode.StartsWith, "ACCOUNT_NAME"); // 09/01/2006 Paul. Add PROBABILITY. Sql.AppendParameter(cmd, Sql.ToFloat(txtPROBABILITY.Text), "PROBABILITY", Sql.IsEmptyString(txtPROBABILITY.Text)); Sql.AppendParameter(cmd, lstOPPORTUNITY_TYPE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "OPPORTUNITY_TYPE"); Sql.AppendParameter(cmd, lstLEAD_SOURCE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "LEAD_SOURCE"); // 09/01/2006 Paul. Change STATUS to SALES_STAGE. Sql.AppendParameter(cmd, lstSALES_STAGE.SelectedValue, 25, Sql.SqlFilterMode.Exact, "SALES_STAGE"); Sql.AppendGuids(cmd, lstASSIGNED_USER_ID, "ASSIGNED_USER_ID"); }
private void Page_Load(object sender, System.EventArgs e) { // 11/05/2007 Paul. Don't show panel if it was manually hidden. this.Visible = this.Visible && (SplendidCRM.Security.GetUserAccess(m_sMODULE, "list") >= 0); // 09/09/2007 Paul. We are having trouble dynamically adding user controls to the WebPartZone. // Instead, control visibility manually here. This approach as the added benefit of hiding the // control even if the WebPartManager has moved it to an alternate zone. if (this.Visible && this.Visible && !Sql.IsEmptyString(sDetailView)) { // 01/17/2008 Paul. We need to use the sDetailView property and not the hard-coded view name. DataView vwFields = new DataView(SplendidCache.DetailViewRelationships(sDetailView)); vwFields.RowFilter = "CONTROL_NAME = '~/Opportunities/MyPipeline'"; this.Visible = vwFields.Count > 0; } if (!this.Visible) { return; } valDATE_START.ErrorMessage = L10n.Term(".ERR_INVALID_DATE"); valDATE_END.ErrorMessage = L10n.Term(".ERR_INVALID_DATE"); if (!IsPostBack) { lstSALES_STAGE.DataSource = SplendidCache.List("sales_stage_dom"); lstSALES_STAGE.DataBind(); // 09/14/2005 Paul. Default to today, and all sales stages. foreach (ListItem item in lstSALES_STAGE.Items) { item.Selected = true; } // 07/09/2006 Paul. The date is passed in TimeZone time, so convert from server time. ctlDATE_START.Value = T10n.FromServerTime(DateTime.Today); ctlDATE_END.Value = T10n.FromServerTime(new DateTime(2100, 1, 1)); // 09/15/2005 Paul. Maintain the pipeline query string separately so that we can respond to specific submit requests // and ignore all other control events on the page. ViewState["MyPipelineQueryString"] = PipelineQueryString(); } }
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 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 { // 01/21/2006 Paul. If there is an error sending the email, we want to make sure to reuse the ID, // otherwise multiple emails get created as the user tries to resend. gID = Sql.ToGuid(ViewState["ID"]); if (Sql.IsEmptyGuid(gID)) { gID = Sql.ToGuid(Request["ID"]); } if (!IsPostBack) { sEMAIL_TYPE = Sql.ToString(Request["TYPE"]).ToLower(); if (sEMAIL_TYPE != "archived") { sEMAIL_TYPE = "draft"; } ctlEditButtons.Visible = !PrintView && (sEMAIL_TYPE != "draft"); ctlEmailButtons.Visible = !PrintView && (sEMAIL_TYPE == "draft"); if (Sql.IsEmptyGuid(gID)) { ctlModuleHeader.EnableModuleLabel = false; if (sEMAIL_TYPE == "archived") { ctlModuleHeader.Title = L10n.Term("Emails.LBL_ARCHIVED_MODULE_NAME") + ":"; } else { ctlModuleHeader.Title = L10n.Term("Emails.LBL_COMPOSE_MODULE_NAME") + ":"; } // 04/16/2006 Paul. The subject is not required. //lblNAME_REQUIRED .Visible = (sEMAIL_TYPE == "archived"); //reqNAME.Enabled = lblNAME_REQUIRED.Visible; ctlDATE_START.Visible = (sEMAIL_TYPE == "archived"); spnDATE_START.Visible = ctlDATE_START.Visible; spnTEMPLATE_LABEL.Visible = (sEMAIL_TYPE == "draft"); lstEMAIL_TEMPLATE.Visible = spnTEMPLATE_LABEL.Visible; trNOTE_SEMICOLON.Visible = (sEMAIL_TYPE == "draft"); trFROM.Visible = !trNOTE_SEMICOLON.Visible; ViewState["TYPE"] = sEMAIL_TYPE; ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; } lstASSIGNED_USER_ID.DataSource = SplendidCache.AssignedUser(); lstASSIGNED_USER_ID.DataBind(); lstASSIGNED_USER_ID.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), "")); lstPARENT_TYPE.DataSource = SplendidCache.List("record_type_display"); lstPARENT_TYPE.DataBind(); if (lstEMAIL_TEMPLATE.Visible) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwEMAIL_TEMPLATES_List" + ControlChars.CrLf + " order by NAME " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); lstEMAIL_TEMPLATE.DataSource = dt.DefaultView; lstEMAIL_TEMPLATE.DataBind(); lstEMAIL_TEMPLATE.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), "")); } } } } } // 07/29/2005 Paul. SugarCRM 3.0 does not allow the NONE option. //lstPARENT_TYPE .Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), "")); Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwEMAILS_Edit" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; if (!Sql.IsEmptyGuid(gDuplicateID)) { Sql.AddParameter(cmd, "@ID", gDuplicateID); gID = Guid.Empty; } else { Sql.AddParameter(cmd, "@ID", gID); } con.Open(); #if DEBUG Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); #endif using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title += Sql.ToString(rdr["NAME"]); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; ViewState["ID"] = gID; txtNAME.Text = Sql.ToString(rdr["NAME"]); ctlDATE_START.Value = T10n.FromServerTime(rdr["DATE_START"]); txtPARENT_ID.Value = Sql.ToString(rdr["PARENT_ID"]); txtPARENT_NAME.Text = Sql.ToString(rdr["PARENT_NAME"]); txtFROM_NAME.Value = Sql.ToString(rdr["FROM_NAME"]); txtFROM_ADDR.Text = Sql.ToString(rdr["FROM_ADDR"]); txtTO_ADDRS.Text = Sql.ToString(rdr["TO_ADDRS"]); txtCC_ADDRS.Text = Sql.ToString(rdr["CC_ADDRS"]); txtBCC_ADDRS.Text = Sql.ToString(rdr["BCC_ADDRS"]); txtTO_ADDRS_IDS.Value = Sql.ToString(rdr["TO_ADDRS_IDS"]); txtTO_ADDRS_NAMES.Value = Sql.ToString(rdr["TO_ADDRS_NAMES"]); txtTO_ADDRS_EMAILS.Value = Sql.ToString(rdr["TO_ADDRS_EMAILS"]); txtCC_ADDRS_IDS.Value = Sql.ToString(rdr["CC_ADDRS_IDS"]); txtCC_ADDRS_NAMES.Value = Sql.ToString(rdr["CC_ADDRS_NAMES"]); txtCC_ADDRS_EMAILS.Value = Sql.ToString(rdr["CC_ADDRS_EMAILS"]); txtBCC_ADDRS_IDS.Value = Sql.ToString(rdr["BCC_ADDRS_IDS"]); txtBCC_ADDRS_NAMES.Value = Sql.ToString(rdr["BCC_ADDRS_NAMES"]); txtBCC_ADDRS_EMAILS.Value = Sql.ToString(rdr["BCC_ADDRS_EMAILS"]); // 04/16/2006 Paul. Since the Plug-in saves body in DESCRIPTION, we need to continue to use it as the primary source of data. txtDESCRIPTION.Value = Sql.ToString(rdr["DESCRIPTION"]); try { lstPARENT_TYPE.SelectedValue = Sql.ToString(rdr["PARENT_TYPE"]); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message); } try { lstASSIGNED_USER_ID.SelectedValue = Sql.ToString(rdr["ASSIGNED_USER_ID"]); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message); } // 11/17/2005 Paul. Archived emails allow editing of the Date & Time Sent. sEMAIL_TYPE = Sql.ToString(rdr["TYPE"]).ToLower(); switch (sEMAIL_TYPE) { case "archived": ctlModuleHeader.Title = L10n.Term("Emails.LBL_ARCHIVED_MODULE_NAME") + ":" + txtNAME.Text; break; case "out": ctlModuleHeader.Title = L10n.Term("Emails.LBL_LIST_FORM_SENT_TITLE") + ":" + txtNAME.Text; break; default: sEMAIL_TYPE = "draft"; ctlModuleHeader.Title = L10n.Term("Emails.LBL_COMPOSE_MODULE_NAME") + ":" + txtNAME.Text; break; } if (sEMAIL_TYPE == "out") { // 01/21/2006 Paul. Editing is not allowed for sent emails. Response.Redirect("view.aspx?ID=" + gID.ToString()); return; } // 04/16/2006 Paul. The subject is not required. //lblNAME_REQUIRED .Visible = (sEMAIL_TYPE == "archived"); //reqNAME.Enabled = lblNAME_REQUIRED.Visible; ctlDATE_START.Visible = (sEMAIL_TYPE == "archived"); spnDATE_START.Visible = ctlDATE_START.Visible; spnTEMPLATE_LABEL.Visible = (sEMAIL_TYPE == "draft"); lstEMAIL_TEMPLATE.Visible = spnTEMPLATE_LABEL.Visible; trNOTE_SEMICOLON.Visible = (sEMAIL_TYPE == "draft"); trFROM.Visible = !trNOTE_SEMICOLON.Visible; ctlModuleHeader.EnableModuleLabel = false; ctlEditButtons.Visible = !PrintView && (sEMAIL_TYPE != "draft"); ctlEmailButtons.Visible = !PrintView && (sEMAIL_TYPE == "draft"); ViewState["TYPE"] = sEMAIL_TYPE; } } } sSQL = "select * " + ControlChars.CrLf + " from vwEMAILS_Attachments" + ControlChars.CrLf + " where EMAIL_ID = @EMAIL_ID" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@EMAIL_ID", gID); #if DEBUG Page.RegisterClientScriptBlock("vwEMAILS_Attachments", Sql.ClientScriptBlock(cmd)); #endif using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); ctlAttachments.DataSource = dt.DefaultView; ctlAttachments.DataBind(); } } } } } else { 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)) { txtPARENT_ID.Value = gPARENT_ID.ToString(); txtPARENT_NAME.Text = sPARENT_NAME; try { lstPARENT_TYPE.SelectedValue = sPARENT_TYPE; } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message); } // 08/05/2006 Paul. When an email is composed from a Lead, automatically set the To address. DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select EMAIL1 " + ControlChars.CrLf + " from vwLEADS_Edit" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gPARENT_ID); con.Open(); #if DEBUG Page.RegisterClientScriptBlock("vwLEADS_Edit", Sql.ClientScriptBlock(cmd)); #endif using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { txtTO_ADDRS.Text = Sql.ToString(rdr["EMAIL1"]); } } } } } } try { lstASSIGNED_USER_ID.SelectedValue = Security.USER_ID.ToString(); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message); } } } else { // 12/02/2005 Paul. When validation fails, the header title does not retain its value. Update manually. ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); sEMAIL_TYPE = Sql.ToString(ViewState["TYPE"]); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlEditButtons.ErrorText = ex.Message; ctlEmailButtons.ErrorText = ex.Message; } }
protected void Page_Command(Object sender, CommandEventArgs e) { // 08/21/2005 Paul. Redirect to parent if that is where the note was originated. Guid gPARENT_ID = Sql.ToGuid(Request["PARENT_ID"]); string sMODULE = String.Empty; string sPARENT_TYPE = String.Empty; string sPARENT_NAME = String.Empty; try { SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); // The only possible error is a connection failure, so just ignore all errors. gPARENT_ID = Guid.Empty; } if (e.CommandName == "Save" || e.CommandName == "Send") { if (ctlDATE_START.Visible) { ctlDATE_START.Validate(); } if (Page.IsValid) { string sCUSTOM_MODULE = "EMAILS"; DataTable dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbTransaction trn = con.BeginTransaction()) { try { //txtDESCRIPTION .Text = txtDESCRIPTION .Text .Trim(); txtFROM_NAME.Value = txtFROM_NAME.Value.Trim(); txtFROM_ADDR.Text = txtFROM_ADDR.Text.Trim(); txtTO_ADDRS.Text = txtTO_ADDRS.Text.Trim(); txtCC_ADDRS.Text = txtCC_ADDRS.Text.Trim(); txtBCC_ADDRS.Text = txtBCC_ADDRS.Text.Trim(); txtTO_ADDRS_IDS.Value = txtTO_ADDRS_IDS.Value.Trim(); txtTO_ADDRS_NAMES.Value = txtTO_ADDRS_NAMES.Value.Trim(); txtTO_ADDRS_EMAILS.Value = txtTO_ADDRS_EMAILS.Value.Trim(); txtCC_ADDRS_IDS.Value = txtCC_ADDRS_IDS.Value.Trim(); txtCC_ADDRS_NAMES.Value = txtCC_ADDRS_NAMES.Value.Trim(); txtCC_ADDRS_EMAILS.Value = txtCC_ADDRS_EMAILS.Value.Trim(); txtBCC_ADDRS_IDS.Value = txtBCC_ADDRS_IDS.Value.Trim(); txtBCC_ADDRS_NAMES.Value = txtBCC_ADDRS_NAMES.Value.Trim(); txtBCC_ADDRS_EMAILS.Value = txtBCC_ADDRS_EMAILS.Value.Trim(); if (e.CommandName == "Send") { // 01/21/2006 Paul. Mark an email as ready-to-send. Type becomes "out" and Status stays at "draft". if (sEMAIL_TYPE == "draft") { sEMAIL_TYPE = "out"; } // 01/21/2006 Paul. Address error only when sending. if (txtTO_ADDRS.Text.Length == 0 && txtCC_ADDRS.Text.Length == 0 && txtBCC_ADDRS.Text.Length == 0) { throw(new Exception(L10n.Term("Emails.ERR_NOT_ADDRESSED"))); } } // 11/20/2005 Paul. SugarCRM 3.5.1 lets bad data flow through. We clear the hidden values if the visible values are empty. // There still is the issue of the data getting out of sync if the user manually edits the visible values. if (txtTO_ADDRS.Text.Length == 0) { txtTO_ADDRS_IDS.Value = String.Empty; txtTO_ADDRS_NAMES.Value = String.Empty; txtTO_ADDRS_EMAILS.Value = String.Empty; } if (txtCC_ADDRS.Text.Length == 0) { txtCC_ADDRS_IDS.Value = String.Empty; txtCC_ADDRS_NAMES.Value = String.Empty; txtCC_ADDRS_EMAILS.Value = String.Empty; } if (txtBCC_ADDRS.Text.Length == 0) { txtBCC_ADDRS_IDS.Value = String.Empty; txtBCC_ADDRS_NAMES.Value = String.Empty; txtBCC_ADDRS_EMAILS.Value = String.Empty; } // 04/24/2006 Paul. Upgrade to SugarCRM 4.2 Schema. // 06/01/2006 Paul. MESSAGE_ID is now a text string. SqlProcs.spEMAILS_Update (ref gID , Sql.ToGuid(lstASSIGNED_USER_ID.SelectedValue) , txtNAME.Text , T10n.ToServerTime(ctlDATE_START.Value) , lstPARENT_TYPE.SelectedValue , Sql.ToGuid(txtPARENT_ID.Value) // 04/16/2006 Paul. Since the Plug-in saves body in DESCRIPTION, we need to continue to use it as the primary source of data. , txtDESCRIPTION.Value // DESCRIPTION , txtDESCRIPTION.Value // DESCRIPTION_HTML , txtFROM_NAME.Value , txtFROM_ADDR.Text , txtTO_ADDRS.Text , txtCC_ADDRS.Text , txtBCC_ADDRS.Text , txtTO_ADDRS_IDS.Value , txtTO_ADDRS_NAMES.Value , txtTO_ADDRS_EMAILS.Value , txtCC_ADDRS_IDS.Value , txtCC_ADDRS_NAMES.Value , txtCC_ADDRS_EMAILS.Value , txtBCC_ADDRS_IDS.Value , txtBCC_ADDRS_NAMES.Value , txtBCC_ADDRS_EMAILS.Value , sEMAIL_TYPE , new DynamicControl(this, "MESSAGE_ID").Text , new DynamicControl(this, "REPLY_TO_NAME").Text , new DynamicControl(this, "REPLY_TO_ADDR").Text , new DynamicControl(this, "INTENT").Text , new DynamicControl(this, "MAILBOX_ID").ID , trn ); // 01/21/2006 Paul. There can be a maximum of 10 attachments, not including attachments that were previously saved. for (int i = 0; i < 10; i++) { HtmlInputFile fileATTACHMENT = FindControl("email_attachment" + i.ToString()) as HtmlInputFile; if (fileATTACHMENT != null) { HttpPostedFile pstATTACHMENT = fileATTACHMENT.PostedFile; if (pstATTACHMENT != null) { long lFileSize = pstATTACHMENT.ContentLength; long lUploadMaxSize = Sql.ToLong(Application["CONFIG.upload_maxsize"]); if ((lUploadMaxSize > 0) && (lFileSize > lUploadMaxSize)) { throw(new Exception("ERROR: uploaded file was too big: max filesize: " + lUploadMaxSize.ToString())); } // 08/20/2005 Paul. File may not have been provided. if (pstATTACHMENT.FileName.Length > 0) { string sFILENAME = Path.GetFileName(pstATTACHMENT.FileName); string sFILE_EXT = Path.GetExtension(sFILENAME); string sFILE_MIME_TYPE = pstATTACHMENT.ContentType; Guid gNoteID = Guid.Empty; SqlProcs.spNOTES_Update (ref gNoteID , "Email Attachment: " + sFILENAME , "Emails" // Parent Type , gID // Parent ID , Guid.Empty , String.Empty , trn ); Guid gAttachmentID = Guid.Empty; // 01/20/2006 Paul. Must include in transaction SqlProcs.spNOTE_ATTACHMENTS_Insert(ref gAttachmentID, gNoteID, pstATTACHMENT.FileName, sFILENAME, sFILE_EXT, sFILE_MIME_TYPE, trn); Notes.EditView.LoadFile(gAttachmentID, pstATTACHMENT.InputStream, trn); } } } } //SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields); trn.Commit(); // 01/21/2006 Paul. In case the SendMail function fails, we want to make sure to reuse the GUID. ViewState["ID"] = gID; } catch (Exception ex) { trn.Rollback(); SplendidError.SystemError(new StackTrace(true).GetFrame(0), Utils.ExpandException(ex)); ctlEditButtons.ErrorText = Utils.ExpandException(ex); ctlEmailButtons.ErrorText = ctlEditButtons.ErrorText; return; } try { if (e.CommandName == "Send") { SendEmail(gID); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), Utils.ExpandException(ex)); ctlEditButtons.ErrorText = Utils.ExpandException(ex); ctlEmailButtons.ErrorText = ctlEditButtons.ErrorText; return; } } } if (!Sql.IsEmptyGuid(gPARENT_ID)) { Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString()); } else if (sEMAIL_TYPE == "draft") { Response.Redirect("default.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()); } // 09/07/2006 Paul. If in draft mode, redirect to list. Viewing a draft will re-direct you to edit mode. else if (Sql.IsEmptyGuid(gID) || Sql.ToString(ViewState["TYPE"]) == "draft") { Response.Redirect("default.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID.ToString()); } } }
private void Page_Load(object sender, System.EventArgs e) { Response.BufferOutput = true; SetPageTitle(L10n.Term("Schedulers.LBL_MODULE_TITLE")); // 06/04/2006 Paul. Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load. this.Visible = SplendidCRM.Security.IS_ADMIN; if (!this.Visible) { return; } try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " , '' as DATE_RANGE" + ControlChars.CrLf + " from vwSCHEDULERS " + ControlChars.CrLf + " where 1 = 1 " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); foreach (DataRow row in dt.Rows) { string sJOB_INTERVAL = Sql.ToString(row["JOB_INTERVAL"]); DateTime dtDATE_TIME_START = Sql.ToDateTime(row["DATE_TIME_START"]); DateTime dtDATE_TIME_END = Sql.ToDateTime(row["DATE_TIME_END"]); DateTime dtLAST_RUN = Sql.ToDateTime(row["LAST_RUN"]); row["JOB_INTERVAL"] = sJOB_INTERVAL + "<br>" + SchedulerUtils.CronDescription(L10n, sJOB_INTERVAL); if (dtDATE_TIME_START != DateTime.MinValue) { row["DATE_RANGE"] = T10n.FromServerTime(dtDATE_TIME_START).ToString() + "-"; } if (dtDATE_TIME_END == DateTime.MinValue) { row["DATE_RANGE"] += L10n.Term("Schedulers.LBL_PERENNIAL"); } else { row["DATE_RANGE"] += T10n.FromServerTime(dtDATE_TIME_END).ToString(); } if (dtLAST_RUN != DateTime.MinValue) { row["LAST_RUN"] = T10n.FromServerTime(dtLAST_RUN); } row["STATUS"] = L10n.Term(".scheduler_status_dom.", row["STATUS"]); } vwMain = dt.DefaultView; grdMain.DataSource = vwMain; if (!IsPostBack) { grdMain.SortColumn = "NAME"; grdMain.SortOrder = "asc"; grdMain.ApplySort(); grdMain.DataBind(); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "Save") { // 01/31/2006 Paul. Enable validator before validating page. SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".ConvertView", this); if (Page.IsValid) { // 02/27/2006 Paul. Fix condition on notes. Enable only if text exists. txtCONTACT_NOTES_NAME_DESCRIPTION.Text = txtCONTACT_NOTES_NAME_DESCRIPTION.Text.Trim(); reqCONTACT_NOTES_NAME.Enabled = !Sql.IsEmptyString(txtCONTACT_NOTES_NAME_DESCRIPTION.Text); reqCONTACT_NOTES_NAME.Validate(); txtACCOUNT_NOTES_NAME_DESCRIPTION.Text = txtACCOUNT_NOTES_NAME_DESCRIPTION.Text.Trim(); reqACCOUNT_NOTES_NAME.Enabled = !Sql.IsEmptyString(txtACCOUNT_NOTES_NAME_DESCRIPTION.Text); reqACCOUNT_NOTES_NAME.Validate(); txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text = txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text.Trim(); reqOPPORTUNITY_NOTES_NAME.Enabled = !Sql.IsEmptyString(txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text); reqOPPORTUNITY_NOTES_NAME.Validate(); // 01/31/2006 Paul. SelectAccount is required if not creating an account but creating an opportunity. reqSELECT_ACCOUNT_ID.Enabled = !chkCreateAccount.Checked && chkCreateOpportunity.Checked; reqSELECT_ACCOUNT_ID.Validate(); reqACCOUNT_NAME.Enabled = chkCreateAccount.Checked; reqACCOUNT_NAME.Validate(); reqOPPORTUNITY_NAME.Enabled = chkCreateOpportunity.Checked; reqOPPORTUNITY_NAME.Validate(); reqOPPORTUNITY_AMOUNT.Enabled = chkCreateOpportunity.Checked; reqOPPORTUNITY_AMOUNT.Validate(); reqAPPOINTMENT_NAME.Enabled = chkCreateAppointment.Checked; reqAPPOINTMENT_NAME.Validate(); reqAPPOINTMENT_TIME_START.Enabled = chkCreateAppointment.Checked; reqAPPOINTMENT_TIME_START.Validate(); if (chkCreateAppointment.Checked) { ctlAPPOINTMENT_DATE_START.Validate(); } } if (Page.IsValid) { string sCUSTOM_MODULE = "LEADS"; DataTable dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbTransaction trn = con.BeginTransaction()) { try { Guid gCONTACT_ID = Guid.Empty; Guid gACCOUNT_ID = Guid.Empty; Guid gOPPORTUNITY_ID = Guid.Empty; Guid gAPPOINTMENT_ID = Guid.Empty; // 01/31/2006 Paul. Create the contact first so that it can be used as the parent of the related records. // We would normally create the related records second, but then it will become a pain to update the Contact ACCOUNT_ID field. SqlProcs.spCONTACTS_New (ref gCONTACT_ID , new DynamicControl(this, "FIRST_NAME").Text , new DynamicControl(this, "LAST_NAME").Text , new DynamicControl(this, "PHONE_WORK").Text , new DynamicControl(this, "EMAIL1").Text , trn ); if (chkCreateAccount.Checked) { SqlProcs.spACCOUNTS_Update (ref gACCOUNT_ID , Security.USER_ID , txtACCOUNT_NAME.Text , String.Empty , Guid.Empty , String.Empty , String.Empty , Sql.ToString(ViewState["PHONE_FAX"]) , Sql.ToString(ViewState["BILLING_ADDRESS_STREET"]) , Sql.ToString(ViewState["BILLING_ADDRESS_CITY"]) , Sql.ToString(ViewState["BILLING_ADDRESS_STATE"]) , Sql.ToString(ViewState["BILLING_ADDRESS_POSTALCODE"]) , Sql.ToString(ViewState["BILLING_ADDRESS_COUNTRY"]) , txtACCOUNT_DESCRIPTION.Text , String.Empty , txtACCOUNT_PHONE_WORK.Text , Sql.ToString(ViewState["PHONE_OTHER"]) , Sql.ToString(ViewState["EMAIL1"]) , Sql.ToString(ViewState["EMAIL2"]) , txtACCOUNT_WEBSITE.Text , String.Empty , String.Empty , String.Empty , String.Empty , Sql.ToString(ViewState["SHIPPING_ADDRESS_STREET"]) , Sql.ToString(ViewState["SHIPPING_ADDRESS_CITY"]) , Sql.ToString(ViewState["SHIPPING_ADDRESS_STATE"]) , Sql.ToString(ViewState["SHIPPING_ADDRESS_POSTALCODE"]) , Sql.ToString(ViewState["SHIPPING_ADDRESS_COUNTRY"]) , trn ); if (!Sql.IsEmptyString(txtACCOUNT_NOTES_NAME.Text)) { Guid gNOTE_ID = Guid.Empty; SqlProcs.spNOTES_Update (ref gNOTE_ID , txtACCOUNT_NOTES_NAME.Text , "Accounts" , gACCOUNT_ID , Guid.Empty , txtACCOUNT_NOTES_NAME_DESCRIPTION.Text , trn ); } } else { gACCOUNT_ID = Sql.ToGuid(txtSELECT_ACCOUNT_ID.Value); } if (chkCreateOpportunity.Checked) { SqlProcs.spOPPORTUNITIES_Update (ref gOPPORTUNITY_ID , Security.USER_ID , gACCOUNT_ID , txtOPPORTUNITY_NAME.Text , String.Empty , new DynamicControl(this, "LEAD_SOURCE").SelectedValue , Sql.ToDecimal(txtOPPORTUNITY_AMOUNT.Text) , Guid.Empty , T10n.ToServerTime(ctlOPPORTUNITY_DATE_CLOSED.Value) , String.Empty , lstOPPORTUNITY_SALES_STAGE.SelectedValue , (float)0.0 , txtOPPORTUNITY_DESCRIPTION.Text , String.Empty , Guid.Empty , trn ); if (!Sql.IsEmptyString(txtOPPORTUNITY_NOTES_NAME.Text)) { Guid gNOTE_ID = Guid.Empty; SqlProcs.spNOTES_Update (ref gNOTE_ID , txtOPPORTUNITY_NOTES_NAME.Text , "Opportunities" , gOPPORTUNITY_ID , Guid.Empty , txtOPPORTUNITY_NOTES_NAME_DESCRIPTION.Text , trn ); } // 03/04/2006 Paul. Must be included in the transaction, otherwise entire operation will fail with a timeout message. SqlProcs.spOPPORTUNITIES_CONTACTS_Update(gOPPORTUNITY_ID, gCONTACT_ID, String.Empty, trn); } if (chkCreateAppointment.Checked) { DateTime dtDATE_START = T10n.ToServerTime(Sql.ToDateTime(ctlAPPOINTMENT_DATE_START.DateText + " " + txtAPPOINTMENT_TIME_START.Text)); if (radScheduleCall.Checked) { SqlProcs.spCALLS_Update (ref gAPPOINTMENT_ID , Security.USER_ID , txtAPPOINTMENT_NAME.Text , 1 , 0 , dtDATE_START , "Accounts" , Guid.Empty , "Planned" , "Outbound" , -1 , txtAPPOINTMENT_DESCRIPTION.Text , gCONTACT_ID.ToString() // 01/31/2006 Paul. This is were we relate this call to the contact. , trn ); } else { SqlProcs.spMEETINGS_Update (ref gAPPOINTMENT_ID , Security.USER_ID , txtAPPOINTMENT_NAME.Text , String.Empty , 1 , 0 , dtDATE_START , "Planned" , "Accounts" , Guid.Empty , -1 , txtAPPOINTMENT_DESCRIPTION.Text , gCONTACT_ID.ToString() // 01/31/2006 Paul. This is were we relate this meeting to the contact. , trn ); } } SqlProcs.spCONTACTS_ConvertLead (ref gCONTACT_ID , gID // 01/31/2006 Paul. Update the Lead with this contact. , Security.USER_ID , new DynamicControl(this, "SALUTATION").SelectedValue , new DynamicControl(this, "FIRST_NAME").Text , new DynamicControl(this, "LAST_NAME").Text , gACCOUNT_ID , new DynamicControl(this, "LEAD_SOURCE").SelectedValue , new DynamicControl(this, "TITLE").Text , new DynamicControl(this, "DEPARTMENT").Text , new DynamicControl(this, "DO_NOT_CALL").Checked , new DynamicControl(this, "PHONE_HOME").Text , new DynamicControl(this, "PHONE_MOBILE").Text , new DynamicControl(this, "PHONE_WORK").Text , new DynamicControl(this, "PHONE_OTHER").Text , new DynamicControl(this, "PHONE_FAX").Text , new DynamicControl(this, "EMAIL1").Text , new DynamicControl(this, "EMAIL2").Text , new DynamicControl(this, "EMAIL_OPT_OUT").Checked , new DynamicControl(this, "INVALID_EMAIL").Checked , new DynamicControl(this, "PRIMARY_ADDRESS_STREET").Text , new DynamicControl(this, "PRIMARY_ADDRESS_CITY").Text , new DynamicControl(this, "PRIMARY_ADDRESS_STATE").Text , new DynamicControl(this, "PRIMARY_ADDRESS_POSTALCODE").Text , new DynamicControl(this, "PRIMARY_ADDRESS_COUNTRY").Text , Sql.ToString(ViewState["ALT_ADDRESS_STREET"]) , Sql.ToString(ViewState["ALT_ADDRESS_CITY"]) , Sql.ToString(ViewState["ALT_ADDRESS_STATE"]) , Sql.ToString(ViewState["ALT_ADDRESS_POSTALCODE"]) , Sql.ToString(ViewState["ALT_ADDRESS_COUNTRY"]) , new DynamicControl(this, "DESCRIPTION").Text , gOPPORTUNITY_ID , txtOPPORTUNITY_NAME.Text , txtOPPORTUNITY_AMOUNT.Text , trn ); if (!Sql.IsEmptyString(txtCONTACT_NOTES_NAME.Text)) { Guid gNOTE_ID = Guid.Empty; SqlProcs.spNOTES_Update (ref gNOTE_ID , txtCONTACT_NOTES_NAME.Text , String.Empty , Guid.Empty , gCONTACT_ID , txtCONTACT_NOTES_NAME_DESCRIPTION.Text , trn ); } SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields); trn.Commit(); } catch (Exception ex) { trn.Rollback(); SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlEditButtons.ErrorText = ex.Message; return; } } } Response.Redirect("view.aspx?ID=" + gID.ToString()); } } else if (e.CommandName == "Cancel") { if (Sql.IsEmptyGuid(gID)) { Response.Redirect("default.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID.ToString()); } } }
private void Page_Load(object sender, System.EventArgs e) { try { gID = Sql.ToGuid(Request["ID"]); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE)); if (!IsPostBack) { lblDATEFORMAT.Text = "(" + Session["USER_SETTINGS/DATEFORMAT"] + ")"; lstOPPORTUNITY_SALES_STAGE.DataSource = SplendidCache.List("sales_stage_dom"); lstOPPORTUNITY_SALES_STAGE.DataBind(); chkCreateAccount.Attributes.Add("onclick", "return ToggleCreateAccount();"); chkCreateOpportunity.Attributes.Add("onclick", "return toggleDisplay('divCreateOpportunity');"); chkCreateAppointment.Attributes.Add("onclick", "return toggleDisplay('divCreateAppointment');"); Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwLEADS_Convert" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; if (!Sql.IsEmptyGuid(gDuplicateID)) { Sql.AddParameter(cmd, "@ID", gDuplicateID); gID = Guid.Empty; } else { Sql.AddParameter(cmd, "@ID", gID); } con.Open(); #if DEBUG Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); #endif using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = L10n.Term("Leads.LBL_CONVERTLEAD"); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); txtACCOUNT_NAME.Text = Sql.ToString(rdr["ACCOUNT_NAME"]); txtACCOUNT_PHONE_WORK.Text = Sql.ToString(rdr["PHONE_WORK"]); // 01/31/2006 Paul. Default start date and time is now. ctlAPPOINTMENT_DATE_START.Value = T10n.FromServerTime(DateTime.Now); txtAPPOINTMENT_TIME_START.Text = T10n.FromServerTime(DateTime.Now).ToShortTimeString(); this.AppendEditViewFields(m_sMODULE + ".ConvertView", tblMain, rdr); // 01/31/2006 Paul. Save all data to be used later. for (int i = 0; i < rdr.FieldCount; i++) { ViewState[rdr.GetName(i)] = rdr.GetValue(i); } } } } } } else { this.AppendEditViewFields(m_sMODULE + ".ConvertView", tblMain, null); } } else { // 12/02/2005 Paul. When validation fails, the header title does not retain its value. Update manually. ctlModuleHeader.Title = L10n.Term("Leads.LBL_CONVERTLEAD"); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlEditButtons.ErrorText = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { 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"]); int nYEAR = Sql.ToInteger(Request.QueryString["YEAR"]); nYEAR = Math.Max(1900, nYEAR); nYEAR = Math.Min(2100, nYEAR); DateTime dtDATE_START = new DateTime(nYEAR, 1, 1); DateTime dtDATE_END = new DateTime(nYEAR, 12, 31); // 09/15/2005 Paul. Values will always be in the query string. string[] arrASSIGNED_USER_ID = Request.QueryString.GetValues("ASSIGNED_USER_ID"); 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(nodeYData, nodeColorLegend); nodeRoot.InsertBefore(nodeXData, nodeYData); XmlUtil.SetSingleNodeAttribute(xml, nodeXData, "length", "20"); XmlUtil.SetSingleNodeAttribute(xml, nodeYData, "min", "0"); XmlUtil.SetSingleNodeAttribute(xml, nodeYData, "max", "0"); if (nCHART_LENGTH < 4) { nCHART_LENGTH = 4; } else if (nCHART_LENGTH > 10) { nCHART_LENGTH = 10; } XmlUtil.SetSingleNodeAttribute(xml, nodeYData, "length", nCHART_LENGTH.ToString()); XmlUtil.SetSingleNodeAttribute(xml, nodeYData, "prefix", Sql.ToString(Session["USER_SETTINGS/CURRENCY_SYMBOL"])); XmlUtil.SetSingleNodeAttribute(xml, nodeYData, "suffix", ""); XmlUtil.SetSingleNodeAttribute(xml, nodeYData, "defaultAltText", L10n.Term("Dashboard.LBL_ROLLOVER_DETAILS")); 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 hashOUTCOME = new Hashtable(); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); string sSQL; // 09/19/2005 Paul. Prepopulate the outcome. string[] arrOUTCOME = new string[] { "Closed Lost", "Closed Won", "Other" }; foreach (string sOUTCOME in arrOUTCOME) { if (!hashOUTCOME.ContainsKey(sOUTCOME)) { XmlNode nodeMapping = xml.CreateElement("mapping"); nodeColorLegend.AppendChild(nodeMapping); XmlUtil.SetSingleNodeAttribute(xml, nodeMapping, "id", sOUTCOME); if (sOUTCOME == "Other") { XmlUtil.SetSingleNodeAttribute(xml, nodeMapping, "name", L10n.Term("Dashboard.LBL_LEAD_SOURCE_OTHER")); } else { XmlUtil.SetSingleNodeAttribute(xml, nodeMapping, "name", Sql.ToString(L10n.Term(".sales_stage_dom.", sOUTCOME))); } XmlUtil.SetSingleNodeAttribute(xml, nodeMapping, "color", SplendidDefaults.generate_graphcolor(sOUTCOME, hashOUTCOME.Count)); hashOUTCOME.Add(sOUTCOME, sOUTCOME); } } sSQL = "select SALES_STAGE " + ControlChars.CrLf + " , MONTH_CLOSED " + ControlChars.CrLf + " , sum(AMOUNT_USDOLLAR/1000) as TOTAL " + ControlChars.CrLf + " , count(*) as OPPORTUNITY_COUNT" + ControlChars.CrLf + " from vwOPPORTUNITIES_PipelineMonth " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Security.Filter(cmd, "Opportunities", "list"); cmd.CommandText += " and DATE_CLOSED >= @DATE_START" + ControlChars.CrLf; cmd.CommandText += " and DATE_CLOSED <= @DATE_END " + ControlChars.CrLf; // 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"); cmd.CommandText += "" + " group by SALES_STAGE " + ControlChars.CrLf + " , MONTH_CLOSED " + ControlChars.CrLf + " order by MONTH_CLOSED, SALES_STAGE desc " + ControlChars.CrLf; using (IDataReader rdr = cmd.ExecuteReader()) { double dMAX_TOTAL = 0; double dPIPELINE_TOTAL = 0; string sMONTHYEAR_FORMAT = m_sDATEFORMAT; // 09/21/2005 Paul. Remove day from format. sMONTHYEAR_FORMAT = sMONTHYEAR_FORMAT.Replace("dd", ""); sMONTHYEAR_FORMAT = sMONTHYEAR_FORMAT.Replace("--", "-"); sMONTHYEAR_FORMAT = sMONTHYEAR_FORMAT.Replace("//", "/"); sMONTHYEAR_FORMAT = sMONTHYEAR_FORMAT.Replace(" ", " "); while (rdr.Read()) { int nMONTH_CLOSED = Sql.ToInteger(rdr["MONTH_CLOSED"]); string sSALES_STAGE = Sql.ToString(rdr["SALES_STAGE"]); double dTOTAL = Sql.ToDouble(rdr["TOTAL"]); int nOPPORTUNITY_COUNT = Sql.ToInteger(rdr["OPPORTUNITY_COUNT"]); DateTime dtMONTH_CLOSED = new DateTime(nYEAR, nMONTH_CLOSED, 1); string sMONTH_CLOSED = dtMONTH_CLOSED.ToString(sMONTHYEAR_FORMAT); dPIPELINE_TOTAL += dTOTAL; if (dTOTAL > dMAX_TOTAL) { dMAX_TOTAL = dTOTAL; } XmlNode nodeRow = nodeXData.SelectSingleNode("dataRow[@title=\'" + L10n.Term(sMONTH_CLOSED).Replace("'", "\'") + "\']"); if (nodeRow == null) { nodeRow = xml.CreateElement("dataRow"); nodeXData.AppendChild(nodeRow); XmlUtil.SetSingleNodeAttribute(xml, nodeRow, "title", sMONTH_CLOSED); 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")); } } XmlNode nodeBar = xml.CreateElement("bar"); nodeRow.AppendChild(nodeBar); XmlUtil.SetSingleNodeAttribute(xml, nodeBar, "id", sSALES_STAGE); XmlUtil.SetSingleNodeAttribute(xml, nodeBar, "totalSize", dTOTAL.ToString("0")); XmlUtil.SetSingleNodeAttribute(xml, nodeBar, "altText", sMONTH_CLOSED + ": " + nOPPORTUNITY_COUNT.ToString() + " " + L10n.Term("Dashboard.LBL_OPPS_WORTH") + " " + dTOTAL.ToString("0") + L10n.Term("Dashboard.LBL_OPP_THOUSANDS") + " " + L10n.Term("Dashboard.LBL_OPPS_OUTCOME") + " " + Sql.ToString(L10n.Term(".sales_stage_dom.", sSALES_STAGE))); XmlUtil.SetSingleNodeAttribute(xml, nodeBar, "url", Sql.ToString(Application["rootURL"]) + "Opportunities/default.aspx?DATE_CLOSED=" + Server.UrlEncode(Sql.ToDateString(T10n.FromServerTime(dtMONTH_CLOSED))) + "&SALES_STAGE=" + Server.UrlEncode(sSALES_STAGE)); } 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, nodeYData, "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); Response.Write(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 { 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()) { con.Open(); string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwCALLS_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); } 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); // 07/12/2006 Paul. Need to enable schedule updates. DateTimePicker ctlDATE_START = FindControl("DATE_START") as DateTimePicker; if (ctlDATE_START != null) { ctlDATE_START.Changed += new System.EventHandler(this.Date_Changed); ctlDATE_START.AutoPostBack = true; } // 08/02/2005 Paul. Set status to Held when closing from Home page. // 06/21/2006 Paul. Change parameter to Close so that the same parameter can be used for Calls, Meetings and Tasks. if (Sql.ToString(Request["Status"]) == "Close") { new DynamicControl(this, "STATUS").SelectedValue = "Held"; } else { new DynamicControl(this, "STATUS").SelectedValue = Sql.ToString(rdr["STATUS"]); } int nMinutes = Sql.ToInteger(rdr["DURATION_MINUTES"]); if (nMinutes <= 7) { new DynamicControl(this, "DURATION_MINUTES").SelectedValue = "00"; } else if (nMinutes <= 15 + 7) { new DynamicControl(this, "DURATION_MINUTES").SelectedValue = "15"; } else if (nMinutes <= 30 + 7) { new DynamicControl(this, "DURATION_MINUTES").SelectedValue = "30"; } else { new DynamicControl(this, "DURATION_MINUTES").SelectedValue = "45"; } int nREMINDER_TIME = Sql.ToInteger(rdr["REMINDER_TIME"]); if (nREMINDER_TIME >= 0) { new DynamicControl(this, "REMINDER_TIME").SelectedValue = nREMINDER_TIME.ToString(); new DynamicControl(this, "SHOULD_REMIND").Checked = true; } } 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"); } } } sSQL = "select INVITEE_ID " + ControlChars.CrLf + " from vwCALLS_Invitees " + ControlChars.CrLf + " where CALL_ID = @ID " + ControlChars.CrLf + " order by INVITEE_TYPE desc, INVITEE_NAME asc" + 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); } if (bDebug) { RegisterClientScriptBlock("vwCALLS_Invitees", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader()) { StringBuilder sb = new StringBuilder(); while (rdr.Read()) { if (sb.Length > 0) { sb.Append(","); } sb.Append(Sql.ToString(rdr["INVITEE_ID"]).ToLower()); } txtINVITEE_ID.Value = sb.ToString(); } } } } else { this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); DateTimePicker ctlDATE_START = FindControl("DATE_START") as DateTimePicker; if (ctlDATE_START != null) { ctlDATE_START.Changed += new System.EventHandler(this.Date_Changed); ctlDATE_START.AutoPostBack = true; // Default start date and time is now. ctlDATE_START.Value = T10n.FromServerTime(DateTime.Now); } // Default value for duration is 15 minutes. new DynamicControl(this, "DURATION_MINUTES").Text = "15"; // Default to 0 hours. new DynamicControl(this, "DURATION_HOURS").Text = "0"; // Default to remind. new DynamicControl(this, "SHOULD_REMIND").Checked = true; 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)) { new DynamicControl(this, "PARENT_ID").ID = gPARENT_ID; new DynamicControl(this, "PARENT_NAME").Text = sPARENT_NAME; new DynamicControl(this, "PARENT_TYPE").SelectedValue = sPARENT_TYPE; } } } // Default to current user. if (txtINVITEE_ID.Value.Length == 0) { txtINVITEE_ID.Value = Security.USER_ID.ToString(); } BindSchedule(); } 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); // 11/09/2005 Paul. Need to rebind early so that the Delete event will fire. BindSchedule(); ctlInviteesView.INVITEES = txtINVITEE_ID.Value.Split(','); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = ex.Message; } }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "NewRecord") { reqNAME.Enabled = true; reqDATE_CLOSED.Enabled = true; reqACCOUNT_ID.Enabled = true; reqAMOUNT.Enabled = true; valDATE_CLOSED.Enabled = true; reqNAME.Validate(); reqDATE_CLOSED.Validate(); reqACCOUNT_ID.Validate(); reqAMOUNT.Validate(); valDATE_CLOSED.Validate(); if (Page.IsValid) { Guid gID = Guid.Empty; try { SqlProcs.spOPPORTUNITIES_New(ref gID, Sql.ToGuid(txtACCOUNT_ID.Value), txtNAME.Text, Sql.ToDecimal(txtAMOUNT.Text), C10n.ID, T10n.ToServerTime(ctlDATE_CLOSED.Value), lstSALES_STAGE.SelectedValue); } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } if (!Sql.IsEmptyGuid(gID)) { Response.Redirect("~/Opportunities/view.aspx?ID=" + gID.ToString()); } } } }
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 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 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; } } } }
protected void Page_Command(object sender, CommandEventArgs e) { try { if (e.CommandName == "Search") { // 10/13/2005 Paul. Make sure to clear the page index prior to applying search. grdMain.CurrentPageIndex = 0; grdMain.ApplySort(); grdMain.DataBind(); } // 12/14/2007 Paul. We need to capture the sort event from the SearchView. else if (e.CommandName == "SortGrid") { grdMain.SetSortFields(e.CommandArgument as string[]); } else if (e.CommandName == "MassUpdate") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { // 10/26/2007 Paul. Use a stack to run the update in blocks of under 200 IDs. //string sIDs = Utils.ValidateIDs(arrID); System.Collections.Stack stk = Utils.FilterByACL_Stack(m_sMODULE, "edit", arrID, "CALLS"); if (stk.Count > 0) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbTransaction trn = con.BeginTransaction()) { try { while (stk.Count > 0) { string sIDs = Utils.BuildMassIDs(stk); // 07/09/2006 Paul. The date conversion was moved out of the MassUpdate control. // 09/11/2007 Paul. Mass update of teams is now available. SqlProcs.spCALLS_MassUpdate(sIDs, ctlMassUpdate.ASSIGNED_USER_ID, T10n.ToServerTime(ctlMassUpdate.DATE_START), ctlMassUpdate.STATUS, ctlMassUpdate.DIRECTION, ctlMassUpdate.TEAM_ID, trn); } trn.Commit(); } catch (Exception ex) { trn.Rollback(); throw(new Exception(ex.Message, ex.InnerException)); } } } Response.Redirect("default.aspx"); } } } else if (e.CommandName == "MassDelete") { string[] arrID = Request.Form.GetValues("chkMain"); if (arrID != null) { // 10/26/2007 Paul. Use a stack to run the update in blocks of under 200 IDs. //string sIDs = Utils.ValidateIDs(arrID); System.Collections.Stack stk = Utils.FilterByACL_Stack(m_sMODULE, "delete", arrID, "CALLS"); if (stk.Count > 0) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); using (IDbTransaction trn = con.BeginTransaction()) { try { while (stk.Count > 0) { string sIDs = Utils.BuildMassIDs(stk); SqlProcs.spCALLS_MassDelete(sIDs, trn); } trn.Commit(); } catch (Exception ex) { trn.Rollback(); throw(new Exception(ex.Message, ex.InnerException)); } } } Response.Redirect("default.aspx"); } } } else if (e.CommandName == "Export") { // 11/03/2006 Paul. Apply ACL rules to Export. int nACLACCESS = SplendidCRM.Security.GetUserAccess(m_sMODULE, "export"); if (nACLACCESS >= 0) { if (nACLACCESS == ACL_ACCESS.OWNER) { vwMain.RowFilter = "ASSIGNED_USER_ID = '" + Security.USER_ID.ToString() + "'"; } string[] arrID = Request.Form.GetValues("chkMain"); SplendidExport.Export(vwMain, m_sMODULE, ctlExportHeader.ExportFormat, ctlExportHeader.ExportRange, grdMain.CurrentPageIndex, grdMain.PageSize, arrID); } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term(".moduleList.Schedulers")); // 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; } NAME_REQUIRED.DataBind(); try { gID = Sql.ToGuid(Request["ID"]); if (!IsPostBack) { STATUS.DataSource = SplendidCache.List("scheduler_status_dom"); STATUS.DataBind(); foreach (string sJob in SchedulerUtils.Jobs) { JOB.Items.Add(new ListItem(sJob, "function::" + sJob)); } 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 vwSCHEDULERS" + 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["NAME"]); SetPageTitle(L10n.Term(".moduleList.Schedulers") + " - " + ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; NAME.Text = Sql.ToString(rdr["NAME"]); CATCH_UP.Checked = Sql.ToBoolean(rdr["CATCH_UP"]); string JOB_INTERVAL = Sql.ToString(rdr["JOB_INTERVAL"]); JOB_INTERVAL = JOB_INTERVAL.Replace(" ", ""); string[] arrCRON = JOB_INTERVAL.Replace("::", "|").Split('|'); // minute hour dayOfMonth month dayOfWeek CRON_MINUTES.Text = (arrCRON.Length > 0) ? arrCRON[0] : "*"; CRON_HOURS.Text = (arrCRON.Length > 1) ? arrCRON[1] : "*"; CRON_DAYOFMONTH.Text = (arrCRON.Length > 2) ? arrCRON[2] : "*"; CRON_MONTHS.Text = (arrCRON.Length > 3) ? arrCRON[3] : "*"; CRON_DAYOFWEEK.Text = (arrCRON.Length > 4) ? arrCRON[4] : "*"; if (rdr["DATE_TIME_START"] != DBNull.Value) { DATE_TIME_START.Value = T10n.FromServerTime(Sql.ToDateTime(rdr["DATE_TIME_START"])); } if (rdr["DATE_TIME_END"] != DBNull.Value) { DATE_TIME_END.Value = T10n.FromServerTime(Sql.ToDateTime(rdr["DATE_TIME_END"])); } // 12/31/2007 Paul. TIME_FROM and TIME_TO are just time components, so they should not be translated. if (rdr["TIME_FROM"] != DBNull.Value) { TIME_FROM.Value = Sql.ToDateTime(rdr["TIME_FROM"]); } if (rdr["TIME_TO"] != DBNull.Value) { TIME_TO.Value = Sql.ToDateTime(rdr["TIME_TO"]); } try { JOB.SelectedValue = Sql.ToString(rdr["JOB"]); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } try { STATUS.SelectedValue = Sql.ToString(rdr["STATUS"]); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } } } } } } } 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.Schedulers") + " - " + ctlModuleHeader.Title); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = ex.Message; } }