コード例 #1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Utils.SetPageTitle(Page, L10n.Term("ProductTypes.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)
                {
                    Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]);
                    if (!Sql.IsEmptyGuid(gID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *              " + ControlChars.CrLf
                                   + "  from vwPRODUCT_TYPES" + 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("ProductTypes.LBL_NAME") + " " + txtNAME.Text;
                                        txtDESCRIPTION.Text = Sql.ToString(rdr["DESCRIPTION"]);
                                        txtLIST_ORDER.Text  = Sql.ToString(rdr["LIST_ORDER"]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                lblError.Text = ex.Message;
            }
        }
コード例 #2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term("EmailMan.LBL_CAMPAIGN_EMAIL_SETTINGS"));
            // 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
            {
                reqNOTIFY_FROMNAME.DataBind();
                reqNOTIFY_FROMADDRESS.DataBind();
                reqMAIL_SMTPSERVER.DataBind();
                reqMAIL_SMTPPORT.DataBind();
                reqMAIL_SMTPUSER.DataBind();
                reqMAIL_SMTPPASS.DataBind();
                if (!IsPostBack)
                {
                    NOTIFY_FROMNAME.Text                    = Sql.ToString(Application["CONFIG.fromname"]);
                    NOTIFY_FROMADDRESS.Text                 = Sql.ToString(Application["CONFIG.fromaddress"]);
                    NOTIFY_ON.Checked                       = Sql.ToBoolean(Application["CONFIG.notify_on"]);
                    NOTIFY_SEND_BY_DEFAULT.Checked          = Sql.ToBoolean(Application["CONFIG.send_by_default"]);
                    NOTIFY_SEND_FROM_ASSIGNING_USER.Checked = Sql.ToBoolean(Application["CONFIG.send_from_assigning_user"]);
                    MAIL_SENDTYPE.Text                      = Sql.ToString(Application["CONFIG.mail_sendtype"]);
                    MAIL_SMTPSERVER.Text                    = Sql.ToString(Application["CONFIG.smtpserver"]);
                    MAIL_SMTPPORT.Text                      = Sql.ToString(Application["CONFIG.smtpport"]);
                    MAIL_SMTPUSER.Text                      = Sql.ToString(Application["CONFIG.smtpuser"]);
                    //MAIL_SMTPPASS                  .Text    = Sql.ToString (Application["CONFIG.smtppass"                ]);
                    MAIL_SMTPAUTH_REQ.Checked = Sql.ToBoolean(Application["CONFIG.smtpauth_req"]);
                    MAIL_SMTPSSL.Checked      = Sql.ToBoolean(Application["CONFIG.smtpssl"]);
                    // 01/20/2008 Paul.  We are going to deviate from SugarCRM and associate the Preserve text with save raw.
                    EMAIL_INBOUND_SAVE_RAW.Checked = Sql.ToBoolean(Application["CONFIG.email_inbound_save_raw"]);

                    NOTIFY_ON.Checked = false;
                    NOTIFY_SEND_BY_DEFAULT.Checked          = false;
                    NOTIFY_SEND_FROM_ASSIGNING_USER.Checked = false;
                    MAIL_SENDTYPE.Text        = "SMTP";
                    MAIL_SMTPAUTH_REQ.Checked = true;

                    string sMAIL_SMTPPASS = Sql.ToString(Application["CONFIG.smtppass"]);
                    // 01/08/2008 Paul.  Don't display the password.
                    // 01/08/2008 Paul.  Browsers don't display passwords.
                    if (!Sql.IsEmptyString(sMAIL_SMTPPASS))
                    {
                        //MAIL_SMTPPASS.Text = "**********";
                        MAIL_SMTPPASS.Attributes.Add("value", "**********");
                    }
                    BuildSecurityTags();
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }
コード例 #3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term("Administration.LBL_MODULE_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;
            }

            NAME_REQUIRED.DataBind();
            if (!IsPostBack)
            {
                NAME.Text = "SplendidCRM_db_" + DateTime.Now.ToString("yyyyMMddHHmm") + ".bak";
            }
        }
コード例 #4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(m_sMODULE + ".LBL_LIST_FORM_TITLE"));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "list") >= 0);
            if (!this.Visible)
            {
                return;
            }

            reqNAME.DataBind();
            reqFILENAME.DataBind();
            try
            {
                if (!IsPostBack)
                {
                    txtASSIGNED_TO.Text           = Security.USER_NAME;
                    txtASSIGNED_USER_ID.Value     = Security.USER_ID.ToString();
                    ViewState["ASSIGNED_USER_ID"] = txtASSIGNED_USER_ID.Value;
                    lstMODULE.DataSource          = SplendidCache.ReportingModules();
                    lstMODULE.DataBind();
                    lstREPORT_TYPE.DataSource = SplendidCache.List("dom_report_types");
                    lstREPORT_TYPE.DataBind();
                    try
                    {
                        lstREPORT_TYPE.SelectedValue = "Freeform";
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlImportButtons.ErrorText = 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();
            }
        }
コード例 #5
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Utils.SetPageTitle(Page, L10n.Term("Administration.LBL_MODULE_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;
            }

            // 07/02/2006 Paul.  The required fields need to be bound manually.
            reqFILENAME.DataBind();
            // 12/17/2005 Paul.  Don't buffer so that the connection can be kept alive.
            Response.BufferOutput = false;
            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();
            }
        }
コード例 #6
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(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();
                    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 (bDebug)
                                {
                                    RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
                                }

                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        txtNAME.Text        = Sql.ToString(rdr["NAME"]);
                                        ctlListHeader.Title = L10n.Term("Shippers.LBL_NAME") + " " + txtNAME.Text;
                                        txtLIST_ORDER.Text  = Sql.ToString(rdr["LIST_ORDER"]);
                                        try
                                        {
                                            lstSTATUS.SelectedValue = Sql.ToString(rdr["STATUS"]);
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        // 07/14/2007 Paul.  Provide a default list order.
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select max(LIST_ORDER) " + ControlChars.CrLf
                                   + "  from vwSHIPPERS      " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                con.Open();
                                txtLIST_ORDER.Text = (Sql.ToInteger(cmd.ExecuteScalar()) + 1).ToString();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                lblError.Text = ex.Message;
            }
        }
コード例 #7
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList.Schedulers"));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = SplendidCRM.Security.IS_ADMIN;
            if (!this.Visible)
            {
                return;
            }

            NAME_REQUIRED.DataBind();
            try
            {
                gID = Sql.ToGuid(Request["ID"]);
                if (!IsPostBack)
                {
                    STATUS.DataSource = SplendidCache.List("scheduler_status_dom");
                    STATUS.DataBind();
                    foreach (string sJob in SchedulerUtils.Jobs)
                    {
                        JOB.Items.Add(new ListItem(sJob, "function::" + sJob));
                    }

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

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

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

                                        NAME.Text        = Sql.ToString(rdr["NAME"]);
                                        CATCH_UP.Checked = Sql.ToBoolean(rdr["CATCH_UP"]);

                                        string JOB_INTERVAL = Sql.ToString(rdr["JOB_INTERVAL"]);
                                        JOB_INTERVAL = JOB_INTERVAL.Replace(" ", "");
                                        string[] arrCRON = JOB_INTERVAL.Replace("::", "|").Split('|');
                                        // minute  hour  dayOfMonth  month  dayOfWeek
                                        CRON_MINUTES.Text    = (arrCRON.Length > 0) ? arrCRON[0] : "*";
                                        CRON_HOURS.Text      = (arrCRON.Length > 1) ? arrCRON[1] : "*";
                                        CRON_DAYOFMONTH.Text = (arrCRON.Length > 2) ? arrCRON[2] : "*";
                                        CRON_MONTHS.Text     = (arrCRON.Length > 3) ? arrCRON[3] : "*";
                                        CRON_DAYOFWEEK.Text  = (arrCRON.Length > 4) ? arrCRON[4] : "*";

                                        if (rdr["DATE_TIME_START"] != DBNull.Value)
                                        {
                                            DATE_TIME_START.Value = T10n.FromServerTime(Sql.ToDateTime(rdr["DATE_TIME_START"]));
                                        }
                                        if (rdr["DATE_TIME_END"] != DBNull.Value)
                                        {
                                            DATE_TIME_END.Value = T10n.FromServerTime(Sql.ToDateTime(rdr["DATE_TIME_END"]));
                                        }
                                        // 12/31/2007 Paul.  TIME_FROM and TIME_TO are just time components, so they should not be translated.
                                        if (rdr["TIME_FROM"] != DBNull.Value)
                                        {
                                            TIME_FROM.Value = Sql.ToDateTime(rdr["TIME_FROM"]);
                                        }
                                        if (rdr["TIME_TO"] != DBNull.Value)
                                        {
                                            TIME_TO.Value = Sql.ToDateTime(rdr["TIME_TO"]);
                                        }
                                        try
                                        {
                                            JOB.SelectedValue = Sql.ToString(rdr["JOB"]);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                        }
                                        try
                                        {
                                            STATUS.SelectedValue = Sql.ToString(rdr["STATUS"]);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    // 12/02/2005 Paul.  When validation fails, the header title does not retain its value.  Update manually.
                    ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]);
                    SetPageTitle(L10n.Term(".moduleList.Schedulers") + " - " + ctlModuleHeader.Title);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }
コード例 #8
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList." + m_sMODULE));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            // 07/11/2006 Paul.  Users must be able to view and edit their own settings.
            this.Visible = bMyAccount || SplendidCRM.Security.IS_ADMIN;              //(SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0);
            if (!this.Visible)
            {
                return;
            }

            reqUSER_NAME.DataBind();
            reqLAST_NAME.DataBind();
            try
            {
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();
                gID = Sql.ToGuid(Request["ID"]);
                if (bMyAccount)
                {
                    gID = Security.USER_ID;
                }
                // 07/12/2006 Paul.  Status can only be edited by an administrator.
                lstSTATUS.Enabled = false;
                // 12/06/2005 Paul.  A user can only edit his own user name if Windows Authentication is off.
                if (Security.IS_ADMIN)
                {
                    // 12/06/2005 Paul.  An administrator can always edit the user name.  This is to allow him to pre-add any NTLM users.
                    txtUSER_NAME.Enabled = true;
                    lstSTATUS.Enabled    = true;
                }
                else if (gID == Security.USER_ID)
                {
                    // 12/06/2005 Paul.  If editing yourself, then you can only edit if not NTLM.
                    // txtUSER_NAME.Enabled = !Security.IsWindowsAuthentication();
                    // 11/26/2006 Paul.  A user cannot edit their own user name. This is a job for the admin.
                    txtUSER_NAME.Enabled = false;
                }
                else
                {
                    // 12/06/2005 Paul.  If not an administrator and not editing yourself, then the name cannot be edited.
                    txtUSER_NAME.Enabled = false;
                }

                if (!IsPostBack)
                {
                    // 'date_formats' => array('Y-m-d'=>'2006-12-23', 'm-d-Y'=>'12-23-2006', 'Y/m/d'=>'2006/12/23', 'm/d/Y'=>'12/23/2006')
                    // 'time_formats' => array('H:i'=>'23:00', 'h:ia'=>'11:00pm', 'h:iA'=>'11:00PM', 'H.i'=>'23.00', 'h.ia'=>'11.00pm', 'h.iA'=>'11.00PM' )
                    lstSTATUS.DataSource = SplendidCache.List("user_status_dom");
                    lstSTATUS.DataBind();
                    // 08/05/2006 Paul.  Remove stub of unsupported code. Reminder is not supported at this time.
                    //lstREMINDER_TIME  .DataSource = SplendidCache.List("reminder_time_dom");
                    //lstREMINDER_TIME  .DataBind();
                    lstTIMEZONE.DataSource = SplendidCache.TimezonesListbox();
                    lstTIMEZONE.DataBind();
                    lstCURRENCY.DataSource = SplendidCache.Currencies();
                    lstCURRENCY.DataBind();
                    // 05/09/2006 Paul.  We need to always initialize the separators, just in case the user is new.
                    txtGROUP_SEPARATOR.Text   = SplendidDefaults.GroupSeparator();
                    txtDECIMAL_SEPARATOR.Text = SplendidDefaults.DecimalSeparator();

                    lstLANGUAGE.DataSource = SplendidCache.Languages();
                    lstLANGUAGE.DataBind();
                    lstLANGUAGE_Changed(null, null);
                    lstTHEME.DataSource = SplendidCache.Themes();
                    lstTHEME.DataBind();

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

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

                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        ctlModuleHeader.Title = Sql.ToString(rdr["FULL_NAME"]);
                                        SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title + " (" + Sql.ToString(rdr["USER_NAME"]) + ")");
                                        Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title);
                                        ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title;

                                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr);
                                        this.AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, rdr);
                                        // 08/05/2006 Paul.  Use the dynamic grid to create the fields, but populate manually.
                                        this.AppendEditViewFields(m_sMODULE + ".EditMailOptions", tblMailOptions, null);
                                        // 01/20/2008 Paul.  The mail options panel is manually populated.
                                        new DynamicControl(this, "EMAIL1").Text = Sql.ToString(rdr["EMAIL1"]);
                                        new DynamicControl(this, "EMAIL2").Text = Sql.ToString(rdr["EMAIL2"]);

                                        // main
                                        txtUSER_NAME.Text  = Sql.ToString(rdr["USER_NAME"]);
                                        txtFIRST_NAME.Text = Sql.ToString(rdr["FIRST_NAME"]);
                                        txtLAST_NAME.Text  = Sql.ToString(rdr["LAST_NAME"]);
                                        // user_settings
                                        chkIS_ADMIN.Checked              = Sql.ToBoolean(rdr["IS_ADMIN"]);
                                        chkPORTAL_ONLY.Checked           = Sql.ToBoolean(rdr["PORTAL_ONLY"]);
                                        chkRECEIVE_NOTIFICATIONS.Checked = Sql.ToBoolean(rdr["RECEIVE_NOTIFICATIONS"]);
                                        // 12/04/2005 Paul.  Only allow the admin flag to be changed if the current user is an admin.
                                        chkIS_ADMIN.Enabled = Security.IS_ADMIN;
                                        // 12/04/2005 Paul.  Save admin flag in ViewState to prevent hacking.
                                        ViewState["IS_ADMIN"] = Sql.ToBoolean(rdr["IS_ADMIN"]);

                                        try
                                        {
                                            lstSTATUS.SelectedValue = Sql.ToString(rdr["STATUS"]);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                        }

                                        string sUSER_PREFERENCES = Sql.ToString(rdr["USER_PREFERENCES"]);
                                        if (!Sql.IsEmptyString(sUSER_PREFERENCES))
                                        {
                                            XmlDocument xml = SplendidInit.InitUserPreferences(sUSER_PREFERENCES);
                                            try
                                            {
                                                ViewState["USER_PREFERENCES"] = xml.OuterXml;
                                                // user_settings
                                                chkGRIDLINE.Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "gridline"));
                                                try
                                                {
                                                    lstLANGUAGE.SelectedValue = L10N.NormalizeCulture(XmlUtil.SelectSingleNode(xml, "culture"));
                                                    lstLANGUAGE_Changed(null, null);
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                try
                                                {
                                                    lstLANGUAGE.SelectedValue = XmlUtil.SelectSingleNode(xml, "theme");
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                try
                                                {
                                                    lstDATE_FORMAT.SelectedValue = XmlUtil.SelectSingleNode(xml, "dateformat");
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                try
                                                {
                                                    lstTIME_FORMAT.SelectedValue = XmlUtil.SelectSingleNode(xml, "timeformat");
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                try
                                                {
                                                    lstTIMEZONE.SelectedValue = XmlUtil.SelectSingleNode(xml, "timezone");
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                try
                                                {
                                                    lstCURRENCY.SelectedValue = XmlUtil.SelectSingleNode(xml, "currency_id");
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }

                                                // mail_options
                                                new DynamicControl(this, "MAIL_FROMNAME").Text        = XmlUtil.SelectSingleNode(xml, "mail_fromname");
                                                new DynamicControl(this, "MAIL_FROMADDRESS").Text     = XmlUtil.SelectSingleNode(xml, "mail_fromaddress");
                                                new DynamicControl(this, "MAIL_SENDTYPE").Text        = XmlUtil.SelectSingleNode(xml, "mail_sendtype");
                                                new DynamicControl(this, "MAIL_SMTPSERVER").Text      = XmlUtil.SelectSingleNode(xml, "mail_smtpserver");
                                                new DynamicControl(this, "MAIL_SMTPPORT").Text        = XmlUtil.SelectSingleNode(xml, "mail_smtpport");
                                                new DynamicControl(this, "MAIL_SMTPAUTH_REQ").Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "mail_smtpauth_req"));
                                                new DynamicControl(this, "MAIL_SMTPUSER").Text        = XmlUtil.SelectSingleNode(xml, "mail_smtpuser");
                                                new DynamicControl(this, "MAIL_SMTPPASS").Text        = XmlUtil.SelectSingleNode(xml, "mail_smtppass");

                                                ViewState["mail_smtppass"] = XmlUtil.SelectSingleNode(xml, "mail_smtppass");
                                                // 08/06/2005 Paul.  Never return password to user.
                                                TextBox txtMAIL_SMTPPASS = FindControl("MAIL_SMTPPASS") as TextBox;
                                                if (txtMAIL_SMTPPASS != null)
                                                {
                                                    if (!Sql.IsEmptyString(txtMAIL_SMTPPASS.Text))
                                                    {
                                                        txtMAIL_SMTPPASS.Text = sEMPTY_PASSWORD;
                                                    }
                                                }

                                                // 05/09/2006 Paul.  Initialize the numeric separators.
                                                txtGROUP_SEPARATOR.Text   = XmlUtil.SelectSingleNode(xml, "num_grp_sep");
                                                txtDECIMAL_SEPARATOR.Text = XmlUtil.SelectSingleNode(xml, "dec_sep");
                                                // 05/09/2006 Paul.  Check for empty strings as the user may have legacy data.
                                                if (Sql.IsEmptyString(txtGROUP_SEPARATOR.Text))
                                                {
                                                    txtGROUP_SEPARATOR.Text = SplendidDefaults.GroupSeparator();
                                                }
                                                if (Sql.IsEmptyString(txtDECIMAL_SEPARATOR.Text))
                                                {
                                                    txtDECIMAL_SEPARATOR.Text = SplendidDefaults.DecimalSeparator();
                                                }

                                                // freebusy
                                                // 08/05/2006 Paul.  Remove stub of unsupported code. Calendar Publish Key is not supported at this time.
                                                //txtCALENDAR_PUBLISH_KEY .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_publish_key" );
                                                //txtCALENDAR_PUBLISH_URL .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_publish_url" );
                                                //txtCALENDAR_SEARCH_URL  .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_search_url"  );
                                                // 08/05/2006 Paul.  Remove stub of unsupported code. Reminder is not supported at this time.

                                                /*
                                                 * try
                                                 * {
                                                 *      int nREMINDER_TIME = Sql.ToInteger(XmlUtil.SelectSingleNode(xml, "reminder_time"));
                                                 *      if ( nREMINDER_TIME > 0 )
                                                 *      {
                                                 *              lstREMINDER_TIME.SelectedValue = nREMINDER_TIME.ToString();
                                                 *              chkSHOULD_REMIND.Checked = true;
                                                 *      }
                                                 * }
                                                 * catch(Exception ex)
                                                 * {
                                                 *      SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                 * }
                                                 */
                                            }
                                            catch (Exception ex)
                                            {
                                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null);
                        this.AppendEditViewFields(m_sMODULE + ".EditAddress", tblAddress, null);
                        this.AppendEditViewFields(m_sMODULE + ".EditMailOptions", tblMailOptions, null);

                        try
                        {
                            lstTHEME.SelectedValue = SplendidDefaults.Theme();
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                        }
                        try
                        {
                            string sDefaultLanguage = Sql.ToString(Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"]);
                            if (Sql.IsEmptyString(sDefaultLanguage))
                            {
                                sDefaultLanguage = "en-US";
                            }
                            lstLANGUAGE.SelectedValue = sDefaultLanguage;
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                        }
                        lstLANGUAGE_Changed(null, null);
                    }
                }
                else
                {
                    // 12/02/2005 Paul.  When validation fails, the header title does not retain its value.  Update manually.
                    ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]);
                    SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }
コード例 #9
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term("Currencies.LBL_CURRENCY"));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = SplendidCRM.Security.IS_ADMIN;
            if (!this.Visible)
            {
                return;
            }

            try
            {
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();  // 09/03/2005 Paul. DataBind is required in order for the RequiredFieldValidators to work.
                // 07/02/2006 Paul.  The required fields need to be bound manually.
                reqNAME.DataBind();
                reqSYMBOL.DataBind();
                reqISO4217.DataBind();
                reqCONVERSION_RATE.DataBind();
                gID = Sql.ToGuid(Request["ID"]);
                if (!IsPostBack)
                {
                    lstSTATUS.DataSource = SplendidCache.List("Currencies", "currency_status_dom");
                    lstSTATUS.DataBind();

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

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

                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        txtNAME.Text        = Sql.ToString(rdr["NAME"]);
                                        ctlListHeader.Title = L10n.Term("Currencies.LBL_CURRENCY") + ": " + txtNAME.Text;
                                        SetPageTitle(L10n.Term("Currencies.LBL_MODULE_NAME") + " - " + txtNAME.Text);
                                        txtSYMBOL.Text          = Sql.ToString(rdr["SYMBOL"]);
                                        txtISO4217.Text         = Sql.ToString(rdr["ISO4217"]);
                                        txtCONVERSION_RATE.Text = Sql.ToString(rdr["CONVERSION_RATE"]);
                                        try
                                        {
                                            lstSTATUS.SelectedValue = Sql.ToString(rdr["STATUS"]);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                lblError.Text = ex.Message;
            }
        }