コード例 #1
0
 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);
     }
 }
コード例 #2
0
 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());
             }
         }
     }
 }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
 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");
 }
コード例 #5
0
 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");
 }
コード例 #6
0
 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");
 }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
 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");
 }
コード例 #9
0
 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;
     }
 }
コード例 #10
0
 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());
                 }
             }
         }
     }
 }
コード例 #11
0
 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");
 }
コード例 #12
0
 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");
 }
コード例 #13
0
        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());
                }
            }
        }
コード例 #14
0
 protected void ctlCalendar_DayRender(Object source, DayRenderEventArgs e)
 {
     // 01/16/2007 Paul.  Catch any exceptions and log them. We are having a problem with duplicate ASSIGNED_USER_ID parameters.
     try
     {
         // Add custom text to cell in the Calendar control.
         if (!e.Day.IsOtherMonth)
         {
             DataView vwMain      = new DataView(dtMain);
             DateTime dtDAY_START = e.Day.Date;
             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.
             CultureInfo ciEnglish             = CultureInfo.CreateSpecificCulture("en-US");
             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;
             //MonthRow ctlMonthRow = LoadControl("MonthRow.ascx") as MonthRow;
             //ctlMonthRow.DataSource = vwMain;
             //e.Cell.Controls.Add(ctlMonthRow);
             //ctlMonthRow.DataBind();
             foreach (DataRowView row in vwMain)
             {
                 HtmlGenericControl div = new HtmlGenericControl("div");
                 div.Attributes.Add("style", "margin-top: 1px;");
                 e.Cell.Controls.Add(div);
                 HtmlTable tbl = new HtmlTable();
                 div.Controls.Add(tbl);
                 tbl.CellPadding = 0;
                 tbl.CellSpacing = 0;
                 tbl.Border      = 0;
                 tbl.Width       = "100%";
                 tbl.Attributes.Add("class", "monthCalBodyDayItem");
                 HtmlTableRow tr = new HtmlTableRow();
                 tbl.Rows.Add(tr);
                 HtmlTableCell tdIcon = new HtmlTableCell();
                 tr.Cells.Add(tdIcon);
                 tdIcon.Attributes.Add("class", "monthCalBodyDayIconTd");
                 Image img = new Image();
                 tdIcon.Controls.Add(img);
                 img.ImageUrl      = Session["themeURL"] + "images/" + Sql.ToString(row["ACTIVITY_TYPE"]) + ".gif";
                 img.AlternateText = L10n.Term(Sql.ToString(row["STATUS"])) + ": " + Sql.ToString(row["NAME"]);
                 img.BorderWidth   = 0;
                 img.Width         = 16;
                 img.Height        = 16;
                 img.ImageAlign    = ImageAlign.AbsMiddle;
                 HtmlTableCell tdLink = new HtmlTableCell();
                 tr.Cells.Add(tdLink);
                 tdLink.Attributes.Add("class", "monthCalBodyDayItemTd");
                 tdLink.Width = "100%";
                 HyperLink lnk = new HyperLink();
                 tdLink.Controls.Add(lnk);
                 lnk.Text        = L10n.Term(Sql.ToString(row["STATUS"])) + ": " + Sql.ToString(row["NAME"]);
                 lnk.NavigateUrl = "../" + Sql.ToString(row["ACTIVITY_TYPE"]) + "/view.aspx?id=" + Sql.ToString(row["ID"]);
                 lnk.CssClass    = "monthCalBodyDayItemLink";
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
         lblError.Text += ex.Message;
     }
 }
コード例 #15
0
        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());
                }
            }
        }
コード例 #16
0
 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());
             }
         }
     }
 }
コード例 #17
0
        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;
            }
        }
コード例 #18
0
        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;
                    }
                }
            }
        }
コード例 #19
0
        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();
            }
        }
コード例 #20
0
        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;
            }
        }
コード例 #21
0
        protected void BindGrid()
        {
            try
            {
                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    string sSQL;
                    sSQL = "select *                                                       " + ControlChars.CrLf
                           + "  from vwACTIVITIES_List                                       " + ControlChars.CrLf;
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        cmd.CommandText = sSQL;
                        DateTime dtDATE_START = new DateTime(Math.Max(1753, dtCurrentDate.Year), dtCurrentDate.Month, 1, 0, 0, 0);
                        DateTime dtDATE_END   = dtDATE_START.AddMonths(1);
                        // 11/27/2006 Paul.  Make sure to filter relationship data based on team access rights.
                        Security.Filter(cmd, "Calls", "list");
                        // 01/16/2007 Paul.  Use AppendParameter so that duplicate ASSIGNED_USER_ID can be avoided.
                        // 01/19/2007 Paul.  Fix AppendParamenter.  @ should not be used in field name.
                        Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID");
                        cmd.CommandText += "   and (   DATE_START >= @DATE_START and DATE_START < @DATE_END" + ControlChars.CrLf;
                        cmd.CommandText += "        or DATE_END   >= @DATE_START and DATE_END   < @DATE_END" + ControlChars.CrLf;
                        cmd.CommandText += "        or DATE_START <  @DATE_START and DATE_END   > @DATE_END" + ControlChars.CrLf;
                        cmd.CommandText += "       )                                                       " + ControlChars.CrLf;
                        cmd.CommandText += " order by DATE_START asc, NAME asc                             " + ControlChars.CrLf;
                        // 03/19/2007 Paul.  Need to query activities based on server time.
                        Sql.AddParameter(cmd, "@DATE_START", T10n.ToServerTime(dtDATE_START));
                        Sql.AddParameter(cmd, "@DATE_END", T10n.ToServerTime(dtDATE_END));

                        if (bDebug)
                        {
                            RegisterClientScriptBlock("vwACTIVITIES_List", Sql.ClientScriptBlock(cmd));
                        }

                        try
                        {
                            using (DbDataAdapter da = dbf.CreateDataAdapter())
                            {
                                ((IDbDataAdapter)da).SelectCommand = cmd;
                                dtMain = new DataTable();
                                da.Fill(dtMain);
                                // 07/24/2005 Paul.  Since this is not a dynamic grid, we must convert the status manually.
                                foreach (DataRow row in dtMain.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;
                                    }
                                }
                            }
                        }
                        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;
            }
        }
コード例 #22
0
 protected void Page_Command(object sender, CommandEventArgs e)
 {
     try
     {
         if (e.CommandName == "Task.Close")
         {
             Guid gID = Sql.ToGuid(e.CommandArgument);
             Response.Redirect("edit.aspx?ID=" + gID.ToString() + "&STATUS=Completed");
         }
         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, "TASKS");
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     // 07/09/2006 Paul.  The date conversion was moved out of the MassUpdate control.
                     SqlProcs.spTASKS_MassUpdate(sIDs, ctlMassUpdate.ASSIGNED_USER_ID, ctlMassUpdate.STATUS, T10n.ToServerTime(ctlMassUpdate.DATE_DUE), T10n.ToServerTime(ctlMassUpdate.DATE_START), ctlMassUpdate.PRIORITY);
                     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, "TASKS");
                 if (!Sql.IsEmptyString(sIDs))
                 {
                     SqlProcs.spTASKS_MassDelete(sIDs);
                     Response.Redirect("default.aspx");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
         lblError.Text = ex.Message;
     }
 }
コード例 #23
0
        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;
                    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, "Calls", "list");
                        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;
                        // 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));
                        Sql.AppendGuids(cmd, lstUSERS, "ASSIGNED_USER_ID");
                        cmd.CommandText += " order by ASSIGNED_FULL_NAME" + ControlChars.CrLf;

                        if (bDebug)
                        {
                            RegisterClientScriptBlock("vwACTIVITIES_List.Users", Sql.ClientScriptBlock(cmd));
                        }

                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            da.Fill(dtUsers);
                        }
                    }


                    sSQL = "select *                                                       " + ControlChars.CrLf
                           + "  from vwACTIVITIES_List                                       " + 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, "Calls", "list");
                        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;
                        // 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));
                        Sql.AppendGuids(cmd, lstUSERS, "ASSIGNED_USER_ID");
                        cmd.CommandText += " order by ASSIGNED_FULL_NAME asc, DATE_START asc, NAME asc" + ControlChars.CrLf;

                        if (bDebug)
                        {
                            RegisterClientScriptBlock("vwACTIVITIES_List.Data", 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;
                                        }
                                    }
                                    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);
                                            // 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);

                                            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_ServerTime = dtDAY_START_ServerTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat);
                                            string sDAY_END_ServerTime   = dtDAY_END_ServerTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat);
                                            vwMain.RowFilter = "ASSIGNED_USER_ID = '" + gASSIGNED_USER_ID.ToString() + "'" + ControlChars.CrLf
                                                               + "and (   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
                                                               + "    )" + ControlChars.CrLf;
#if DEBUG
//											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);
                            lblError.Text = ex.Message;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                lblError.Text = ex.Message;
            }
        }
コード例 #24
0
 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;
     }
 }
コード例 #25
0
        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);
            }
        }