private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    // 06/02/2006 Paul.  Buttons should be hidden if the user does not have access.
                    int nACLACCESS_Delete = Security.GetUserAccess(m_sMODULE, "delete");
                    int nACLACCESS_Edit   = Security.GetUserAccess(m_sMODULE, "edit");
                    btnDelete.Visible = (nACLACCESS_Delete >= 0);
                    btnUpdate.Visible = (nACLACCESS_Edit >= 0);

                    lstLEAD_SOURCE.DataSource = SplendidCache.List("lead_source_dom");
                    lstLEAD_SOURCE.DataBind();
                    lstLEAD_SOURCE.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
            //this.DataBind();  // Need to bind so that Text of the Button gets updated.
            reqNAME.ErrorMessage = L10n.Term(".ERR_MISSING_REQUIRED_FIELDS") + " " + L10n.Term("Terminology.LBL_LIST_NAME") + "<br>";
            if (!IsPostBack)
            {
                // 01/12/2006 Paul.  Language cannot be null.
                lstLANGUAGE.DataSource = SplendidCache.Languages();
                lstLANGUAGE.DataBind();

                DataTable dtModules = SplendidCache.Modules().Copy();
                dtModules.Rows.InsertAt(dtModules.NewRow(), 0);
                lstMODULE_NAME.DataSource = dtModules;
                lstMODULE_NAME.DataBind();
                // 01/12/2006 Paul.  Insert is failing, but I don't know why.
                // It might be because the NewRecord control is loaded using LoadControl.
                // Very odd as the Search Control is not having a problem inserting a value.
                //lstMODULE_NAME.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));

                DataTable dtPickLists = SplendidCache.TerminologyPickLists().Copy();
                dtPickLists.Rows.InsertAt(dtPickLists.NewRow(), 0);
                lstLIST_NAME.DataSource = dtPickLists;
                lstLIST_NAME.DataBind();
                //lstLIST_NAME.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));

                try
                {
                    // 01/12/2006 Paul.  Set default value to current language.
                    // 01/12/2006 Paul.  This is not working.  Use client-side script to select the default.
                    lstLANGUAGE.SelectedValue = L10N.NormalizeCulture(L10n.NAME);
                }
                catch (Exception ex)
                {
                    SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                }
                //this.DataBind();
            }
        }
 private void Page_Load(object sender, System.EventArgs e)
 {
     if (!this.IsPostBack)
     {
         DataTable dtCustomEditModules = SplendidCache.CustomEditModules();
         foreach (DataRow row in dtCustomEditModules.Rows)
         {
             row["DISPLAY_NAME"] = L10n.Term(".moduleList." + row["DISPLAY_NAME"]);
         }
         lstMODULE_NAME.DataSource = dtCustomEditModules;
         lstMODULE_NAME.DataBind();
         // 01/05/2006 Paul.  Can't seem to set the selected value from ListView.ascx.
         string sMODULE_NAME = Sql.ToString(Request["MODULE_NAME"]);
         try
         {
             lstMODULE_NAME.SelectedValue = sMODULE_NAME;
         }
         catch
         {
         }
     }
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 11/05/2007 Paul.  Don't show panel if it was manually hidden.
            this.Visible = this.Visible && (SplendidCRM.Security.GetUserAccess(m_sMODULE, "list") >= 0);
            // 09/09/2007 Paul.  We are having trouble dynamically adding user controls to the WebPartZone.
            // Instead, control visibility manually here.  This approach as the added benefit of hiding the
            // control even if the WebPartManager has moved it to an alternate zone.
            if (this.Visible && this.Visible && !Sql.IsEmptyString(sDetailView))
            {
                // 01/17/2008 Paul.  We need to use the sDetailView property and not the hard-coded view name.
                DataView vwFields = new DataView(SplendidCache.DetailViewRelationships(sDetailView));
                vwFields.RowFilter = "CONTROL_NAME = '~/Opportunities/MyPipeline'";
                this.Visible       = vwFields.Count > 0;
            }
            if (!this.Visible)
            {
                return;
            }

            valDATE_START.ErrorMessage = L10n.Term(".ERR_INVALID_DATE");
            valDATE_END.ErrorMessage   = L10n.Term(".ERR_INVALID_DATE");
            if (!IsPostBack)
            {
                lstSALES_STAGE.DataSource = SplendidCache.List("sales_stage_dom");
                lstSALES_STAGE.DataBind();
                // 09/14/2005 Paul.  Default to today, and all sales stages.
                foreach (ListItem item in lstSALES_STAGE.Items)
                {
                    item.Selected = true;
                }
                // 07/09/2006 Paul.  The date is passed in TimeZone time, so convert from server time.
                ctlDATE_START.Value = T10n.FromServerTime(DateTime.Today);
                ctlDATE_END.Value   = T10n.FromServerTime(new DateTime(2100, 1, 1));
                // 09/15/2005 Paul.  Maintain the pipeline query string separately so that we can respond to specific submit requests
                // and ignore all other control events on the page.
                ViewState["MyPipelineQueryString"] = PipelineQueryString();
            }
        }
示例#5
0
 private void Page_Load(object sender, System.EventArgs e)
 {
     if (!this.IsPostBack)
     {
         // 05/20/2007 Paul.  Make sure to copy the table before modifying the data, otherwise the changes will get applied to the cached table.
         DataTable dtCustomEditModules = SplendidCache.CustomEditModules().Copy();
         foreach (DataRow row in dtCustomEditModules.Rows)
         {
             row["DISPLAY_NAME"] = L10n.Term(".moduleList." + row["DISPLAY_NAME"]);
         }
         lstMODULE_NAME.DataSource = dtCustomEditModules;
         lstMODULE_NAME.DataBind();
         // 01/05/2006 Paul.  Can't seem to set the selected value from ListView.ascx.
         string sMODULE_NAME = Sql.ToString(Request["MODULE_NAME"]);
         try
         {
             lstMODULE_NAME.SelectedValue = sMODULE_NAME;
         }
         catch
         {
         }
     }
 }
示例#6
0
 private void Page_Load(object sender, System.EventArgs e)
 {
     if (!IsPostBack)
     {
         lstLEAD_SOURCE.DataSource = SplendidCache.List("lead_source_dom");
         lstLEAD_SOURCE.DataBind();
         lstLEAD_SOURCE.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
         lstUSERS.DataSource = SplendidCache.ActiveUsers();
         lstUSERS.DataBind();
         // 09/14/2005 Paul.  Default to today, and all leads.
         foreach (ListItem item in lstLEAD_SOURCE.Items)
         {
             item.Selected = true;
         }
         foreach (ListItem item in lstUSERS.Items)
         {
             item.Selected = true;
         }
         // 09/15/2005 Paul.  Maintain the pipeline query string separately so that we can respond to specific submit requests
         // and ignore all other control events on the page.
         ViewState["OppByLeadSourceByOutcomeQueryString"] = PipelineQueryString();
     }
 }
示例#7
0
        public void RefreshSavedSearches(Guid gID)
        {
            txtSavedSearchName.Text   = String.Empty;
            lstColumns.SelectedIndex  = 0;
            radSavedSearchASC.Checked = true;
            SplendidCache.ClearSavedSearch(m_sMODULE);

            DataView vwSavedSearch = new DataView(SplendidCache.SavedSearch(m_sMODULE));

            vwSavedSearch.RowFilter     = "NAME is not null";
            lstSavedSearches.DataSource = vwSavedSearch;
            lstSavedSearches.DataBind();
            lstSavedSearches.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
            if (Sql.IsEmptyGuid(gID))
            {
                lstSavedSearches.SelectedIndex = 0;
            }
            else
            {
                lstSavedSearches.SelectedValue = gID.ToString();
            }
            lstSavedSearches_Changed(lstSavedSearches, null);
        }
示例#8
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    // 06/02/2006 Paul.  Buttons should be hidden if the user does not have access.
                    int nACLACCESS_Delete = Security.GetUserAccess(m_sMODULE, "delete");
                    int nACLACCESS_Edit   = Security.GetUserAccess(m_sMODULE, "edit");
                    btnDelete.Visible = (nACLACCESS_Delete >= 0);
                    btnUpdate.Visible = (nACLACCESS_Edit >= 0);

                    lstSTATUS.DataSource = SplendidCache.List("bug_status_dom");
                    lstSTATUS.DataBind();
                    lstSTATUS.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                    lstPRIORITY.DataSource = SplendidCache.List("bug_priority_dom");
                    lstPRIORITY.DataBind();
                    lstPRIORITY.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                    lstRESOLUTION.DataSource = SplendidCache.List("bug_resolution_dom");
                    lstRESOLUTION.DataBind();
                    lstRESOLUTION.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                    lstTYPE.DataSource = SplendidCache.List("bug_type_dom");
                    lstTYPE.DataBind();
                    lstTYPE.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                    lstSOURCE.DataSource = SplendidCache.List("source_dom");
                    lstSOURCE.DataBind();
                    lstSOURCE.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                    lstPRODUCT_CATEGORY.DataSource = SplendidCache.List("product_category_dom");
                    lstPRODUCT_CATEGORY.DataBind();
                    lstPRODUCT_CATEGORY.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
            }
        }
 protected void Page_Command(Object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Save")
     {
         if (Page.IsValid)
         {
             try
             {
                 Guid gID = Guid.Empty;
                 SqlProcs.spTERMINOLOGY_LIST_Insert(ref gID, String.Empty, L10n.NAME, String.Empty, txtNAME.Text, 1, String.Empty);
                 // 01/20/2006 Paul.  Clear the cache.
                 SplendidCache.ClearTerminologyPickLists();
                 // 01/16/2006 Paul.  If successful, go to dropdown editing.
                 Response.Redirect("default.aspx?DROPDOWN=" + txtNAME.Text);
             }
             catch (Exception ex)
             {
                 SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                 ctlEditButtons.ErrorText = ex.Message;
                 return;
             }
         }
     }
 }
示例#10
0
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Save")
            {
                try
                {
                    // 01/16/2006 Paul.  Enable validator before validating page.
                    this.ValidateEditViewFields(m_sMODULE + ".EditView");
                    this.ValidateEditViewFields(m_sMODULE + ".EditOptions");

                    if (Page.IsValid)
                    {
                        DropDownList SERVICE = FindControl("SERVICE") as DropDownList;
                        if (SERVICE != null)
                        {
                            if (SERVICE.SelectedValue == "imap")
                            {
                                ctlEditButtons.ErrorText += "POP3 is the only supported service at this time. ";
                                return;
                            }
                        }
                        DropDownList MAILBOX_TYPE = FindControl("MAILBOX_TYPE") as DropDownList;
                        if (MAILBOX_TYPE != null)
                        {
                            if (MAILBOX_TYPE.SelectedValue != "bounce")
                            {
                                ctlEditButtons.ErrorText += "Bounce handling is the only supported action at this time. ";
                                return;
                            }
                        }
                    }
                    if (Page.IsValid)
                    {
                        // 01/08/2008 Paul.  If the encryption key does not exist, then we must create it and we must save it back to the database.
                        // 01/08/2008 Paul.  SugarCRM uses blowfish for the inbound email encryption, but we will not since .NET 2.0 does not support blowfish natively.
                        Guid gINBOUND_EMAIL_KEY = Sql.ToGuid(Application["CONFIG.InboundEmailKey"]);
                        if (Sql.IsEmptyGuid(gINBOUND_EMAIL_KEY))
                        {
                            gINBOUND_EMAIL_KEY = Guid.NewGuid();
                            SqlProcs.spCONFIG_Update("mail", "InboundEmailKey", gINBOUND_EMAIL_KEY.ToString());
                            Application["CONFIG.InboundEmailKey"] = gINBOUND_EMAIL_KEY;
                        }
                        Guid gINBOUND_EMAIL_IV = Sql.ToGuid(Application["CONFIG.InboundEmailIV"]);
                        if (Sql.IsEmptyGuid(gINBOUND_EMAIL_IV))
                        {
                            gINBOUND_EMAIL_IV = Guid.NewGuid();
                            SqlProcs.spCONFIG_Update("mail", "InboundEmailIV", gINBOUND_EMAIL_IV.ToString());
                            Application["CONFIG.InboundEmailIV"] = gINBOUND_EMAIL_IV;
                        }

                        string            sCUSTOM_MODULE = "INBOUND_EMAIL";
                        DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                        DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            con.Open();
                            // 11/18/2007 Paul.  Use the current values for any that are not defined in the edit view.
                            DataRow   rowCurrent = null;
                            DataTable dtCurrent  = new DataTable();
                            if (!Sql.IsEmptyGuid(gID))
                            {
                                string sSQL;
                                sSQL = "select *                    " + ControlChars.CrLf
                                       + "  from vwINBOUND_EMAILS_Edit" + ControlChars.CrLf
                                       + " where ID = @ID             " + ControlChars.CrLf;
                                using (IDbCommand cmd = con.CreateCommand())
                                {
                                    cmd.CommandText = sSQL;
                                    Sql.AddParameter(cmd, "@ID", gID);
                                    using (DbDataAdapter da = dbf.CreateDataAdapter())
                                    {
                                        ((IDbDataAdapter)da).SelectCommand = cmd;
                                        da.Fill(dtCurrent);
                                        if (dtCurrent.Rows.Count > 0)
                                        {
                                            rowCurrent = dtCurrent.Rows[0];
                                        }
                                        else
                                        {
                                            // 11/19/2007 Paul.  If the record is not found, clear the ID so that the record cannot be updated.
                                            // It is possible that the record exists, but that ACL rules prevent it from being selected.
                                            gID = Guid.Empty;
                                        }
                                    }
                                }
                            }
                            using (IDbTransaction trn = con.BeginTransaction())
                            {
                                try
                                {
                                    string sEMAIL_PASSWORD = new DynamicControl(this, "EMAIL_PASSWORD").Text;
                                    if (sEMAIL_PASSWORD == "**********")
                                    {
                                        if (rowCurrent != null)
                                        {
                                            sEMAIL_PASSWORD = Sql.ToString(rowCurrent["EMAIL_PASSWORD"]);
                                        }
                                        else
                                        {
                                            sEMAIL_PASSWORD = "";
                                        }
                                    }
                                    else
                                    {
                                        string sENCRYPTED_EMAIL_PASSWORD = Security.EncryptPassword(sEMAIL_PASSWORD, gINBOUND_EMAIL_KEY, gINBOUND_EMAIL_IV);
                                        if (Security.DecryptPassword(sENCRYPTED_EMAIL_PASSWORD, gINBOUND_EMAIL_KEY, gINBOUND_EMAIL_IV) != sEMAIL_PASSWORD)
                                        {
                                            throw(new Exception("Decryption failed"));
                                        }
                                        sEMAIL_PASSWORD = sENCRYPTED_EMAIL_PASSWORD;
                                    }
                                    SqlProcs.spINBOUND_EMAILS_Update
                                        (ref gID
                                        , new DynamicControl(this, rowCurrent, "NAME").Text
                                        , new DynamicControl(this, rowCurrent, "STATUS").SelectedValue
                                        , new DynamicControl(this, rowCurrent, "SERVER_URL").Text
                                        , new DynamicControl(this, rowCurrent, "EMAIL_USER").Text
                                        , sEMAIL_PASSWORD
                                        , Sql.ToInteger(new DynamicControl(this, rowCurrent, "PORT").Text)
                                        , new DynamicControl(this, rowCurrent, "MAILBOX_SSL").Checked
                                        , new DynamicControl(this, rowCurrent, "SERVICE").SelectedValue
                                        , "INBOX"
                                        , new DynamicControl(this, rowCurrent, "MARK_READ").Checked
                                        , new DynamicControl(this, rowCurrent, "ONLY_SINCE").Checked
                                        , new DynamicControl(this, rowCurrent, "MAILBOX_TYPE").SelectedValue
                                        , new DynamicControl(this, rowCurrent, "TEMPLATE_ID").ID
                                        , new DynamicControl(this, rowCurrent, "GROUP_ID").ID
                                        , new DynamicControl(this, rowCurrent, "FROM_NAME").Text
                                        , new DynamicControl(this, rowCurrent, "FROM_ADDR").Text
                                        , new DynamicControl(this, rowCurrent, "FILTER_DOMAIN").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);
                                    ctlEditButtons.ErrorText = ex.Message;
                                    return;
                                }
                            }
                        }
                        SplendidCache.ClearEmailGroups();
                        SplendidCache.ClearInboundEmails();
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
                catch (Exception ex)
                {
                    SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                    ctlEditButtons.ErrorText = ex.Message;
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 09/09/2006 Paul.  Visibility is already controlled by the ASPX page,
            // but since this control is used on the home page, we need to apply the module specific rules.
            // 11/05/2007 Paul.  Don't show panel if it was manually hidden.
            this.Visible = this.Visible && (SplendidCRM.Security.GetUserAccess(m_sMODULE, "list") >= 0);
            // 09/09/2007 Paul.  We are having trouble dynamically adding user controls to the WebPartZone.
            // Instead, control visibility manually here.  This approach as the added benefit of hiding the
            // control even if the WebPartManager has moved it to an alternate zone.
            if (this.Visible && this.Visible && !Sql.IsEmptyString(sDetailView))
            {
                // 01/17/2008 Paul.  We need to use the sDetailView property and not the hard-coded view name.
                DataView vwFields = new DataView(SplendidCache.DetailViewRelationships(sDetailView));
                vwFields.RowFilter = "CONTROL_NAME = '~/Contacts/MyContacts'";
                this.Visible       = vwFields.Count > 0;
            }
            if (!this.Visible)
            {
                return;
            }

            DbProviderFactory dbf = DbProviderFactories.GetFactory();

            using (IDbConnection con = dbf.CreateConnection())
            {
                string sSQL;
                sSQL = "select *                " + ControlChars.CrLf
                       + "  from vwCONTACTS_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);

                    if (bDebug)
                    {
                        RegisterClientScriptBlock("vwCONTACTS_List", 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_ENTERED";
                                    grdMain.SortOrder  = "desc";
                                    grdMain.ApplySort();
                                }
                                // 09/15/2005 Paul. We must always bind, otherwise a Dashboard refresh will display the grid with empty rows.
                                grdMain.DataBind();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                        lblError.Text = ex.Message;
                    }
                }
            }
            if (!IsPostBack)
            {
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0);
            if (!this.Visible)
            {
                return;
            }

            try
            {
                // 01/21/2006 Paul.  If there is an error sending the email, we want to make sure to reuse the ID,
                // otherwise multiple emails get created as the user tries to resend.
                gID = Sql.ToGuid(ViewState["ID"]);
                if (Sql.IsEmptyGuid(gID))
                {
                    gID = Sql.ToGuid(Request["ID"]);
                }
                if (!IsPostBack)
                {
                    sEMAIL_TYPE = Sql.ToString(Request["TYPE"]).ToLower();
                    if (sEMAIL_TYPE != "archived")
                    {
                        sEMAIL_TYPE = "draft";
                    }
                    ctlEditButtons.Visible  = !PrintView && (sEMAIL_TYPE != "draft");
                    ctlEmailButtons.Visible = !PrintView && (sEMAIL_TYPE == "draft");

                    if (Sql.IsEmptyGuid(gID))
                    {
                        ctlModuleHeader.EnableModuleLabel = false;
                        if (sEMAIL_TYPE == "archived")
                        {
                            ctlModuleHeader.Title = L10n.Term("Emails.LBL_ARCHIVED_MODULE_NAME") + ":";
                        }
                        else
                        {
                            ctlModuleHeader.Title = L10n.Term("Emails.LBL_COMPOSE_MODULE_NAME") + ":";
                        }
                        // 04/16/2006 Paul.  The subject is not required.
                        //lblNAME_REQUIRED .Visible = (sEMAIL_TYPE == "archived");
                        //reqNAME.Enabled          =  lblNAME_REQUIRED.Visible;
                        ctlDATE_START.Visible              = (sEMAIL_TYPE == "archived");
                        spnDATE_START.Visible              = ctlDATE_START.Visible;
                        spnTEMPLATE_LABEL.Visible          = (sEMAIL_TYPE == "draft");
                        lstEMAIL_TEMPLATE.Visible          = spnTEMPLATE_LABEL.Visible;
                        trNOTE_SEMICOLON.Visible           = (sEMAIL_TYPE == "draft");
                        trFROM.Visible                     = !trNOTE_SEMICOLON.Visible;
                        ViewState["TYPE"]                  = sEMAIL_TYPE;
                        ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title;
                    }

                    lstASSIGNED_USER_ID.DataSource = SplendidCache.AssignedUser();
                    lstASSIGNED_USER_ID.DataBind();
                    lstASSIGNED_USER_ID.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                    lstPARENT_TYPE.DataSource = SplendidCache.List("record_type_display");
                    lstPARENT_TYPE.DataBind();
                    if (lstEMAIL_TEMPLATE.Visible)
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *                     " + ControlChars.CrLf
                                   + "  from vwEMAIL_TEMPLATES_List" + ControlChars.CrLf
                                   + " order by NAME               " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                using (DbDataAdapter da = dbf.CreateDataAdapter())
                                {
                                    ((IDbDataAdapter)da).SelectCommand = cmd;
                                    using (DataTable dt = new DataTable())
                                    {
                                        da.Fill(dt);
                                        lstEMAIL_TEMPLATE.DataSource = dt.DefaultView;
                                        lstEMAIL_TEMPLATE.DataBind();
                                        lstEMAIL_TEMPLATE.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                                    }
                                }
                            }
                        }
                    }
                    // 07/29/2005 Paul.  SugarCRM 3.0 does not allow the NONE option.
                    //lstPARENT_TYPE     .Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                    Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]);
                    if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *            " + ControlChars.CrLf
                                   + "  from vwEMAILS_Edit" + ControlChars.CrLf
                                   + " where ID = @ID     " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                if (!Sql.IsEmptyGuid(gDuplicateID))
                                {
                                    Sql.AddParameter(cmd, "@ID", gDuplicateID);
                                    gID = Guid.Empty;
                                }
                                else
                                {
                                    Sql.AddParameter(cmd, "@ID", gID);
                                }
                                con.Open();
#if DEBUG
                                Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
#endif
                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        ctlModuleHeader.Title += Sql.ToString(rdr["NAME"]);
                                        Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                                        Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title);
                                        ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title;
                                        ViewState["ID"] = gID;

                                        txtNAME.Text        = Sql.ToString(rdr["NAME"]);
                                        ctlDATE_START.Value = T10n.FromServerTime(rdr["DATE_START"]);
                                        txtPARENT_ID.Value  = Sql.ToString(rdr["PARENT_ID"]);
                                        txtPARENT_NAME.Text = Sql.ToString(rdr["PARENT_NAME"]);
                                        txtFROM_NAME.Value  = Sql.ToString(rdr["FROM_NAME"]);
                                        txtFROM_ADDR.Text   = Sql.ToString(rdr["FROM_ADDR"]);

                                        txtTO_ADDRS.Text          = Sql.ToString(rdr["TO_ADDRS"]);
                                        txtCC_ADDRS.Text          = Sql.ToString(rdr["CC_ADDRS"]);
                                        txtBCC_ADDRS.Text         = Sql.ToString(rdr["BCC_ADDRS"]);
                                        txtTO_ADDRS_IDS.Value     = Sql.ToString(rdr["TO_ADDRS_IDS"]);
                                        txtTO_ADDRS_NAMES.Value   = Sql.ToString(rdr["TO_ADDRS_NAMES"]);
                                        txtTO_ADDRS_EMAILS.Value  = Sql.ToString(rdr["TO_ADDRS_EMAILS"]);
                                        txtCC_ADDRS_IDS.Value     = Sql.ToString(rdr["CC_ADDRS_IDS"]);
                                        txtCC_ADDRS_NAMES.Value   = Sql.ToString(rdr["CC_ADDRS_NAMES"]);
                                        txtCC_ADDRS_EMAILS.Value  = Sql.ToString(rdr["CC_ADDRS_EMAILS"]);
                                        txtBCC_ADDRS_IDS.Value    = Sql.ToString(rdr["BCC_ADDRS_IDS"]);
                                        txtBCC_ADDRS_NAMES.Value  = Sql.ToString(rdr["BCC_ADDRS_NAMES"]);
                                        txtBCC_ADDRS_EMAILS.Value = Sql.ToString(rdr["BCC_ADDRS_EMAILS"]);

                                        // 04/16/2006 Paul.  Since the Plug-in saves body in DESCRIPTION, we need to continue to use it as the primary source of data.
                                        txtDESCRIPTION.Value = Sql.ToString(rdr["DESCRIPTION"]);
                                        try
                                        {
                                            lstPARENT_TYPE.SelectedValue = Sql.ToString(rdr["PARENT_TYPE"]);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                                        }
                                        try
                                        {
                                            lstASSIGNED_USER_ID.SelectedValue = Sql.ToString(rdr["ASSIGNED_USER_ID"]);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                                        }
                                        // 11/17/2005 Paul.  Archived emails allow editing of the Date & Time Sent.
                                        sEMAIL_TYPE = Sql.ToString(rdr["TYPE"]).ToLower();
                                        switch (sEMAIL_TYPE)
                                        {
                                        case "archived":
                                            ctlModuleHeader.Title = L10n.Term("Emails.LBL_ARCHIVED_MODULE_NAME") + ":" + txtNAME.Text;
                                            break;

                                        case "out":
                                            ctlModuleHeader.Title = L10n.Term("Emails.LBL_LIST_FORM_SENT_TITLE") + ":" + txtNAME.Text;
                                            break;

                                        default:
                                            sEMAIL_TYPE           = "draft";
                                            ctlModuleHeader.Title = L10n.Term("Emails.LBL_COMPOSE_MODULE_NAME") + ":" + txtNAME.Text;
                                            break;
                                        }
                                        if (sEMAIL_TYPE == "out")
                                        {
                                            // 01/21/2006 Paul.  Editing is not allowed for sent emails.
                                            Response.Redirect("view.aspx?ID=" + gID.ToString());
                                            return;
                                        }
                                        // 04/16/2006 Paul.  The subject is not required.
                                        //lblNAME_REQUIRED .Visible = (sEMAIL_TYPE == "archived");
                                        //reqNAME.Enabled = lblNAME_REQUIRED.Visible;
                                        ctlDATE_START.Visible             = (sEMAIL_TYPE == "archived");
                                        spnDATE_START.Visible             = ctlDATE_START.Visible;
                                        spnTEMPLATE_LABEL.Visible         = (sEMAIL_TYPE == "draft");
                                        lstEMAIL_TEMPLATE.Visible         = spnTEMPLATE_LABEL.Visible;
                                        trNOTE_SEMICOLON.Visible          = (sEMAIL_TYPE == "draft");
                                        trFROM.Visible                    = !trNOTE_SEMICOLON.Visible;
                                        ctlModuleHeader.EnableModuleLabel = false;

                                        ctlEditButtons.Visible  = !PrintView && (sEMAIL_TYPE != "draft");
                                        ctlEmailButtons.Visible = !PrintView && (sEMAIL_TYPE == "draft");
                                        ViewState["TYPE"]       = sEMAIL_TYPE;
                                    }
                                }
                            }
                            sSQL = "select *                   " + ControlChars.CrLf
                                   + "  from vwEMAILS_Attachments" + ControlChars.CrLf
                                   + " where EMAIL_ID = @EMAIL_ID" + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Sql.AddParameter(cmd, "@EMAIL_ID", gID);
#if DEBUG
                                Page.RegisterClientScriptBlock("vwEMAILS_Attachments", Sql.ClientScriptBlock(cmd));
#endif
                                using (DbDataAdapter da = dbf.CreateDataAdapter())
                                {
                                    ((IDbDataAdapter)da).SelectCommand = cmd;
                                    using (DataTable dt = new DataTable())
                                    {
                                        da.Fill(dt);
                                        ctlAttachments.DataSource = dt.DefaultView;
                                        ctlAttachments.DataBind();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Guid gPARENT_ID = Sql.ToGuid(Request["PARENT_ID"]);
                        if (!Sql.IsEmptyGuid(gPARENT_ID))
                        {
                            string sMODULE      = String.Empty;
                            string sPARENT_TYPE = String.Empty;
                            string sPARENT_NAME = String.Empty;
                            SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
                            if (!Sql.IsEmptyGuid(gPARENT_ID))
                            {
                                txtPARENT_ID.Value  = gPARENT_ID.ToString();
                                txtPARENT_NAME.Text = sPARENT_NAME;
                                try
                                {
                                    lstPARENT_TYPE.SelectedValue = sPARENT_TYPE;
                                }
                                catch (Exception ex)
                                {
                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                                }
                                // 08/05/2006 Paul.  When an email is composed from a Lead, automatically set the To address.
                                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                                using (IDbConnection con = dbf.CreateConnection())
                                {
                                    string sSQL;
                                    sSQL = "select EMAIL1      " + ControlChars.CrLf
                                           + "  from vwLEADS_Edit" + ControlChars.CrLf
                                           + " where ID = @ID    " + ControlChars.CrLf;
                                    using (IDbCommand cmd = con.CreateCommand())
                                    {
                                        cmd.CommandText = sSQL;
                                        Sql.AddParameter(cmd, "@ID", gPARENT_ID);
                                        con.Open();
#if DEBUG
                                        Page.RegisterClientScriptBlock("vwLEADS_Edit", Sql.ClientScriptBlock(cmd));
#endif
                                        using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                        {
                                            if (rdr.Read())
                                            {
                                                txtTO_ADDRS.Text = Sql.ToString(rdr["EMAIL1"]);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        try
                        {
                            lstASSIGNED_USER_ID.SelectedValue = Security.USER_ID.ToString();
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                        }
                    }
                }
                else
                {
                    // 12/02/2005 Paul.  When validation fails, the header title does not retain its value.  Update manually.
                    ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]);
                    Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                    sEMAIL_TYPE = Sql.ToString(ViewState["TYPE"]);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                ctlEditButtons.ErrorText  = ex.Message;
                ctlEmailButtons.ErrorText = ex.Message;
            }
        }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            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")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "PROJECT_TASK";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                SqlProcs.spPROJECT_TASKS_Update
                                    (ref gID
                                    , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, "NAME").Text
                                    , new DynamicControl(this, "STATUS").SelectedValue
                                    , new DynamicControl(this, "DATE_DUE").DateValue
                                    , new DynamicControl(this, "DATE_START").DateValue
                                    , new DynamicControl(this, "PROJECT_ID").ID
                                    , new DynamicControl(this, "PRIORITY").SelectedValue
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , new DynamicControl(this, "ORDER_NUMBER").IntegerValue
                                    , new DynamicControl(this, "TASK_NUMBER").IntegerValue
                                    , new DynamicControl(this, "DEPENDS_ON_ID").ID
                                    , new DynamicControl(this, "MILESTONE_FLAG").Checked
                                    , new DynamicControl(this, "ESTIMATED_EFFORT").IntegerValue
                                    , new DynamicControl(this, "ACTUAL_EFFORT").IntegerValue
                                    , new DynamicControl(this, "UTILIZATION").IntegerValue
                                    , new DynamicControl(this, "PERCENT_COMPLETE").IntegerValue
                                    , 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;
                            }
                        }
                    }
                    // 11/17/2005 Paul.  SugarCRM does not redirect to the Project, even if the user changed it. Just do the same.
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
示例#14
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")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "BUGS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                //die("ERROR: uploaded file was too big: max filesize: {$sugar_config['upload_maxsize']}");
                                HtmlInputFile  fileATTACHMENT = FindControl("ATTACHMENT") as HtmlInputFile;
                                HttpPostedFile pstATTACHMENT  = null;
                                if (fileATTACHMENT != null)
                                {
                                    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()));
                                    }
                                }
                                SqlProcs.spBUGS_Update
                                    (ref gID
                                    , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, "NAME").Text
                                    , new DynamicControl(this, "STATUS").SelectedValue
                                    , new DynamicControl(this, "PRIORITY").SelectedValue
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , new DynamicControl(this, "RESOLUTION").SelectedValue
                                    , new DynamicControl(this, "RELEASE").SelectedValue
                                    , new DynamicControl(this, "TYPE").SelectedValue
                                    , new DynamicControl(this, "FIXED_IN_RELEASE").SelectedValue
                                    , new DynamicControl(this, "WORK_LOG").Text
                                    , new DynamicControl(this, "SOURCE").Text
                                    , new DynamicControl(this, "PRODUCT_CATEGORY").SelectedValue
                                    , sMODULE
                                    , gPARENT_ID
                                    , trn
                                    );
                                if (pstATTACHMENT != null)
                                {
                                    // 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 gAttachmentID = Guid.Empty;
                                        // 01/20/2006 Paul.  Must include in transaction
                                        SqlProcs.spBUG_ATTACHMENTS_Insert(ref gAttachmentID, gID, pstATTACHMENT.FileName, sFILENAME, sFILE_EXT, sFILE_MIME_TYPE, trn);
                                        LoadFile(gAttachmentID, pstATTACHMENT.InputStream, trn);
                                    }
                                }
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Save")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                this.ValidateEditViewFields(m_sMODULE + ".EditView");
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "CONTRACTS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        // 11/18/2007 Paul.  Use the current values for any that are not defined in the edit view.
                        DataRow   rowCurrent = null;
                        DataTable dtCurrent  = new DataTable();
                        if (!Sql.IsEmptyGuid(gID))
                        {
                            string sSQL;
                            sSQL = "select *               " + ControlChars.CrLf
                                   + "  from vwCONTRACTS_Edit" + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Security.Filter(cmd, m_sMODULE, "edit");
                                Sql.AppendParameter(cmd, gID, "ID", false);
                                using (DbDataAdapter da = dbf.CreateDataAdapter())
                                {
                                    ((IDbDataAdapter)da).SelectCommand = cmd;
                                    da.Fill(dtCurrent);
                                    if (dtCurrent.Rows.Count > 0)
                                    {
                                        rowCurrent = dtCurrent.Rows[0];
                                    }
                                    else
                                    {
                                        // 11/19/2007 Paul.  If the record is not found, clear the ID so that the record cannot be updated.
                                        // It is possible that the record exists, but that ACL rules prevent it from being selected.
                                        gID = Guid.Empty;
                                    }
                                }
                            }
                        }

                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                // 11/19/2006 Paul.  OPPORTUNITY_ID was added.
                                // 11/18/2007 Paul.  Use the current values for any that are not defined in the edit view.
                                // 11/30/2007 Paul.  Change TYPE to unique identifier and rename to TYPE_ID.
                                // 12/29/2007 Paul.  TEAM_ID is now in the stored procedure.
                                SqlProcs.spCONTRACTS_Update
                                    (ref gID
                                    , new DynamicControl(this, rowCurrent, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, rowCurrent, "NAME").Text
                                    , new DynamicControl(this, rowCurrent, "REFERENCE_CODE").Text
                                    , new DynamicControl(this, rowCurrent, "STATUS").Text
                                    , new DynamicControl(this, rowCurrent, "TYPE_ID").ID
                                    , new DynamicControl(this, rowCurrent, "ACCOUNT_ID").ID
                                    , new DynamicControl(this, rowCurrent, "OPPORTUNITY_ID").ID
                                    , new DynamicControl(this, rowCurrent, "START_DATE").DateValue
                                    , new DynamicControl(this, rowCurrent, "END_DATE").DateValue
                                    , new DynamicControl(this, rowCurrent, "COMPANY_SIGNED_DATE").DateValue
                                    , new DynamicControl(this, rowCurrent, "CUSTOMER_SIGNED_DATE").DateValue
                                    , new DynamicControl(this, rowCurrent, "EXPIRATION_NOTICE").DateValue
                                    , new DynamicControl(this, rowCurrent, "CURRENCY_ID").ID
                                    , new DynamicControl(this, rowCurrent, "TOTAL_CONTRACT_VALUE").DecimalValue
                                    , new DynamicControl(this, rowCurrent, "DESCRIPTION").Text
                                    , new DynamicControl(this, rowCurrent, "TEAM_ID").ID
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);

                                // 04/29/2007 Paul.  Assign quote if created from Quote.
                                Guid gQUOTE_ID = Sql.ToGuid(Request["QUOTE_ID"]);
                                if (!Sql.IsEmptyGuid(gQUOTE_ID))
                                {
                                    SqlProcs.spCONTRACTS_QUOTES_Update(gID, gQUOTE_ID, trn);
                                }
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                gID = Sql.ToGuid(Request["ID"]);
                Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE));
                if (!IsPostBack)
                {
                    lblDATEFORMAT.Text = "(" + Session["USER_SETTINGS/DATEFORMAT"] + ")";
                    lstOPPORTUNITY_SALES_STAGE.DataSource = SplendidCache.List("sales_stage_dom");
                    lstOPPORTUNITY_SALES_STAGE.DataBind();

                    chkCreateAccount.Attributes.Add("onclick", "return ToggleCreateAccount();");
                    chkCreateOpportunity.Attributes.Add("onclick", "return toggleDisplay('divCreateOpportunity');");
                    chkCreateAppointment.Attributes.Add("onclick", "return toggleDisplay('divCreateAppointment');");

                    Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]);
                    if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *              " + ControlChars.CrLf
                                   + "  from vwLEADS_Convert" + ControlChars.CrLf
                                   + " where ID = @ID       " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                if (!Sql.IsEmptyGuid(gDuplicateID))
                                {
                                    Sql.AddParameter(cmd, "@ID", gDuplicateID);
                                    gID = Guid.Empty;
                                }
                                else
                                {
                                    Sql.AddParameter(cmd, "@ID", gID);
                                }
                                con.Open();
#if DEBUG
                                Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
#endif
                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        ctlModuleHeader.Title = L10n.Term("Leads.LBL_CONVERTLEAD");
                                        Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);

                                        txtACCOUNT_NAME.Text       = Sql.ToString(rdr["ACCOUNT_NAME"]);
                                        txtACCOUNT_PHONE_WORK.Text = Sql.ToString(rdr["PHONE_WORK"]);
                                        // 01/31/2006 Paul.  Default start date and time is now.
                                        ctlAPPOINTMENT_DATE_START.Value = T10n.FromServerTime(DateTime.Now);
                                        txtAPPOINTMENT_TIME_START.Text  = T10n.FromServerTime(DateTime.Now).ToShortTimeString();

                                        this.AppendEditViewFields(m_sMODULE + ".ConvertView", tblMain, rdr);
                                        // 01/31/2006 Paul.  Save all data to be used later.
                                        for (int i = 0; i < rdr.FieldCount; i++)
                                        {
                                            ViewState[rdr.GetName(i)] = rdr.GetValue(i);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.AppendEditViewFields(m_sMODULE + ".ConvertView", tblMain, null);
                    }
                }
                else
                {
                    // 12/02/2005 Paul.  When validation fails, the header title does not retain its value.  Update manually.
                    ctlModuleHeader.Title = L10n.Term("Leads.LBL_CONVERTLEAD");
                    Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }
        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());
                }
            }
        }
 protected void Page_Command(Object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Save")
     {
         // 01/16/2006 Paul.  Enable validator before validating page.
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".ConvertView", this);
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".ConvertAddress", this);
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".ConvertDescription", this);
         if (Page.IsValid)
         {
             Guid              gLEAD_ID       = Guid.Empty;
             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
                     {
                         // 04/24/2006 Paul.  Upgrade to SugarCRM 4.2 Schema.
                         SqlProcs.spLEADS_ConvertProspect
                             (ref gLEAD_ID
                             , gID                                                                       // 01/31/2006 Paul.  Update the Prospect with this lead.
                             , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                             , new DynamicControl(this, "SALUTATION").SelectedValue
                             , new DynamicControl(this, "FIRST_NAME").Text
                             , new DynamicControl(this, "LAST_NAME").Text
                             , new DynamicControl(this, "TITLE").Text
                             , new DynamicControl(this, "REFERED_BY").Text
                             , new DynamicControl(this, "LEAD_SOURCE").SelectedValue
                             , new DynamicControl(this, "LEAD_SOURCE_DESCRIPTION").Text
                             , new DynamicControl(this, "STATUS").SelectedValue
                             , new DynamicControl(this, "STATUS_DESCRIPTION").Text
                             , new DynamicControl(this, "DEPARTMENT").Text
                             , Guid.Empty                                      // 06/24/2005. REPORTS_TO_ID is not used in version 3.0.
                             , 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
                             , new DynamicControl(this, "ALT_ADDRESS_STREET").Text
                             , new DynamicControl(this, "ALT_ADDRESS_CITY").Text
                             , new DynamicControl(this, "ALT_ADDRESS_STATE").Text
                             , new DynamicControl(this, "ALT_ADDRESS_POSTALCODE").Text
                             , new DynamicControl(this, "ALT_ADDRESS_COUNTRY").Text
                             , new DynamicControl(this, "DESCRIPTION").Text
                             , new DynamicControl(this, "ACCOUNT_NAME").Text
                             , new DynamicControl(this, "CAMPAIGN_ID").ID
                             , trn
                             );
                         SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                         trn.Commit();
                     }
                     catch (Exception ex)
                     {
                         trn.Rollback();
                         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.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());
         }
     }
 }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            Guid gCAMPAIGN_ID = Sql.ToGuid(Request["CAMPAIGN_ID"]);

            if (e.CommandName == "Save")
            {
                // 09/22/2007 Paul.  When the IE text box is disabled, it does not submit the data.
                // Correcting this behavior here seems reasonable.
                bool bIS_OPTOUT = new DynamicControl(this, "IS_OPTOUT").Checked;
                if (bIS_OPTOUT)
                {
                    new DynamicControl(this, "TRACKER_URL").Text = "RemoveMe.aspx";
                }

                // 01/16/2006 Paul.  Enable validator before validating page.
                this.ValidateEditViewFields(m_sMODULE + ".EditView");
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "CAMPAIGN_TRKRS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        // 11/18/2007 Paul.  Use the current values for any that are not defined in the edit view.
                        DataRow   rowCurrent = null;
                        DataTable dtCurrent  = new DataTable();
                        if (!Sql.IsEmptyGuid(gID))
                        {
                            string sSQL;
                            sSQL = "select *                    " + ControlChars.CrLf
                                   + "  from vwCAMPAIGN_TRKRS_Edit" + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Security.Filter(cmd, m_sMODULE, "edit");
                                Sql.AppendParameter(cmd, gID, "ID", false);
                                using (DbDataAdapter da = dbf.CreateDataAdapter())
                                {
                                    ((IDbDataAdapter)da).SelectCommand = cmd;
                                    da.Fill(dtCurrent);
                                    if (dtCurrent.Rows.Count > 0)
                                    {
                                        rowCurrent = dtCurrent.Rows[0];
                                    }
                                    else
                                    {
                                        // 11/19/2007 Paul.  If the record is not found, clear the ID so that the record cannot be updated.
                                        // It is possible that the record exists, but that ACL rules prevent it from being selected.
                                        gID = Guid.Empty;
                                    }
                                }
                            }
                        }

                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                // 11/18/2007 Paul.  Use the current values for any that are not defined in the edit view.
                                SqlProcs.spCAMPAIGN_TRKRS_Update(ref gID
                                                                 , new DynamicControl(this, rowCurrent, "TRACKER_NAME").Text
                                                                 , new DynamicControl(this, rowCurrent, "TRACKER_URL").Text
                                                                 , new DynamicControl(this, rowCurrent, "CAMPAIGN_ID").ID
                                                                 , new DynamicControl(this, rowCurrent, "IS_OPTOUT").Checked
                                                                 , trn
                                                                 );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gCAMPAIGN_ID))
                    {
                        Response.Redirect("~/Campaigns/view.aspx?ID=" + gCAMPAIGN_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gCAMPAIGN_ID))
                {
                    Response.Redirect("~/Campaigns/view.aspx?ID=" + gCAMPAIGN_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
 protected void Page_Command(Object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Save")
     {
         // 01/16/2006 Paul.  Enable validator before validating page.
         SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
         if (Page.IsValid)
         {
             string            sCUSTOM_MODULE = "CAMPAIGNS";
             DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
             DbProviderFactory dbf            = DbProviderFactories.GetFactory();
             using (IDbConnection con = dbf.CreateConnection())
             {
                 con.Open();
                 using (IDbTransaction trn = con.BeginTransaction())
                 {
                     try
                     {
                         // 04/24/2006 Paul.  Upgrade to SugarCRM 4.2 Schema.
                         SqlProcs.spCAMPAIGNS_Update
                             (ref gID
                             , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                             , new DynamicControl(this, "NAME").Text
                             , new DynamicControl(this, "REFER_URL").Text
                             , new DynamicControl(this, "TRACKER_TEXT").Text
                             , new DynamicControl(this, "START_DATE").DateValue
                             , new DynamicControl(this, "END_DATE").DateValue
                             , new DynamicControl(this, "STATUS").SelectedValue
                             , new DynamicControl(this, "BUDGET").DecimalValue
                             , new DynamicControl(this, "EXPECTED_COST").DecimalValue
                             , new DynamicControl(this, "ACTUAL_COST").DecimalValue
                             , new DynamicControl(this, "EXPECTED_REVENUE").DecimalValue
                             , new DynamicControl(this, "CAMPAIGN_TYPE").SelectedValue
                             , new DynamicControl(this, "OBJECTIVE").Text
                             , new DynamicControl(this, "CONTENT").Text
                             , new DynamicControl(this, "CURRENCY_ID").ID
                             , trn
                             );
                         SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                         trn.Commit();
                     }
                     catch (Exception ex)
                     {
                         trn.Rollback();
                         SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.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());
         }
     }
 }
示例#21
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);
                // The only possible error is a connection failure, so just ignore all errors.
                gPARENT_ID = Guid.Empty;
            }
            if (e.CommandName == "Save")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                this.ValidateEditViewFields(m_sMODULE + ".EditView");
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "PROSPECT_LISTS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        // 11/18/2007 Paul.  Use the current values for any that are not defined in the edit view.
                        DataRow   rowCurrent = null;
                        DataTable dtCurrent  = new DataTable();
                        if (!Sql.IsEmptyGuid(gID))
                        {
                            string sSQL;
                            sSQL = "select *                    " + ControlChars.CrLf
                                   + "  from vwPROSPECT_LISTS_Edit" + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Security.Filter(cmd, m_sMODULE, "edit");
                                Sql.AppendParameter(cmd, gID, "ID", false);
                                using (DbDataAdapter da = dbf.CreateDataAdapter())
                                {
                                    ((IDbDataAdapter)da).SelectCommand = cmd;
                                    da.Fill(dtCurrent);
                                    if (dtCurrent.Rows.Count > 0)
                                    {
                                        rowCurrent = dtCurrent.Rows[0];
                                    }
                                    else
                                    {
                                        // 11/19/2007 Paul.  If the record is not found, clear the ID so that the record cannot be updated.
                                        // It is possible that the record exists, but that ACL rules prevent it from being selected.
                                        gID = Guid.Empty;
                                    }
                                }
                            }
                        }

                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                // 04/24/2006 Paul.  Upgrade to SugarCRM 4.2 Schema.
                                // 11/18/2007 Paul.  Use the current values for any that are not defined in the edit view.
                                // 12/29/2007 Paul.  TEAM_ID is now in the stored procedure.
                                SqlProcs.spPROSPECT_LISTS_Update
                                    (ref gID
                                    , new DynamicControl(this, rowCurrent, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, rowCurrent, "NAME").Text
                                    , new DynamicControl(this, rowCurrent, "DESCRIPTION").Text
                                    , sMODULE
                                    , gPARENT_ID
                                    , new DynamicControl(this, rowCurrent, "LIST_TYPE").Text
                                    , new DynamicControl(this, rowCurrent, "DOMAIN_NAME").Text
                                    , new DynamicControl(this, rowCurrent, "TEAM_ID").ID
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
 protected override void ClearCache(string sNAME)
 {
     SplendidCache.ClearDetailView(sNAME);
 }
        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());
                }
            }
        }
 protected override void GetLayoutFields(string sNAME)
 {
     dtFields = SplendidCache.DetailViewFields(sNAME).Copy();
 }
        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")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "OPPORTUNITIES";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                SqlProcs.spOPPORTUNITIES_Update
                                    (ref gID
                                    , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, "ACCOUNT_ID").ID
                                    , new DynamicControl(this, "NAME").Text
                                    , new DynamicControl(this, "OPPORTUNITY_TYPE").SelectedValue
                                    , new DynamicControl(this, "LEAD_SOURCE").SelectedValue
                                    , new DynamicControl(this, "AMOUNT").DecimalValue
                                    , new DynamicControl(this, "CURRENCY_ID").ID                                           // 03/04/2006 Paul.  Correct name is CURRENCY_ID.
                                    , new DynamicControl(this, "DATE_CLOSED").DateValue
                                    , new DynamicControl(this, "NEXT_STEP").Text
                                    , new DynamicControl(this, "SALES_STAGE").SelectedValue
                                    , new DynamicControl(this, "PROBABILITY").FloatValue
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , sMODULE
                                    , gPARENT_ID
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList." + m_sMODULE));
            this.Visible = SplendidCRM.Security.IS_ADMIN;
            if (!this.Visible)
            {
                return;
            }

            try
            {
                gID = Sql.ToGuid(Request["ID"]);
                if (!IsPostBack)
                {
                    MODULE_NAME.DataSource = SplendidCache.Modules();
                    MODULE_NAME.DataBind();
                    SHORTCUT_MODULE.DataSource = SplendidCache.Modules();
                    SHORTCUT_MODULE.DataBind();
                    SHORTCUT_MODULE.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                    SHORTCUT_ACLTYPE.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                    if (!Sql.IsEmptyGuid(gID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *               " + ControlChars.CrLf
                                   + "  from vwSHORTCUTS_Edit" + ControlChars.CrLf
                                   + " where 1 = 1           " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Sql.AppendParameter(cmd, gID, "ID", false);
                                con.Open();

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

                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        ctlModuleHeader.Title = Sql.ToString(rdr["DISPLAY_NAME"]);
                                        SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                                        ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title;

                                        try
                                        {
                                            MODULE_NAME.SelectedValue = Sql.ToString(rdr["MODULE_NAME"]);
                                        }
                                        catch
                                        {
                                        }
                                        DISPLAY_NAME.Text        = Sql.ToString(rdr["DISPLAY_NAME"]);
                                        RELATIVE_PATH.Text       = Sql.ToString(rdr["RELATIVE_PATH"]);
                                        IMAGE_NAME.Text          = Sql.ToString(rdr["IMAGE_NAME"]);
                                        SHORTCUT_ENABLED.Checked = Sql.ToBoolean(rdr["SHORTCUT_ENABLED"]);
                                        if (Sql.ToInteger(rdr["SHORTCUT_ORDER"]) > 0)
                                        {
                                            SHORTCUT_ORDER.Text = Sql.ToString(rdr["SHORTCUT_ORDER"]);
                                        }
                                        try
                                        {
                                            SHORTCUT_MODULE.SelectedValue = Sql.ToString(rdr["SHORTCUT_MODULE"]);
                                        }
                                        catch
                                        {
                                        }
                                        try
                                        {
                                            SHORTCUT_ACLTYPE.SelectedValue = Sql.ToString(rdr["SHORTCUT_ACLTYPE"]);
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    // 12/02/2005 Paul.  When validation fails, the header title does not retain its value.  Update manually.
                    ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]);
                    SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            if (e.CommandName == "NewRecord")
            {
                txtNAME.Text  = txtNAME.Text.Trim();
                txtLABEL.Text = txtLABEL.Text.Trim();

                if (Sql.IsEmptyString(txtLABEL.Text))
                {
                    txtLABEL.Text = txtNAME.Text;
                }
                Regex r = new Regex(@"[^\w]+");
                txtNAME.Text = r.Replace(txtNAME.Text, "_");

                // 01/11/2006 Paul.  The label does not need to be validated because it will become the term display name.
                reqNAME.Enabled = true;
                regNAME.Enabled = true;
                reqNAME.Validate();
                regNAME.Validate();
                if (Page.IsValid)
                {
                    Guid gID = Guid.Empty;
                    try
                    {
                        // 01/11/2006 Paul.  The label needs to be stored in the TERMINOLOGY table.
                        // 05/20/2007 Paul.  The Label term is no longer used.  The label term must be derived from the field name
                        // in order for the reporting area to work properly.  The reporting area assumes that the label is the of the format "LBL_" + Name + "_C".
                        string sLABEL_TERM = String.Empty;                          // r.Replace(txtLABEL.Text, "_");
                        // 04/24/2006 Paul.  Upgrade to SugarCRM 4.2 Schema.
                        // 04/24/2006 Paul.  We don't support MassUpdate at this time.

                        // 07/18/2006 Paul.  Manually create the command so that we can increase the timeout.
                        // 07/18/2006 Paul.  Keep the original procedure call so that we will get a compiler error if something changes.
                        bool bIncreaseTimeout = true;
                        if (!bIncreaseTimeout)
                        {
                            SqlProcs.spFIELDS_META_DATA_Insert(ref gID, txtNAME.Text, txtLABEL.Text, sLABEL_TERM, sMODULE_NAME, lstDATA_TYPE.SelectedValue, Sql.ToInteger(txtMAX_SIZE.Text), chkREQUIRED.Checked, chkAUDITED.Checked, txtDEFAULT_VALUE.Text, lstDROPDOWN_LIST.SelectedValue, false);
                        }
                        else
                        {
                            string            sNAME          = txtNAME.Text;
                            string            sLABEL         = txtLABEL.Text;
                            string            sCUSTOM_MODULE = sMODULE_NAME;
                            string            sDATA_TYPE     = lstDATA_TYPE.SelectedValue;
                            Int32             nMAX_SIZE      = Sql.ToInteger(txtMAX_SIZE.Text);
                            bool              bREQUIRED      = chkREQUIRED.Checked;
                            bool              bAUDITED       = chkAUDITED.Checked;
                            string            sDEFAULT_VALUE = txtDEFAULT_VALUE.Text;
                            string            sDROPDOWN_LIST = lstDROPDOWN_LIST.SelectedValue;
                            bool              bMASS_UPDATE   = false;
                            DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                            using (IDbConnection con = dbf.CreateConnection())
                            {
                                con.Open();
                                using (IDbTransaction trn = con.BeginTransaction())
                                {
                                    try
                                    {
                                        using (IDbCommand cmd = con.CreateCommand())
                                        {
                                            cmd.Transaction = trn;
                                            cmd.CommandType = CommandType.StoredProcedure;
                                            cmd.CommandText = "spFIELDS_META_DATA_Insert";
                                            // 07/18/2006 Paul.  Tripple the default timeout.  The operation was timing-out on QA machines and on the demo server.
                                            // 02/03/2007 Paul.  Increase timeout to 5 minutes.  It should not take that long, but some users are reporting a timeout.
                                            cmd.CommandTimeout = 5 * 60;
                                            IDbDataParameter parID = Sql.AddParameter(cmd, "@ID", gID);
                                            IDbDataParameter parMODIFIED_USER_ID = Sql.AddParameter(cmd, "@MODIFIED_USER_ID", Security.USER_ID);
                                            IDbDataParameter parNAME             = Sql.AddParameter(cmd, "@NAME", sNAME, 255);
                                            IDbDataParameter parLABEL            = Sql.AddParameter(cmd, "@LABEL", sLABEL, 255);
                                            IDbDataParameter parLABEL_TERM       = Sql.AddParameter(cmd, "@LABEL_TERM", sLABEL_TERM, 255);
                                            IDbDataParameter parCUSTOM_MODULE    = Sql.AddParameter(cmd, "@CUSTOM_MODULE", sCUSTOM_MODULE, 255);
                                            IDbDataParameter parDATA_TYPE        = Sql.AddParameter(cmd, "@DATA_TYPE", sDATA_TYPE, 255);
                                            IDbDataParameter parMAX_SIZE         = Sql.AddParameter(cmd, "@MAX_SIZE", nMAX_SIZE);
                                            IDbDataParameter parREQUIRED         = Sql.AddParameter(cmd, "@REQUIRED", bREQUIRED);
                                            IDbDataParameter parAUDITED          = Sql.AddParameter(cmd, "@AUDITED", bAUDITED);
                                            IDbDataParameter parDEFAULT_VALUE    = Sql.AddParameter(cmd, "@DEFAULT_VALUE", sDEFAULT_VALUE, 255);
                                            IDbDataParameter parDROPDOWN_LIST    = Sql.AddParameter(cmd, "@DROPDOWN_LIST", sDROPDOWN_LIST, 50);
                                            IDbDataParameter parMASS_UPDATE      = Sql.AddParameter(cmd, "@MASS_UPDATE", bMASS_UPDATE);
                                            parID.Direction = ParameterDirection.InputOutput;
                                            cmd.ExecuteNonQuery();
                                            gID = Sql.ToGuid(parID.Value);
                                        }
                                        trn.Commit();
                                    }
                                    catch (Exception ex)
                                    {
                                        trn.Rollback();
                                        throw(new Exception(ex.Message, ex.InnerException));
                                    }
                                }
                            }
                        }
                        // 01/11/2006 Paul.  Add term to the local cache.  Always default to english.
                        //Application["en-US." + sMODULE_NAME + "." + sLABEL_TERM] = txtLABEL.Text;
                        // 04/05/2006 Paul.  A _C is appended to the term in the procedure.  Do so here as well.
                        // 05/20/2007 Paul.  The label is also prepended with LBL_.  This is a requirement for the reporting system.
                        // 05/20/2007 Paul.  The Label term is no longer used.  The label term must be derived from the field name
                        // in order for the reporting area to work properly.  The reporting area assumes that the label is the of the format "LBL_" + Name + "_C".
                        L10N.SetTerm("en-US", sMODULE_NAME, "LBL_" + txtNAME.Text.ToUpper() + "_C", txtLABEL.Text);
                        // 01/10/2006 Paul.  Clear the cache.
                        SplendidCache.ClearFieldsMetaData(sMODULE_NAME);
                        Clear();
                        if (Command != null)
                        {
                            Command(this, e);
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                        lblError.Text = ex.Message;
                    }
                }
            }
        }
示例#28
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Utils.SetPageTitle(Page, L10n.Term("Shippers.LBL_NAME"));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = SplendidCRM.Security.IS_ADMIN;
            if (!this.Visible)
            {
                return;
            }

            try
            {
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();  // 09/03/2005 Paul. DataBind is required in order for the RequiredFieldValidators to work.
                // 07/02/2006 Paul.  The required fields need to be bound manually.
                reqNAME.DataBind();
                reqLIST_ORDER.DataBind();
                gID = Sql.ToGuid(Request["ID"]);
                if (!IsPostBack)
                {
                    lstSTATUS.DataSource = SplendidCache.List("shipper_status_dom");
                    lstSTATUS.DataBind();
                    Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]);
                    if (!Sql.IsEmptyGuid(gID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *         " + ControlChars.CrLf
                                   + "  from vwSHIPPERS" + ControlChars.CrLf
                                   + " where ID = @ID  " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Sql.AddParameter(cmd, "@ID", gID);
                                con.Open();
#if DEBUG
                                Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
#endif
                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        txtNAME.Text        = Sql.ToString(rdr["NAME"]);
                                        ctlListHeader.Title = L10n.Term("Shippers.LBL_NAME") + " " + txtNAME.Text;
                                        txtLIST_ORDER.Text  = Sql.ToString(rdr["LIST_ORDER"]);
                                        try
                                        {
                                            lstSTATUS.SelectedValue = Sql.ToString(rdr["STATUS"]);
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                lblError.Text = ex.Message;
            }
        }
        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")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditView", this);
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditAddress", this);
                SplendidDynamic.ValidateEditViewFields(m_sMODULE + ".EditDescription", this);
                if (Page.IsValid)
                {
                    string            sCUSTOM_MODULE = "CONTACTS";
                    DataTable         dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE);
                    DbProviderFactory dbf            = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        con.Open();
                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                SqlProcs.spCONTACTS_Update
                                    (ref gID
                                    , new DynamicControl(this, "ASSIGNED_USER_ID").ID
                                    , new DynamicControl(this, "SALUTATION").SelectedValue
                                    , new DynamicControl(this, "FIRST_NAME").Text
                                    , new DynamicControl(this, "LAST_NAME").Text
                                    , new DynamicControl(this, "ACCOUNT_ID").ID
                                    , new DynamicControl(this, "LEAD_SOURCE").SelectedValue
                                    , new DynamicControl(this, "TITLE").Text
                                    , new DynamicControl(this, "DEPARTMENT").Text
                                    , new DynamicControl(this, "REPORTS_TO_ID").ID
                                    , new DynamicControl(this, "BIRTHDATE").DateValue
                                    , 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, "ASSISTANT").Text
                                    , new DynamicControl(this, "ASSISTANT_PHONE").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
                                    , new DynamicControl(this, "ALT_ADDRESS_STREET").Text
                                    , new DynamicControl(this, "ALT_ADDRESS_CITY").Text
                                    , new DynamicControl(this, "ALT_ADDRESS_STATE").Text
                                    , new DynamicControl(this, "ALT_ADDRESS_POSTALCODE").Text
                                    , new DynamicControl(this, "ALT_ADDRESS_COUNTRY").Text
                                    , new DynamicControl(this, "DESCRIPTION").Text
                                    , sMODULE
                                    , gPARENT_ID
                                    , new DynamicControl(this, "SYNC_CONTACT").Checked
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
示例#30
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList.Terminology"));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = SplendidCRM.Security.IS_ADMIN;
            if (!this.Visible)
            {
                return;
            }

            try
            {
                gID = Sql.ToGuid(Request["ID"]);
                if (!IsPostBack)
                {
                    lstLANGUAGE.DataSource = SplendidCache.Languages();
                    lstLANGUAGE.DataBind();

                    lstMODULE_NAME.DataSource = SplendidCache.Modules();
                    lstMODULE_NAME.DataBind();
                    lstMODULE_NAME.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));

                    lstLIST_NAME.DataSource = SplendidCache.TerminologyPickLists();
                    lstLIST_NAME.DataBind();
                    lstLIST_NAME.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));

                    Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]);
                    if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *                 " + ControlChars.CrLf
                                   + "  from vwTERMINOLOGY_Edit" + ControlChars.CrLf
                                   + " where ID = @ID          " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Sql.AddParameter(cmd, "@ID", gID);
                                con.Open();

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

                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        ctlModuleHeader.Title = Sql.ToString(rdr["NAME"]);
                                        SetPageTitle(L10n.Term(".moduleList.Terminology") + " - " + ctlModuleHeader.Title);
                                        ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title;

                                        // 01/20/2006 Paul.  Don't allow the name to be changed.  Require a new term.
                                        txtNAME.ReadOnly = true;

                                        txtNAME.Text         = Sql.ToString(rdr["NAME"]);
                                        txtDISPLAY_NAME.Text = Sql.ToString(rdr["DISPLAY_NAME"]);
                                        if (Sql.ToInteger(rdr["LIST_ORDER"]) > 0)
                                        {
                                            txtLIST_ORDER.Text = Sql.ToString(rdr["LIST_ORDER"]);
                                        }
                                        try
                                        {
                                            lstLANGUAGE.SelectedValue = L10N.NormalizeCulture(Sql.ToString(rdr["LANG"]));
                                        }
                                        catch
                                        {
                                        }
                                        string sMODULE_NAME = Sql.ToString(rdr["MODULE_NAME"]);
                                        try
                                        {
                                            lstMODULE_NAME.SelectedValue = sMODULE_NAME;
                                        }
                                        catch
                                        {
                                            // 01/12/2006 Paul.  If module does not exist in our table, then add it to prevent data loss.
                                            lstMODULE_NAME.Items.Add(sMODULE_NAME);
                                            lstMODULE_NAME.SelectedValue = sMODULE_NAME;
                                        }
                                        try
                                        {
                                            lstLIST_NAME.SelectedValue = Sql.ToString(rdr["LIST_NAME"]);
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    // 12/02/2005 Paul.  When validation fails, the header title does not retain its value.  Update manually.
                    ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]);
                    SetPageTitle(L10n.Term(".moduleList.Administration") + " - " + ctlModuleHeader.Title);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }