private void Page_Load(object sender, System.EventArgs e)
        {
            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();
                if (!IsPostBack)
                {
                    lstLANGUAGE.DataSource = SplendidCache.Languages();
                    lstLANGUAGE.DataBind();
                    lstTHEME.DataSource = SplendidCache.Themes();
                    lstTHEME.DataBind();

                    string sDefaultUserName = Sql.ToString(Application["CONFIG.default_user_name"]);
                    string sDefaultPassword = Sql.ToString(Application["CONFIG.default_password"]);
                    string sDefaultTheme    = Sql.ToString(Application["CONFIG.default_theme"]);
                    string sDefaultLanguage = Sql.ToString(Application["CONFIG.default_language"]);
                    txtUSER_NAME.Text = sDefaultUserName;
                    txtPASSWORD.Text  = sDefaultPassword;
                    try
                    {
                        sDefaultTheme          = Sql.IsEmptyString(sDefaultTheme) ? "Sugar" : sDefaultTheme;
                        lstTHEME.SelectedValue = sDefaultTheme;
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                    }
                    try
                    {
                        sDefaultLanguage          = Sql.IsEmptyString(sDefaultLanguage) ? "en-US" : sDefaultLanguage;
                        lstLANGUAGE.SelectedValue = L10N.NormalizeCulture(sDefaultLanguage);
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                        lblError.Text += ex.Message;
                    }
                    // 11/19/2005 Paul.  Don't show the Login & Password if Windows Authentication.
                    tblUser.Visible         = !Security.IsWindowsAuthentication();
                    lblInstructions.Visible = tblUser.Visible;
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                lblError.Text = ex.Message;
            }
        }
Exemplo n.º 2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 06/04/2006 Paul.  NewRecord should not be displayed if the user does not have edit rights.
            this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0);
            if (!this.Visible)
            {
                return;
            }

            // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
            //this.DataBind();  // Need to bind so that Text of the Button gets updated.
            reqNAME.ErrorMessage = L10n.Term(".ERR_MISSING_REQUIRED_FIELDS") + " " + L10n.Term("Bugs.LBL_LIST_SUBJECT") + "<br>";
            if (!IsPostBack)
            {
                lstPRIORITY.DataSource = SplendidCache.List("bug_priority_dom");
                // 03/30/2006 Paul.  IBM DB2 is having a problem returning lists.
                // This is causing a Page.DataBind() error, so only bind if the list is not null.
                if (lstPRIORITY.DataSource != null)
                {
                    lstPRIORITY.DataBind();
                    try
                    {
                        // Set default value for priority.
                        // 07/16/2005 Paul.  Setting the default value is not working.
                        lstPRIORITY.SelectedValue = "Medium";
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                    }
                }
                lstTYPE.DataSource = SplendidCache.List("bug_type_dom");
                lstTYPE.DataBind();
                // 07/16/2005 Paul.  Items.Insert is not working (but not failing).  Use manually if table is empty.
                DataTable dtRelease = SplendidCache.Release();
                if (dtRelease.Rows.Count > 0)
                {
                    lstRELEASE.DataSource = dtRelease;
                    lstRELEASE.DataBind();
                }
                else
                {
                    lstRELEASE.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
                }
            }
        }
Exemplo n.º 3
0
 private void Page_Load(object sender, System.EventArgs e)
 {
     if (!IsPostBack)
     {
         if (lstLANGUAGE_OPTIONS.DataSource == null)
         {
             lstLANGUAGE_OPTIONS.DataSource = SplendidCache.Languages();
             lstLANGUAGE_OPTIONS.DataBind();
         }
         try
         {
             lstLANGUAGE_OPTIONS.SelectedValue = L10n.NAME;
         }
         catch (Exception ex)
         {
             SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
         }
     }
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0);
            if (!this.Visible)
            {
                return;
            }

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

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

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

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

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

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

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

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

                                        ctlEditButtons.Visible  = !PrintView && (sEMAIL_TYPE != "draft");
                                        ctlEmailButtons.Visible = !PrintView && (sEMAIL_TYPE == "draft");
                                        ViewState["TYPE"]       = sEMAIL_TYPE;
                                    }
                                }
                            }
                            sSQL = "select *                   " + ControlChars.CrLf
                                   + "  from vwEMAILS_Attachments" + ControlChars.CrLf
                                   + " where EMAIL_ID = @EMAIL_ID" + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Sql.AddParameter(cmd, "@EMAIL_ID", gID);
#if DEBUG
                                Page.RegisterClientScriptBlock("vwEMAILS_Attachments", Sql.ClientScriptBlock(cmd));
#endif
                                using (DbDataAdapter da = dbf.CreateDataAdapter())
                                {
                                    ((IDbDataAdapter)da).SelectCommand = cmd;
                                    using (DataTable dt = new DataTable())
                                    {
                                        da.Fill(dt);
                                        ctlAttachments.DataSource = dt.DefaultView;
                                        ctlAttachments.DataBind();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Guid gPARENT_ID = Sql.ToGuid(Request["PARENT_ID"]);
                        if (!Sql.IsEmptyGuid(gPARENT_ID))
                        {
                            string sMODULE      = String.Empty;
                            string sPARENT_TYPE = String.Empty;
                            string sPARENT_NAME = String.Empty;
                            SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
                            if (!Sql.IsEmptyGuid(gPARENT_ID))
                            {
                                txtPARENT_ID.Value  = gPARENT_ID.ToString();
                                txtPARENT_NAME.Text = sPARENT_NAME;
                                try
                                {
                                    lstPARENT_TYPE.SelectedValue = sPARENT_TYPE;
                                }
                                catch (Exception ex)
                                {
                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                                }
                                // 08/05/2006 Paul.  When an email is composed from a Lead, automatically set the To address.
                                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                                using (IDbConnection con = dbf.CreateConnection())
                                {
                                    string sSQL;
                                    sSQL = "select EMAIL1      " + ControlChars.CrLf
                                           + "  from vwLEADS_Edit" + ControlChars.CrLf
                                           + " where ID = @ID    " + ControlChars.CrLf;
                                    using (IDbCommand cmd = con.CreateCommand())
                                    {
                                        cmd.CommandText = sSQL;
                                        Sql.AddParameter(cmd, "@ID", gPARENT_ID);
                                        con.Open();
#if DEBUG
                                        Page.RegisterClientScriptBlock("vwLEADS_Edit", Sql.ClientScriptBlock(cmd));
#endif
                                        using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                        {
                                            if (rdr.Read())
                                            {
                                                txtTO_ADDRS.Text = Sql.ToString(rdr["EMAIL1"]);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        try
                        {
                            lstASSIGNED_USER_ID.SelectedValue = Security.USER_ID.ToString();
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                        }
                    }
                }
                else
                {
                    // 12/02/2005 Paul.  When validation fails, the header title does not retain its value.  Update manually.
                    ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]);
                    Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                    sEMAIL_TYPE = Sql.ToString(ViewState["TYPE"]);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                ctlEditButtons.ErrorText  = ex.Message;
                ctlEmailButtons.ErrorText = ex.Message;
            }
        }
Exemplo n.º 5
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0);
            if (!this.Visible)
            {
                return;
            }

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

                                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null);
                        try
                        {
                            // 08/31/2005 Paul.  Default value is Medium.
                            new DynamicControl(this, "PRIORITY").SelectedValue = "Medium";
                        }
                        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);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList." + m_sMODULE));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0);
            if (!this.Visible)
            {
                return;
            }

            try
            {
                gID = Sql.ToGuid(Request["ID"]);
                if (!IsPostBack)
                {
                    Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]);
                    if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *             " + ControlChars.CrLf
                                   + "  from vwIFRAMES_Edit" + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                // 11/19/2007 Paul.  Use new Security.Filter() function to apply Team and ACL security rules.
                                Security.Filter(cmd, m_sMODULE, "edit");
                                if (!Sql.IsEmptyGuid(gDuplicateID))
                                {
                                    Sql.AppendParameter(cmd, gDuplicateID, "ID", false);
                                    gID = Guid.Empty;
                                }
                                else
                                {
                                    Sql.AppendParameter(cmd, gID, "ID", false);
                                }
                                con.Open();

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

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

                                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null);

                        new DynamicControl(this, "STATUS").Checked = true;
                        try
                        {
                            // 12/04/2005 Paul.  Default value is Personal.
                            new DynamicControl(this, "TYPE").SelectedValue = "personal";
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                        }
                        try
                        {
                            // 12/04/2005 Paul.  Default value is Tab Menu and Shortcut Menu.
                            new DynamicControl(this, "PLACEMENT").SelectedValue = "all";
                        }
                        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." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }
Exemplo n.º 7
0
        private void SetDate()
        {
            // 03/10/2006 Paul.  Make sure to only populate the list once.
            // We populate inside SetDate because we need the list to have values before the value can be set.
            if (lstMINUTE.Items.Count == 0)
            {
                for (int nMinute = 0; nMinute < 60; nMinute += nMinutesIncrement)
                {
                    lstMINUTE.Items.Add(new ListItem(nMinute.ToString("00"), nMinute.ToString("00")));
                }
            }
            string sTimeFormat = Sql.ToString(Session["USER_SETTINGS/TIMEFORMAT"]);
            bool   b12Hour     = (sTimeFormat.IndexOf("tt") >= 0);

            // 03/10/2006 Paul.  Make sure to only populate the list once.
            // We populate inside SetDate because we need the list to have values before the value can be set.
            if (lstHOUR.Items.Count == 0)
            {
                if (b12Hour)
                {
                    for (int nHour = 1; nHour <= 12; nHour++)
                    {
                        // 01/26/2008 Paul.  Make sure that 12 is first.
                        if (nHour == 12)
                        {
                            lstHOUR.Items.Insert(0, new ListItem(nHour.ToString("00"), nHour.ToString("00")));
                        }
                        else
                        {
                            lstHOUR.Items.Add(new ListItem(nHour.ToString("00"), nHour.ToString("00")));
                        }
                    }
                    lstMERIDIEM.Visible = true;
                }
                else
                {
                    for (int nHour = 0; nHour < 24; nHour++)
                    {
                        lstHOUR.Items.Add(new ListItem(nHour.ToString("00"), nHour.ToString("00")));
                    }
                    lstMERIDIEM.Visible = false;
                }
            }
            if (dtValue > DateTime.MinValue)
            {
                txtDATE.Text = Sql.ToDateString(dtValue);
                try
                {
                    int nMinutes = dtValue.Minute;
                    if (nMinutesIncrement == 1)
                    {
                        lstMINUTE.SelectedValue = nMinutes.ToString("00");
                    }
                    else
                    {
                        for (int nMinute = 0; nMinute < 60; nMinute += nMinutesIncrement)
                        {
                            if (nMinutes <= (nMinute + nMinutesIncrement / 2))
                            {
                                lstMINUTE.SelectedValue = nMinute.ToString("00");
                                break;
                            }
                        }
                    }

                    int nHours = dtValue.Hour;
                    if (b12Hour)
                    {
                        // 07/11/2006 Paul.  The Meridiem dropdown needs to be populated before we set its value.
                        lstMERIDIEM_Bind();
                        if (nHours >= 12)
                        {
                            nHours -= 12;
                            lstMERIDIEM.SelectedValue = "PM";
                        }
                        else
                        {
                            lstMERIDIEM.SelectedValue = "AM";
                        }
                        if (nHours == 0)
                        {
                            lstHOUR.SelectedValue = (12).ToString("00");
                        }
                        else
                        {
                            lstHOUR.SelectedValue = nHours.ToString("00");
                        }
                    }
                    else
                    {
                        lstHOUR.SelectedValue = nHours.ToString("00");
                    }
                }
                catch (Exception ex)
                {
                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                }
            }
        }
Exemplo n.º 8
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Utils.SetPageTitle(Page, L10n.Term(".moduleList.EditCustomFields"));
            // 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();

                gID = Sql.ToGuid(Request["ID"]);
                if (!IsPostBack)
                {
                    Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]);
                    if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *                      " + ControlChars.CrLf
                                   + "  from vwFIELDS_META_DATA_Edit" + 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())
                                    {
                                        ViewState["MODULE_NAME"] = Sql.ToString(rdr["CUSTOM_MODULE"]);
                                        txtNAME.Text             = Sql.ToString(rdr["NAME"]);
                                        Utils.SetPageTitle(Page, L10n.Term("EditCustomFields.LBL_MODULE_NAME") + " - " + txtNAME.Text);
                                        txtLABEL.Text         = Sql.ToString(rdr["LABEL"]);
                                        txtMAX_SIZE.Text      = Sql.ToString(rdr["MAX_SIZE"]);
                                        txtDEFAULT_VALUE.Text = Sql.ToString(rdr["DEFAULT_VALUE"]);
                                        chkAUDITED.Checked    = Sql.ToBoolean(rdr["AUDITED"]);
                                        chkREQUIRED.Checked   = (Sql.ToString(rdr["REQUIRED_OPTION"]) == "required") ? true : false;
                                        try
                                        {
                                            lstDATA_TYPE.SelectedValue = Sql.ToString(rdr["DATA_TYPE"]);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                                        }
                                        try
                                        {
                                            if (lstDATA_TYPE.SelectedValue == "enum")
                                            {
                                                lstDROPDOWN_LIST.SelectedValue = Sql.ToString(rdr["EXT1"]);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                                        }
                                        trDROPDOWN_LIST.Visible = (lstDATA_TYPE.SelectedValue == "enum");
                                        trMAX_SIZE.Visible      = (lstDATA_TYPE.SelectedValue == "varchar");
                                        lstDROPDOWN_LIST_Changed(null, null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                lblError.Text = ex.Message;
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList.Releases"));
            // 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("release_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 vwRELEASES_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("Releases.LBL_RELEASE") + " " + txtNAME.Text;
                                        SetPageTitle(L10n.Term("Releases.LBL_MODULE_NAME") + " - " + txtNAME.Text);
                                        txtLIST_ORDER.Text = Sql.ToString(rdr["LIST_ORDER"]);
                                        try
                                        {
                                            lstSTATUS.SelectedValue = Sql.ToString(rdr["STATUS"]);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                lblError.Text = ex.Message;
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList.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;
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            SetPageTitle(L10n.Term(".moduleList." + m_sMODULE));
            // 06/04/2006 Paul.  Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load.
            // 07/11/2006 Paul.  Users must be able to view and edit their own settings.
            this.Visible = bMyAccount || SplendidCRM.Security.IS_ADMIN;              //(SplendidCRM.Security.GetUserAccess(m_sMODULE, "view") >= 0);
            if (!this.Visible)
            {
                return;
            }

            try
            {
                gID = Sql.ToGuid(Request["ID"]);
                if (bMyAccount)
                {
                    // 11/19/2005 Paul.  SugarCRM 3.5.0 allows administrator to duplicate itself.
                    btnDuplicate.Visible = Security.IS_ADMIN;
                    gID = Security.USER_ID;
                }
                ctlAccessView.USER_ID = gID;

                // 12/06/2005 Paul.  The password button is only visible if not windows authentication or Admin.
                // The reason to allow the admin to change a password is so that the admin can prepare to turn off windows authentication.
                btnChangePassword.Visible = !Security.IsWindowsAuthentication() || Security.IS_ADMIN;
                btnReset.Visible          = Security.IS_ADMIN;
                if (!Sql.IsEmptyString(txtNEW_PASSWORD.Value))
                {
                    bool bValidOldPassword = false;
                    if (!Security.IS_ADMIN)
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            // 07/17/2006 Paul.  The USER_HASH has been removed from the main vwUSERS view to prevent its use in reports.
                            sSQL = "select *                     " + ControlChars.CrLf
                                   + "  from vwUSERS_Login         " + ControlChars.CrLf
                                   + " where ID        = @ID       " + ControlChars.CrLf
                                   + "   and USER_HASH = @USER_HASH" + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Sql.AddParameter(cmd, "@ID", gID);
                                Sql.AddParameter(cmd, "@USER_HASH", Security.HashPassword(txtOLD_PASSWORD.Value));
                                con.Open();
                                using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                {
                                    if (rdr.Read())
                                    {
                                        bValidOldPassword = true;
                                    }
                                }
                            }
                        }
                        if (!bValidOldPassword)
                        {
                            lblError.Text = L10n.Term("Users.ERR_PASSWORD_INCORRECT_OLD");
                        }
                    }
                    if (bValidOldPassword || Security.IS_ADMIN)
                    {
                        if (txtNEW_PASSWORD.Value == txtCONFIRM_PASSWORD.Value)
                        {
                            SqlProcs.spUSERS_PasswordUpdate(gID, Security.HashPassword(txtNEW_PASSWORD.Value));
                            if (bMyAccount)
                            {
                                Response.Redirect("MyAccount.aspx");
                            }
                            else
                            {
                                Response.Redirect("view.aspx?ID=" + gID.ToString());
                            }
                        }
                        else
                        {
                            lblError.Text = L10n.Term("Users.ERR_REENTER_PASSWORDS");
                        }
                    }
                }
                if (!IsPostBack)
                {
                    // 05/09/2006 Paul.  We need to always initialize the separators, just in case the user is new.
                    txtGROUP_SEPARATOR.Text   = SplendidDefaults.GroupSeparator();
                    txtDECIMAL_SEPARATOR.Text = SplendidDefaults.DecimalSeparator();
                    if (!Sql.IsEmptyGuid(gID))
                    {
                        DbProviderFactory dbf = DbProviderFactories.GetFactory();
                        using (IDbConnection con = dbf.CreateConnection())
                        {
                            string sSQL;
                            sSQL = "select *           " + ControlChars.CrLf
                                   + "  from vwUSERS_Edit" + ControlChars.CrLf
                                   + " where ID = @ID    " + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                Sql.AddParameter(cmd, "@ID", gID);
                                con.Open();

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

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

                                        // main
                                        txtNAME.Text      = Sql.ToString(rdr["FULL_NAME"]);
                                        txtUSER_NAME.Text = Sql.ToString(rdr["USER_NAME"]);
                                        txtSTATUS.Text    = Sql.ToString(L10n.Term(".user_status_dom.", rdr["STATUS"]));
                                        // user_settings
                                        chkIS_ADMIN.Checked              = Sql.ToBoolean(rdr["IS_ADMIN"]);
                                        chkPORTAL_ONLY.Checked           = Sql.ToBoolean(rdr["PORTAL_ONLY"]);
                                        chkRECEIVE_NOTIFICATIONS.Checked = Sql.ToBoolean(rdr["RECEIVE_NOTIFICATIONS"]);

                                        this.AppendDetailViewFields(m_sMODULE + ".DetailView", tblMain, rdr);
                                        // 08/05/2006 Paul.  MailOptions are populated manually.
                                        this.AppendDetailViewFields(m_sMODULE + ".MailOptions", tblMailOptions, null);
                                        // 01/20/2008 Paul.  The mail options panel is manually populated.
                                        new DynamicControl(this, "EMAIL1").Text = Sql.ToString(rdr["EMAIL1"]);
                                        new DynamicControl(this, "EMAIL2").Text = Sql.ToString(rdr["EMAIL2"]);

                                        string sUSER_PREFERENCES = Sql.ToString(rdr["USER_PREFERENCES"]);
                                        if (!Sql.IsEmptyString(sUSER_PREFERENCES))
                                        {
                                            XmlDocument xml = SplendidInit.InitUserPreferences(sUSER_PREFERENCES);
                                            try
                                            {
                                                // user_settings
                                                txtLANGUAGE.Text = L10N.NormalizeCulture(XmlUtil.SelectSingleNode(xml, "culture"));
                                                try
                                                {
                                                    DataView vwLanguages = new DataView(SplendidCache.Languages());
                                                    vwLanguages.RowFilter = "NAME = '" + txtLANGUAGE.Text + "'";
                                                    if (vwLanguages.Count > 0)
                                                    {
                                                        txtLANGUAGE.Text = Sql.ToString(vwLanguages[0]["NATIVE_NAME"]);
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                }
                                                txtDATEFORMAT.Text = XmlUtil.SelectSingleNode(xml, "dateformat");
                                                txtTIMEFORMAT.Text = XmlUtil.SelectSingleNode(xml, "timeformat");
                                                // 08/05/2006 Paul.  Remove stub of unsupported code. Show Gridline is not supported at this time.
                                                //chkGRIDLINE             .Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "gridline"             ));
                                                // mail_options
                                                new DynamicControl(this, "MAIL_FROMNAME").Text        = XmlUtil.SelectSingleNode(xml, "mail_fromname");
                                                new DynamicControl(this, "MAIL_FROMADDRESS").Text     = XmlUtil.SelectSingleNode(xml, "mail_fromaddress");
                                                new DynamicControl(this, "MAIL_SENDTYPE").Text        = XmlUtil.SelectSingleNode(xml, "mail_sendtype");
                                                new DynamicControl(this, "MAIL_SMTPSERVER").Text      = XmlUtil.SelectSingleNode(xml, "mail_smtpserver");
                                                new DynamicControl(this, "MAIL_SMTPPORT").Text        = XmlUtil.SelectSingleNode(xml, "mail_smtpport");
                                                new DynamicControl(this, "MAIL_SMTPAUTH_REQ").Checked = Sql.ToBoolean(XmlUtil.SelectSingleNode(xml, "mail_smtpauth_req"));
                                                new DynamicControl(this, "MAIL_SMTPUSER").Text        = XmlUtil.SelectSingleNode(xml, "mail_smtpuser");
                                                // freebusy
                                                // 08/05/2006 Paul.  Remove stub of unsupported code. Calendar Publish Key is not supported at this time.
                                                //txtCALENDAR_PUBLISH_KEY .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_publish_key" );
                                                //txtCALENDAR_PUBLISH_URL .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_publish_url" );
                                                //txtCALENDAR_SEARCH_URL  .Text    =               XmlUtil.SelectSingleNode(xml, "calendar_search_url"  );

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

                                                string   sTIMEZONE   = XmlUtil.SelectSingleNode(xml, "timezone");
                                                DataView vwTimezones = new DataView(SplendidCache.Timezones());
                                                vwTimezones.RowFilter = "ID = '" + sTIMEZONE + "'";
                                                if (vwTimezones.Count > 0)
                                                {
                                                    txtTIMEZONE.Text = Sql.ToString(vwTimezones[0]["NAME"]);
                                                }

                                                string   sCURRENCY    = XmlUtil.SelectSingleNode(xml, "currency_id");
                                                DataView vwCurrencies = new DataView(SplendidCache.Currencies());
                                                vwCurrencies.RowFilter = "ID = '" + sCURRENCY + "'";
                                                if (vwCurrencies.Count > 0)
                                                {
                                                    txtCURRENCY.Text = Sql.ToString(vwCurrencies[0]["NAME_SYMBOL"]);
                                                }
                                                // 08/05/2006 Paul.  Remove stub of unsupported code. Reminder is not supported at this time.

                                                /*
                                                 * try
                                                 * {
                                                 *      int nREMINDER_TIME = Sql.ToInteger(XmlUtil.SelectSingleNode(xml, "reminder_time"));
                                                 *      if ( nREMINDER_TIME > 0 )
                                                 *      {
                                                 *              txtREMINDER_TIME.Text = L10n.Term(".reminder_time_options." + nREMINDER_TIME.ToString());
                                                 *              chkREMINDER.Checked = true;
                                                 *      }
                                                 * }
                                                 * catch(Exception ex)
                                                 * {
                                                 *      SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                                                 * }
                                                 */
                                            }
                                            catch (Exception ex)
                                            {
                                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                                            }
                                        }
                                        //txtDESCRIPTION.Text = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String("YToxODp7czo4OiJncmlkbGluZSI7czozOiJvZmYiO3M6ODoibWF4X3RhYnMiO3M6MjoiMTIiO3M6MTI6ImRpc3BsYXlfdGFicyI7YToxNTp7aTowO3M6NDoiSG9tZSI7aToxO3M6NzoiaUZyYW1lcyI7aToyO3M6ODoiQ2FsZW5kYXIiO2k6MztzOjEwOiJBY3Rpdml0aWVzIjtpOjQ7czo4OiJBY2NvdW50cyI7aTo1O3M6NToiTGVhZHMiO2k6NjtzOjEzOiJPcHBvcnR1bml0aWVzIjtpOjc7czo1OiJDYXNlcyI7aTo4O3M6NDoiQnVncyI7aTo5O3M6OToiRG9jdW1lbnRzIjtpOjEwO3M6NjoiRW1haWxzIjtpOjExO3M6OToiQ2FtcGFpZ25zIjtpOjEyO3M6NzoiUHJvamVjdCI7aToxMztzOjU6IkZlZWRzIjtpOjE0O3M6OToiRGFzaGJvYXJkIjt9czoxMzoicmVtaW5kZXJfdGltZSI7czozOiI5MDAiO3M6NToidGltZWYiO3M6MzoiSDppIjtzOjg6ImN1cnJlbmN5IjtzOjM6Ii05OSI7czo1OiJkYXRlZiI7czo1OiJZLW0tZCI7czo1OiJ0aW1leiI7czoxOiIwIjtzOjEzOiJtYWlsX2Zyb21uYW1lIjtzOjQ6IlBhdWwiO3M6MTY6Im1haWxfZnJvbWFkZHJlc3MiO3M6MTM6InBhdWxAcm9ueS5jb20iO3M6MTM6Im1haWxfc2VuZHR5cGUiO3M6NDoiU01UUCI7czoxNToibWFpbF9zbXRwc2VydmVyIjtzOjM6Im5zMSI7czoxMzoibWFpbF9zbXRwcG9ydCI7czoyOiIyMyI7czoxMzoibWFpbF9zbXRwdXNlciI7czo4OiJwYXVscm9ueSI7czoxMzoibWFpbF9zbXRwcGFzcyI7czo3OiJwb2NrZXQxIjtzOjE3OiJtYWlsX3NtdHBhdXRoX3JlcSI7czowOiIiO3M6MTY6Im1haWxfcG9wYXV0aF9yZXEiO3M6MDoiIjtzOjIwOiJjYWxlbmRhcl9wdWJsaXNoX2tleSI7czoxMToicHVibGlzaCBoZXkiO30="));
                                    }
                                }
                            }
                        }
                    }
                }
                // 06/09/2006 Paul.  Remove data binding in the user controls.  Binding is required, but only do so in the ASPX pages.
                //Page.DataBind();
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                lblError.Text = ex.Message;
            }
        }
        /*
         *              <asp:Calendar ID="ctlCalendar" Width="100%" CssClass="monthBox" ShowGridLines="true"
         *                      CalendarSelectionMode="DayWeek" OnSelectionChanged="ctlCalendar_SelectionChanged" OnDayRender="ctlCalendar_DayRender"
         *                      Runat="server">
         *                      <TitleStyle         CssClass="monthHeader monthHeaderH3"   />
         *                      <NextPrevStyle      CssClass="monthHeader monthFooterPrev" />
         *                      <DayHeaderStyle     CssClass="monthCalBodyTHDay"           />
         *                      <DayStyle           CssClass="monthCalBodyWeekDay monthCalBodyWeekDayDateLink"      VerticalAlign="Top" />
         *                      <TodayDayStyle      CssClass="monthCalBodyTodayWeekDay monthCalBodyWeekDayDateLink" VerticalAlign="Top" />
         *                      <WeekendDayStyle    CssClass="monthCalBodyWeekEnd monthCalBodyWeekDayDateLink"      VerticalAlign="Top" />
         *                      <OtherMonthDayStyle CssClass="monthCalBodyWeekDay" ForeColor="#fafafa"              VerticalAlign="Top" />
         *              </asp:Calendar>
         */
        protected void BindGrid()
        {
            try
            {
                tblDailyCalTable.Rows.Clear();
                for (int nQuarter = 0; nQuarter < 4; nQuarter++)
                {
                    HtmlTableRow tr = new HtmlTableRow();
                    tblDailyCalTable.Rows.Add(tr);
                    for (int nQMonth = 1; nQMonth <= 3; nQMonth++)
                    {
                        HtmlTableCell td = new HtmlTableCell();
                        tr.Cells.Add(td);
                        td.VAlign = "top";
                        td.Align  = "center";
                        td.Attributes.Add("class", "yearCalBodyMonth");

                        DateTime dtCurrentMonth = new DateTime(dtCurrentDate.Year, 3 * nQuarter + nQMonth, 1);
                        try
                        {
                            // 09/30/2005 Paul.  Attempt to keep the day, but prevent a date overflow.
                            if (dtCurrentDate.Day <= dtCurrentMonth.AddMonths(1).AddDays(-1).Day)
                            {
                                dtCurrentMonth = dtCurrentMonth.AddDays(dtCurrentDate.Day - 1);
                            }
                            else
                            {
                                dtCurrentMonth = dtCurrentMonth.AddMonths(1).AddDays(-1);
                            }
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                        }
                        HyperLink lnkMonth = new HyperLink();
                        td.Controls.Add(lnkMonth);
                        lnkMonth.CssClass    = "yearCalBodyMonthLink";
                        lnkMonth.Text        = dtCurrentMonth.ToString("MMMM");
                        lnkMonth.NavigateUrl = "Month.aspx?" + CalendarQueryString(dtCurrentMonth);

                        System.Web.UI.WebControls.Calendar cal = new System.Web.UI.WebControls.Calendar();
                        td.Controls.Add(cal);
                        cal.VisibleDate                  = new DateTime(dtCurrentDate.Year, 3 * nQuarter + nQMonth, 1);
                        cal.Width                        = new Unit(100, UnitType.Percentage);
                        cal.CssClass                     = "monthBox";
                        cal.ShowGridLines                = true;
                        cal.ShowTitle                    = false;
                        cal.ShowNextPrevMonth            = false;
                        cal.SelectionMode                = CalendarSelectionMode.Day;
                        cal.TitleStyle.CssClass          = "monthHeader monthHeaderH3";
                        cal.DayHeaderStyle.CssClass      = "monthCalBodyTHDay";
                        cal.DayStyle.CssClass            = "monthCalBodyWeekDay monthCalBodyWeekDayDateLink";
                        cal.TodayDayStyle.CssClass       = "monthCalBodyTodayWeekDay monthCalBodyWeekDayDateLink";
                        cal.WeekendDayStyle.CssClass     = "monthCalBodyWeekEnd monthCalBodyWeekDayDateLink";
                        cal.OtherMonthDayStyle.CssClass  = "monthCalBodyWeekDay";
                        cal.OtherMonthDayStyle.ForeColor = System.Drawing.Color.FromArgb(0xfa, 0xfa, 0xfa);                        //"#fafafa";
                        cal.SelectionChanged            += new EventHandler(ctlCalendar_SelectionChanged);
                    }
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                lblError.Text = ex.Message;
            }
        }
Exemplo n.º 13
0
        protected void Page_Command(Object sender, CommandEventArgs e)
        {
            Guid   gPARENT_ID   = Sql.ToGuid(Request["PARENT_ID"]);
            string sMODULE      = String.Empty;
            string sPARENT_TYPE = String.Empty;
            string sPARENT_NAME = String.Empty;

            try
            {
                SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME);
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                // The only possible error is a connection failure, so just ignore all errors.
                gPARENT_ID = Guid.Empty;
            }
            if (e.CommandName == "Save")
            {
                // 01/16/2006 Paul.  Enable validator before validating page.
                this.ValidateEditViewFields(m_sMODULE + ".EditView");
                this.ValidateEditViewFields(m_sMODULE + ".EditAddress");
                if (Page.IsValid)
                {
                    string      sUSER_PREFERENCES = String.Empty;
                    XmlDocument xml = new XmlDocument();
                    try
                    {
                        try
                        {
                            sUSER_PREFERENCES = Sql.ToString(ViewState["USER_PREFERENCES"]);
                            xml.LoadXml(sUSER_PREFERENCES);
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                            xml.AppendChild(xml.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""));
                            xml.AppendChild(xml.CreateElement("USER_PREFERENCE"));
                        }
                        // user_settings
                        XmlUtil.SetSingleNode(xml, "gridline", chkGRIDLINE.Checked ? "true" : "false");
                        XmlUtil.SetSingleNode(xml, "culture", lstLANGUAGE.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "theme", lstTHEME.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "dateformat", lstDATE_FORMAT.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "timeformat", lstTIME_FORMAT.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "timezone", lstTIMEZONE.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "currency_id", lstCURRENCY.SelectedValue);
                        XmlUtil.SetSingleNode(xml, "num_grp_sep", txtGROUP_SEPARATOR.Text);
                        XmlUtil.SetSingleNode(xml, "dec_sep", txtDECIMAL_SEPARATOR.Text);
                        // 08/05/2006 Paul.  Remove stub of unsupported code. Reminder is not supported at this time.
                        //XmlUtil.SetSingleNode(xml, "reminder_time"       , chkSHOULD_REMIND.Checked ? lstREMINDER_TIME.SelectedValue : "0" );
                        // mail_options

                        string sMAIL_SMTPPASS = Sql.ToString(ViewState["mail_smtppass"]);
                        // 08/06/2005 Paul.  Password might be our empty value.
                        TextBox txtMAIL_SMTPPASS = FindControl("MAIL_SMTPPASS") as TextBox;
                        if (txtMAIL_SMTPPASS != null)
                        {
                            // 08/05/2006 Paul.  Allow the password to be cleared.
                            if (txtMAIL_SMTPPASS.Text != sEMPTY_PASSWORD)
                            {
                                sMAIL_SMTPPASS = txtMAIL_SMTPPASS.Text;
                            }
                        }

                        XmlUtil.SetSingleNode(xml, "mail_fromname", new DynamicControl(this, "MAIL_FROMNAME").Text);
                        XmlUtil.SetSingleNode(xml, "mail_fromaddress", new DynamicControl(this, "MAIL_FROMADDRESS").Text);
                        XmlUtil.SetSingleNode(xml, "mail_smtpserver", new DynamicControl(this, "MAIL_SMTPSERVER").Text);
                        XmlUtil.SetSingleNode(xml, "mail_smtpport", new DynamicControl(this, "MAIL_SMTPPORT").Text);
                        XmlUtil.SetSingleNode(xml, "mail_sendtype", new DynamicControl(this, "MAIL_SENDTYPE").Text);
                        XmlUtil.SetSingleNode(xml, "mail_smtpauth_req", new DynamicControl(this, "MAIL_SMTPAUTH_REQ").Checked ? "true" : "false");
                        XmlUtil.SetSingleNode(xml, "mail_smtpuser", new DynamicControl(this, "MAIL_SMTPUSER").Text);
                        XmlUtil.SetSingleNode(xml, "mail_smtppass", sMAIL_SMTPPASS);

                        // freebusy
                        // 08/05/2006 Paul.  Remove stub of unsupported code. Calendar Publish Key is not supported at this time.
                        //XmlUtil.SetSingleNode(xml, "calendar_publish_key", txtCALENDAR_PUBLISH_KEY .Text         );
                        //XmlUtil.SetSingleNode(xml, "calendar_publish_url", txtCALENDAR_PUBLISH_URL .Text         );
                        //XmlUtil.SetSingleNode(xml, "calendar_search_url" , txtCALENDAR_SEARCH_URL  .Text         );
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                    }
                    if (Sql.ToBoolean(Application["CONFIG.XML_UserPreferences"]))
                    {
                        sUSER_PREFERENCES = xml.OuterXml;
                    }
                    else
                    {
                        sUSER_PREFERENCES = XmlUtil.ConvertToPHP(xml.DocumentElement);
                    }

                    // 12/06/2005 Paul.  Need to prevent duplicate users.
                    string            sUSER_NAME = txtUSER_NAME.Text.Trim();
                    DbProviderFactory dbf        = DbProviderFactories.GetFactory();
                    try
                    {
                        // 11/10/2006 Paul.  If the decimal and group separate match, then .NET will not be able to parse decimals.
                        // The exception "Input string was not in a correct format." is thrown.
                        if (txtGROUP_SEPARATOR.Text == txtDECIMAL_SEPARATOR.Text)
                        {
                            throw(new Exception(L10n.Term("Users.LBL_INVALID_DECIMAL")));
                        }
                        if (!Sql.IsEmptyString(sUSER_NAME))
                        {
                            using (IDbConnection con = dbf.CreateConnection())
                            {
                                string sSQL;
                                sSQL = "select USER_NAME             " + ControlChars.CrLf
                                       + "  from vwUSERS               " + ControlChars.CrLf
                                       + " where USER_NAME = @USER_NAME" + ControlChars.CrLf;
                                using (IDbCommand cmd = con.CreateCommand())
                                {
                                    cmd.CommandText = sSQL;
                                    Sql.AddParameter(cmd, "@USER_NAME", sUSER_NAME);
                                    if (!Sql.IsEmptyGuid(gID))
                                    {
                                        // 12/06/2005 Paul.  Only include the ID if it is not null as we cannot compare NULL to anything.
                                        cmd.CommandText += "   and ID <> @ID" + ControlChars.CrLf;
                                        Sql.AddParameter(cmd, "@ID", gID);
                                    }
                                    con.Open();
                                    using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow))
                                    {
                                        if (rdr.Read())
                                        {
                                            string sMESSAGE = String.Empty;
                                            sMESSAGE = String.Format(L10n.Term("Users.ERR_USER_NAME_EXISTS_1") + "{0}" + L10n.Term("Users.ERR_USER_NAME_EXISTS_2"), sUSER_NAME);
                                            throw(new Exception(sMESSAGE));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                        ctlEditButtons.ErrorText = ex.Message;
                        return;
                    }

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

                        using (IDbTransaction trn = con.BeginTransaction())
                        {
                            try
                            {
                                bool bNewUser = Sql.IsEmptyGuid(gID);
                                // 04/24/2006 Paul.  Upgrade to SugarCRM 4.2 Schema.
                                // 11/18/2007 Paul.  Use the current values for any that are not defined in the edit view.
                                SqlProcs.spUSERS_Update
                                    (ref gID
                                    , sUSER_NAME
                                    , txtFIRST_NAME.Text
                                    , txtLAST_NAME.Text
                                    , new DynamicControl(this, rowCurrent, "REPORTS_TO_ID").ID
                                    , (Security.IS_ADMIN ? chkIS_ADMIN.Checked : Sql.ToBoolean(ViewState["IS_ADMIN"]))
                                    , chkRECEIVE_NOTIFICATIONS.Checked
                                    , new DynamicControl(this, rowCurrent, "DESCRIPTION").Text
                                    , new DynamicControl(this, rowCurrent, "TITLE").Text
                                    , new DynamicControl(this, rowCurrent, "DEPARTMENT").Text
                                    , new DynamicControl(this, rowCurrent, "PHONE_HOME").Text
                                    , new DynamicControl(this, rowCurrent, "PHONE_MOBILE").Text
                                    , new DynamicControl(this, rowCurrent, "PHONE_WORK").Text
                                    , new DynamicControl(this, rowCurrent, "PHONE_OTHER").Text
                                    , new DynamicControl(this, rowCurrent, "PHONE_FAX").Text
                                    , new DynamicControl(this, rowCurrent, "EMAIL1").Text
                                    , new DynamicControl(this, rowCurrent, "EMAIL2").Text
                                    , lstSTATUS.SelectedValue
                                    , new DynamicControl(this, rowCurrent, "ADDRESS_STREET").Text
                                    , new DynamicControl(this, rowCurrent, "ADDRESS_CITY").Text
                                    , new DynamicControl(this, rowCurrent, "ADDRESS_STATE").Text
                                    , new DynamicControl(this, rowCurrent, "ADDRESS_POSTALCODE").Text
                                    , new DynamicControl(this, rowCurrent, "ADDRESS_COUNTRY").Text
                                    , sUSER_PREFERENCES
                                    , chkPORTAL_ONLY.Checked
                                    , new DynamicControl(this, rowCurrent, "EMPLOYEE_STATUS").SelectedValue
                                    , new DynamicControl(this, rowCurrent, "MESSENGER_ID").Text
                                    , new DynamicControl(this, rowCurrent, "MESSENGER_TYPE").SelectedValue
                                    , sMODULE
                                    , gPARENT_ID
                                    , new DynamicControl(this, rowCurrent, "IS_GROUP").Checked
                                    , trn
                                    );
                                SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields);
                                trn.Commit();
                                // 09/09/2006 Paul.  Refresh cached user information.
                                if (bNewUser)
                                {
                                    SplendidCache.ClearUsers();
                                }
                                // 08/27/2005 Paul. Reload session with user preferences.
                                // 08/30/2005 Paul. Only reload preferences the user is editing his own profile.
                                // We want to allow an administrator to update other user profiles.
                                if (Security.USER_ID == gID)
                                {
                                    SplendidInit.LoadUserPreferences(gID, lstTHEME.SelectedValue, lstLANGUAGE.SelectedValue);
                                }
                            }
                            catch (Exception ex)
                            {
                                trn.Rollback();
                                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                                ctlEditButtons.ErrorText = ex.Message;
                                return;
                            }
                        }
                    }
                    if (!Sql.IsEmptyGuid(gPARENT_ID))
                    {
                        Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                    }
                    else if (bMyAccount)
                    {
                        Response.Redirect("MyAccount.aspx");
                    }
                    else
                    {
                        Response.Redirect("view.aspx?ID=" + gID.ToString());
                    }
                }
            }
            else if (e.CommandName == "Cancel")
            {
                if (!Sql.IsEmptyGuid(gPARENT_ID))
                {
                    Response.Redirect("~/" + sMODULE + "/view.aspx?ID=" + gPARENT_ID.ToString());
                }
                else if (bMyAccount)
                {
                    Response.Redirect("MyAccount.aspx");
                }
                else if (Sql.IsEmptyGuid(gID))
                {
                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Redirect("view.aspx?ID=" + gID.ToString());
                }
            }
        }
Exemplo n.º 14
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;
            }
        }
Exemplo n.º 15
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.
            this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0);
            if (!this.Visible)
            {
                return;
            }

            try
            {
                gID = Sql.ToGuid(Request["ID"]);
                if (!IsPostBack)
                {
                    // 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 vwTASKS_Edit" + ControlChars.CrLf;
                            using (IDbCommand cmd = con.CreateCommand())
                            {
                                cmd.CommandText = sSQL;
                                // 11/24/2006 Paul.  Use new Security.Filter() function to apply Team and ACL security rules.
                                Security.Filter(cmd, m_sMODULE, "edit");
                                if (!Sql.IsEmptyGuid(gDuplicateID))
                                {
                                    Sql.AppendParameter(cmd, gDuplicateID, "ID", false);
                                    gID = Guid.Empty;
                                }
                                else
                                {
                                    Sql.AppendParameter(cmd, gID, "ID", false);
                                }
                                con.Open();

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

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

                                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr);
                                        // 07/15/2006 Paul.  Contacts are not valid parents for a Task.
                                        // Manually remove them as the list record_type_display is common across all other parents.
                                        DropDownList lstPARENT_TYPE = FindControl("PARENT_TYPE") as DropDownList;
                                        if (lstPARENT_TYPE != null)
                                        {
                                            lstPARENT_TYPE.Items.Remove("Contacts");
                                        }

                                        // 03/04/2006 Paul.  The close button on the Tasks List is used to edit and set STATUS to Completed.
                                        // 06/21/2006 Paul.  Change parameter to Close so that the same parameter can be used for Calls, Meetings and Tasks.
                                        // 08/08/2006 Paul.  SugarCRM uses Completed in its URL, so we will do the same.
                                        if (Sql.ToString(Request["Status"]) == "Completed")
                                        {
                                            new DynamicControl(this, "STATUS").SelectedValue = "Completed";
                                        }
                                    }
                                    else
                                    {
                                        // 11/25/2006 Paul.  If item is not visible, then don't allow save
                                        ctlEditButtons.DisableAll();
                                        ctlEditButtons.ErrorText = L10n.Term("ACL.LBL_NO_ACCESS");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null);
                        // 07/15/2006 Paul.  Contacts are not valid parents for a Task.
                        // Manually remove them as the list record_type_display is common across all other parents.
                        DropDownList lstPARENT_TYPE = FindControl("PARENT_TYPE") as DropDownList;
                        if (lstPARENT_TYPE != null)
                        {
                            lstPARENT_TYPE.Items.Remove("Contacts");
                        }

                        Guid gPARENT_ID  = Sql.ToGuid(Request["PARENT_ID"]);
                        Guid gCONTACT_ID = Sql.ToGuid(Request["CONTACT_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))
                            {
                                // 07/15/2006 Paul.  If the parent is a contact, then convert to a contact.
                                if (sPARENT_TYPE == "Contacts")
                                {
                                    gCONTACT_ID = gPARENT_ID;
                                }
                                else
                                {
                                    new DynamicControl(this, "PARENT_ID").ID              = gPARENT_ID;
                                    new DynamicControl(this, "PARENT_NAME").Text          = sPARENT_NAME;
                                    new DynamicControl(this, "PARENT_TYPE").SelectedValue = sPARENT_TYPE;
                                }
                            }
                        }
                        if (!Sql.IsEmptyGuid(gCONTACT_ID))
                        {
                            string sMODULE       = String.Empty;
                            string sCONTACT_TYPE = String.Empty;
                            string sCONTACT_NAME = String.Empty;
                            SqlProcs.spPARENT_Get(ref gCONTACT_ID, ref sMODULE, ref sCONTACT_TYPE, ref sCONTACT_NAME);
                            if (!Sql.IsEmptyGuid(gCONTACT_ID))
                            {
                                new DynamicControl(this, "CONTACT_ID").ID     = gCONTACT_ID;
                                new DynamicControl(this, "CONTACT_NAME").Text = sCONTACT_NAME;
                            }
                        }
                        try
                        {
                            // 12/04/2005 Paul.  Default value is Medium.
                            new DynamicControl(this, "PRIORITY").SelectedValue = "Medium";
                        }
                        catch (Exception ex)
                        {
                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex);
                        }
                        try
                        {
                            // 12/04/2005 Paul.  Default value is Not Started.
                            new DynamicControl(this, "STATUS").SelectedValue = "Not Started";
                        }
                        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." + m_sMODULE) + " - " + ctlModuleHeader.Title);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }
Exemplo n.º 16
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Utils.SetPageTitle(Page, L10n.Term(".moduleList.Administration"));
            // 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
            {
                if (!IsPostBack)
                {
                    lstMAIL_SENDTYPE.DataSource = SplendidCache.List("notifymail_sendtype");
                    lstMAIL_SENDTYPE.DataBind();

                    DbProviderFactory dbf = DbProviderFactories.GetFactory();
                    using (IDbConnection con = dbf.CreateConnection())
                    {
                        string sSQL;
                        sSQL = "select *        " + ControlChars.CrLf
                               + "  from vwCONFIG " + ControlChars.CrLf
                               + " where CATEGORY_NAME in ( 'notify_fromname'       " + ControlChars.CrLf
                               + "                        , 'notify_fromaddress'    " + ControlChars.CrLf
                               + "                        , 'notify_on'             " + ControlChars.CrLf
                               + "                        , 'notify_send_by_default'" + ControlChars.CrLf
                               + "                        , 'mail_smtpserver'       " + ControlChars.CrLf
                               + "                        , 'mail_smtpport'         " + ControlChars.CrLf
                               + "                        , 'mail_smtpauth_req'     " + ControlChars.CrLf
                               + "                        , 'mail_smtpuser'         " + ControlChars.CrLf
                               + "                        , 'mail_smtppass'         " + ControlChars.CrLf
                               + "                        )" + ControlChars.CrLf;
                        using (IDbCommand cmd = con.CreateCommand())
                        {
                            cmd.CommandText = sSQL;
                            con.Open();
#if DEBUG
                            Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd));
#endif
                            using (IDataReader rdr = cmd.ExecuteReader())
                            {
                                while (rdr.Read())
                                {
                                    string sCATEGORY_NAME = Sql.ToString(rdr["CATEGORY_NAME"]);
                                    switch (sCATEGORY_NAME.ToUpper())
                                    {
                                    case "NOTIFY_FROMNAME":  txtNOTIFY_FROMNAME.Text = Sql.ToString(rdr["VALUE"]);  break;

                                    case "NOTIFY_FROMADDRESS":  txtNOTIFY_FROMADDRESS.Text = Sql.ToString(rdr["VALUE"]);  break;

                                    case "NOTIFY_ON":  chkNOTIFY_ON.Checked = Sql.ToBoolean(rdr["VALUE"]);  break;

                                    case "NOTIFY_SEND_BY_DEFAULT":  chkNOTIFY_SEND_BY_DEFAULT.Checked = Sql.ToBoolean(rdr["VALUE"]);  break;

                                    case "MAIL_SMTPSERVER":  txtMAIL_SMTPSERVER.Text = Sql.ToString(rdr["VALUE"]);  break;

                                    case "MAIL_SMTPPORT":  txtMAIL_SMTPPORT.Text = Sql.ToString(rdr["VALUE"]);  break;

                                    case "MAIL_SMTPAUTH_REQ":  chkMAIL_SMTPAUTH_REQ.Checked = Sql.ToBoolean(rdr["VALUE"]);  break;

                                    case "MAIL_SMTPUSER":  txtMAIL_SMTPUSER.Text = Sql.ToString(rdr["VALUE"]);  break;

                                    case "MAIL_SMTPPASS":  txtMAIL_SMTPPASS.Text = Sql.ToString(rdr["VALUE"]);  break;

                                    case "PORTAL_ON":  chkPORTAL_ON.Checked = Sql.ToBoolean(rdr["VALUE"]);  break;

                                    case "MAIL_SENDTYPE":
                                        try
                                        {
                                            lstMAIL_SENDTYPE.SelectedValue = Sql.ToString(rdr["VALUE"]);
                                        }
                                        catch (Exception ex)
                                        {
                                            SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                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.Administration") + " - " + ctlModuleHeader.Title);
                }
            }
            catch (Exception ex)
            {
                SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message);
                ctlEditButtons.ErrorText = ex.Message;
            }
        }