Exemplo n.º 1
0
        protected void cityList_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                DistrictList.Items.Clear();
                SqlCommand command = new SqlCommand("EXEC ListAllDistrictsWithCity " + cityList.SelectedItem.Value, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                DistrictList.DataSource     = reader;
                DistrictList.DataTextField  = "Name";
                DistrictList.DataValueField = "ID";
                DistrictList.DataBind();
            }

            CompanyList.Items.Clear();
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand("EXEC ShowCompanyOnDistrict " + DistrictList.SelectedItem.Value, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                CompanyList.DataSource     = reader;
                CompanyList.DataTextField  = "CompanyName";
                CompanyList.DataValueField = "ID";
                CompanyList.DataBind();
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!Request.IsAuthenticated || LUser == null || LUser.LoginName.ToLower() == "anonymous")
                {
                    string loginUrl = System.Web.Security.FormsAuthentication.LoginUrl;
                    if (string.IsNullOrEmpty(loginUrl))
                    {
                        loginUrl = "~/MyAccount.aspx";
                    }
                    SignIn.Visible        = true; SignIn.NavigateUrl = loginUrl + (loginUrl.Contains("?") ? "&" : "?") + "logo=N";
                    SignoutPanel.Visible  = false;
                    cLoginName.Visible    = false;
                    cAppDomainUrl.Visible = false;
                    return;
                }
                else
                {
                    string extAppDomainUrl =
                        !string.IsNullOrWhiteSpace(System.Configuration.ConfigurationManager.AppSettings["ExtBaseUrl"])
                            ? System.Configuration.ConfigurationManager.AppSettings["ExtBaseUrl"]
                            : Request.Url.AbsoluteUri.Replace(Request.Url.Query, "").Replace(Request.Url.Segments[Request.Url.Segments.Length - 1], "");
                    cAppDomainUrl.Text    = extAppDomainUrl.EndsWith("/") ? extAppDomainUrl.Substring(0, extAppDomainUrl.Length - 1) : extAppDomainUrl;
                    cAppDomainUrl.Visible = true;
                    SignIn.Visible        = false;
                    SignoutPanel.Visible  = true;
                    cLoginName.Text       = LUser.LoginName;
                    cLoginName.Visible    = true;
                }
                if (LUser != null)
                {
                    if (base.LPref != null)
                    {
                        switch (base.LPref.SysListVisible)
                        {
                        case "N":
                            SystemsLabel.Visible = false; SystemsList.Visible = false; SystemsList.Enabled = true; CurrSys.Visible = false; break;

                        case "R":
                            SystemsLabel.Visible = true; SystemsList.Visible = true; SystemsList.Enabled = false; CurrSys.Visible = true; break;

                        default:
                            SystemsLabel.Visible = true; SystemsList.Visible = true; SystemsList.Enabled = true; CurrSys.Visible = true; break;
                        }
                        switch (base.LPref.PrjListVisible)
                        {
                        case "N":
                            ProjectLabel.Visible = false; ProjectList.Visible = false; ProjectList.Enabled = true; CurrPrj.Visible = false; break;

                        case "R":
                            ProjectLabel.Visible = true; ProjectList.Visible = true; ProjectList.Enabled = false; CurrPrj.Visible = true; break;

                        default:
                            ProjectLabel.Visible = true; ProjectList.Visible = true; ProjectList.Enabled = true; CurrPrj.Visible = true; break;
                        }
                        switch (base.LPref.ComListVisible)
                        {
                        case "N":
                            CompanyLabel.Visible = false; CompanyList.Visible = false; CompanyList.Enabled = true; CurrCmp.Visible = false; break;

                        case "R":
                            CompanyLabel.Visible = true; CompanyList.Visible = true; CompanyList.Enabled = false; CurrCmp.Visible = true; break;

                        default:
                            CompanyLabel.Visible = true; CompanyList.Visible = true; CompanyList.Enabled = true; CurrCmp.Visible = true; break;
                        }
                    }

                    CompanyList.Attributes["onchange"] = "javascript:return CanPostBack(true, this);"; CompanyList.Attributes["NeedConfirm"] = "Y";
                    ProjectList.Attributes["onchange"] = "javascript:return CanPostBack(true, this);"; ProjectList.Attributes["NeedConfirm"] = "Y";
                    SystemsList.Attributes["onchange"] = "javascript:return CanPostBack(true, this);"; SystemsList.Attributes["NeedConfirm"] = "Y";

                    UserLabel.Text = LUser != null ? LUser.UsrName : Context.User.Identity.Name;
                    if (LUser.HasPic)
                    {
                        UsrPic.ImageUrl = base.GetUrlWithQSHash("~/DnLoad.aspx?key=" + LUser.UsrId.ToString() + "&tbl=dbo.Usr&knm=UsrId&col=PicMed&sys=3"); UsrPic.Visible = true;
                    }

                    SystemsList.DataSource  = GetSystemsList();
                    CompanyList.DataSource  = GetCompanyList();
                    ProjectList.DataSource  = GetProjectList();
                    TimeZoneList.DataSource = GetTimeZoneList();

                    TranslateItems();

                    this.DataBind();
                    try { SystemsList.SelectedValue = LCurr.SystemId.ToString(); CurrSys.Text = SystemsList.SelectedItem.Text; }
                    catch { }
                    try { CompanyList.SelectedValue = LCurr.CompanyId.ToString(); CurrCmp.Text = CompanyList.SelectedItem.Text; }
                    catch { }
                    try { ProjectList.SelectedValue = LCurr.ProjectId.ToString(); CurrPrj.Text = ProjectList.SelectedItem.Text; }
                    catch { }
                    try { TimeZoneList.SelectedValue = CurrTimeZoneInfo().Id; }
                    catch { }
                    cMyAccountLink.NavigateUrl = System.Web.Security.FormsAuthentication.LoginUrl; // +(Request.QueryString["typ"] != null ? "?typ=" + Request.QueryString["typ"] : "");
                }
            }
            else if (Request.IsAuthenticated && base.LUser != null)     // Get around selectedIndexChange event not triggered because of viewstate-in-session.
            {
                if (SystemsList.Items.Count <= 0 && Request.Params["__EVENTTARGET"] == SystemsList.UniqueID)
                {
                    SystemsList.DataSource    = GetSystemsList(); SystemsList.DataBind();
                    SystemsList.SelectedValue = Request.Params[SystemsList.UniqueID];
                    SystemsList_SelectedIndexChanged(SystemsList, new EventArgs());
                }
                if (CompanyList.Items.Count <= 0 && Request.Params["__EVENTTARGET"] == CompanyList.UniqueID)
                {
                    CompanyList.DataSource    = GetCompanyList(); CompanyList.DataBind();
                    CompanyList.SelectedValue = Request.Params[CompanyList.UniqueID];
                    CompanyList_SelectedIndexChanged(CompanyList, new EventArgs());
                }
                if (ProjectList.Items.Count <= 0 && Request.Params["__EVENTTARGET"] == ProjectList.UniqueID)
                {
                    ProjectList.DataSource    = GetProjectList(); ProjectList.DataBind();
                    ProjectList.SelectedValue = Request.Params[ProjectList.UniqueID];
                    ProjectList_SelectedIndexChanged(ProjectList, new EventArgs());
                }
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                string extAppDomainUrl =
                    !string.IsNullOrWhiteSpace(Config.ExtBaseUrl)
                        ? Config.ExtBaseUrl
                        : string.IsNullOrEmpty(Request.Url.Query) ? Request.Url.AbsoluteUri.Replace(Request.Url.Segments[Request.Url.Segments.Length - 1], "")
                        : Request.Url.AbsoluteUri.Replace(Request.Url.Query, "").Replace(Request.Url.Segments[Request.Url.Segments.Length - 1], "");
                cAppDomainUrl.Text = extAppDomainUrl.EndsWith("/") ? extAppDomainUrl.Substring(0, extAppDomainUrl.Length - 1) : extAppDomainUrl;
                if (!Request.IsAuthenticated || LUser == null || LUser.LoginName.ToLower() == "anonymous")
                {
                    string loginUrl = System.Web.Security.FormsAuthentication.LoginUrl;
                    if (string.IsNullOrEmpty(loginUrl))
                    {
                        loginUrl = "~/MyAccount.aspx";
                    }
                    SignIn.Visible       = true; SignIn.NavigateUrl = loginUrl + (loginUrl.Contains("?") ? "&" : "?") + "logo=N";
                    SignoutPanel.Visible = false;
                    cLoginName.Visible   = false;
                    // for client side login sync between React and asp.net(only when served under the same app tree
                    // this controls react/asp.net login sync for 'showpage' like usage, turn this off would disable auto login(from react token) in show page and other public page
                    cAppDomainUrl.Visible = true;
                    return;
                }
                else
                {
                    cAppDomainUrl.Visible = true;
                    SignIn.Visible        = false;
                    SignoutPanel.Visible  = true;
                    cLoginName.Text       = LUser.LoginName;
                    cLoginName.Visible    = true;
                }
                if (LUser != null)
                {
                    if (base.LPref != null)
                    {
                        switch (base.LPref.SysListVisible)
                        {
                        case "N":
                            SystemsLabel.Visible = false; SystemsList.Visible = false; SystemsList.Enabled = true; CurrSys.Visible = false; break;

                        case "R":
                            SystemsLabel.Visible = true; SystemsList.Visible = true; SystemsList.Enabled = false; CurrSys.Visible = true; break;

                        default:
                            SystemsLabel.Visible = true; SystemsList.Visible = true; SystemsList.Enabled = true; CurrSys.Visible = true; break;
                        }
                        switch (base.LPref.PrjListVisible)
                        {
                        case "N":
                            ProjectLabel.Visible = false; ProjectList.Visible = false; ProjectList.Enabled = true; CurrPrj.Visible = false; break;

                        case "R":
                            ProjectLabel.Visible = true; ProjectList.Visible = true; ProjectList.Enabled = false; CurrPrj.Visible = true; break;

                        default:
                            ProjectLabel.Visible = true; ProjectList.Visible = true; ProjectList.Enabled = true; CurrPrj.Visible = true; break;
                        }
                        switch (base.LPref.ComListVisible)
                        {
                        case "N":
                            CompanyLabel.Visible = false; CompanyList.Visible = false; CompanyList.Enabled = true; CurrCmp.Visible = false; break;

                        case "R":
                            CompanyLabel.Visible = true; CompanyList.Visible = true; CompanyList.Enabled = false; CurrCmp.Visible = true; break;

                        default:
                            CompanyLabel.Visible = true; CompanyList.Visible = true; CompanyList.Enabled = true; CurrCmp.Visible = true; break;
                        }
                    }

                    CompanyList.Attributes["onchange"] = "javascript:return CanPostBack(true, this);"; CompanyList.Attributes["NeedConfirm"] = "Y";
                    ProjectList.Attributes["onchange"] = "javascript:return CanPostBack(true, this);"; ProjectList.Attributes["NeedConfirm"] = "Y";
                    SystemsList.Attributes["onchange"] = "javascript:return CanPostBack(true, this);"; SystemsList.Attributes["NeedConfirm"] = "Y";

                    UserLabel.Text = LUser != null ? LUser.UsrName : Context.User.Identity.Name;
                    if (LUser.HasPic)
                    {
                        UsrPic.ImageUrl = base.GetUrlWithQSHash("~/DnLoad.aspx?key=" + LUser.UsrId.ToString() + "&tbl=dbo.Usr&knm=UsrId&col=PicMed&sys=3"); UsrPic.Visible = true;
                    }


                    SystemsList.DataSource = GetSystemsList();
                    if (LCurr != null && LUser != null)
                    {
                        DataTable dtSystem = GetCompanyProf();
                        if (dtSystem != null && dtSystem.Rows.Count > 0)
                        {
                            string   logo     = dtSystem.Rows[0]["CompanyLogo"].ToString();
                            string   systemLs = dtSystem.Rows[0]["SystemLs"].ToString();
                            DataView dv       = GetSystemsList();
                            if (!string.IsNullOrEmpty(systemLs) && systemLs != "()")
                            {
                                dv.RowFilter           = "Active='Y' AND SystemId IN " + systemLs;
                                SystemsList.DataSource = dv;
                            }
                        }
                    }
                    CompanyList.DataSource  = GetCompanyList();
                    ProjectList.DataSource  = GetProjectList();
                    TimeZoneList.DataSource = GetTimeZoneList();

                    TranslateItems();

                    this.DataBind();
                    try { SystemsList.SelectedValue = LCurr.SystemId.ToString(); CurrSys.Text = SystemsList.SelectedItem.Text; }
                    catch { }
                    try { CompanyList.SelectedValue = LCurr.CompanyId.ToString(); CurrCmp.Text = CompanyList.SelectedItem.Text; }
                    catch { }
                    try { ProjectList.SelectedValue = LCurr.ProjectId.ToString(); CurrPrj.Text = ProjectList.SelectedItem.Text; }
                    catch { }
                    try { TimeZoneList.SelectedValue = CurrTimeZoneInfo().Id; }
                    catch { }
                    cMyAccountLink.NavigateUrl = System.Web.Security.FormsAuthentication.LoginUrl; // +(Request.QueryString["typ"] != null ? "?typ=" + Request.QueryString["typ"] : "");
                }
            }
            else if (Request.IsAuthenticated && base.LUser != null)     // Get around selectedIndexChange event not triggered because of viewstate-in-session.
            {
                if (SystemsList.Items.Count <= 0 && Request.Params["__EVENTTARGET"] == SystemsList.UniqueID)
                {
                    SystemsList.DataSource    = GetSystemsList(); SystemsList.DataBind();
                    SystemsList.SelectedValue = Request.Params[SystemsList.UniqueID];
                    SystemsList_SelectedIndexChanged(SystemsList, new EventArgs());
                }
                if (CompanyList.Items.Count <= 0 && Request.Params["__EVENTTARGET"] == CompanyList.UniqueID)
                {
                    CompanyList.DataSource    = GetCompanyList(); CompanyList.DataBind();
                    CompanyList.SelectedValue = Request.Params[CompanyList.UniqueID];
                    CompanyList_SelectedIndexChanged(CompanyList, new EventArgs());
                }
                if (ProjectList.Items.Count <= 0 && Request.Params["__EVENTTARGET"] == ProjectList.UniqueID)
                {
                    ProjectList.DataSource    = GetProjectList(); ProjectList.DataBind();
                    ProjectList.SelectedValue = Request.Params[ProjectList.UniqueID];
                    ProjectList_SelectedIndexChanged(ProjectList, new EventArgs());
                }
            }
        }
Exemplo n.º 4
0
        private void ContSearchAz_Click(object sender, EventArgs e)
        {
            CompanyList.Fields.Clear();
            CompanyList.DataSource = null;
            StringBuilder query = new StringBuilder();

            query.Append("SELECT ID,COMPANYNAME,INVOICINGADDRESS,INVOICINGCITY,INVOICINGSTATEPROVINCE,INVOICINGSTATE,INVOICINGZIPCODE,PHONE,FAX,EMAIL ");
            query.AppendFormat("FROM BASE_COMPANIES WHERE (LIMBO=0 AND ({0})) ", (GroupsSecure("BASE_COMPANIES").Length > 0) ? GroupsSecure("BASE_COMPANIES") : "Base_Companies.groups like '%|" + UC.UserGroupId + "|%'");
            query.AppendFormat("AND (COMPANYNAME LIKE '%{0}%' OR PHONE LIKE '%{0}%')", ContQuery.Text);
            DataTable dt = DatabaseConnection.CreateDataset(query.ToString()).Tables[0];

            if (dt.Rows.Count > 0)
            {
                CompanyList.DataSource = dt;
                ObjectListField ListField1 = new ObjectListField();
                ListField1.DataField = "companyname";
                ListField1.Visible   = false;
                ListField1.Title     = SimpleG.rm.GetString("Bcotxt17");
                CompanyList.Fields.Add(ListField1);
                ListField1           = new ObjectListField();
                ListField1.DataField = "Phone";
                ListField1.Name      = "CALL";
                ListField1.Title     = SimpleG.rm.GetString("Bcotxt20");
                CompanyList.Fields.Add(ListField1);
                ListField1           = new ObjectListField();
                ListField1.DataField = "InvoicingAddress";
                ListField1.Title     = SimpleG.rm.GetString("Bcotxt26");
                CompanyList.Fields.Add(ListField1);
                ListField1           = new ObjectListField();
                ListField1.DataField = "InvoicingCity";
                ListField1.Title     = SimpleG.rm.GetString("Bcotxt27");
                CompanyList.Fields.Add(ListField1);
                ListField1           = new ObjectListField();
                ListField1.DataField = "InvoicingStateProvince";
                ListField1.Title     = SimpleG.rm.GetString("Bcotxt28");
                CompanyList.Fields.Add(ListField1);
                ListField1           = new ObjectListField();
                ListField1.DataField = "InvoicingState";
                ListField1.Title     = SimpleG.rm.GetString("Bcotxt53");
                CompanyList.Fields.Add(ListField1);
                ListField1           = new ObjectListField();
                ListField1.DataField = "InvoicingZIPCode";
                ListField1.Title     = SimpleG.rm.GetString("Bcotxt29");
                CompanyList.Fields.Add(ListField1);
                ListField1           = new ObjectListField();
                ListField1.DataField = "Fax";
                ListField1.Title     = SimpleG.rm.GetString("Bcotxt21");
                CompanyList.Fields.Add(ListField1);
                ListField1.DataField = "Email";
                ListField1.Name      = "MAIL";
                ListField1.Title     = SimpleG.rm.GetString("Bcotxt22");
                CompanyList.Fields.Add(ListField1);
                CompanyList.AutoGenerateFields = false;
                CompanyList.ItemsPerPage       = 5;
                CompanyList.DataBind();
                CompanyList.Visible = true;
                Clearpanels();
                CompanyPanel.Visible = true;
                Bback.Visible        = true;
                SearchInfo.Visible   = false;
            }
            else
            {
                SearchInfo.Text    = SimpleG.rm.GetString("WAPtxt7");
                SearchInfo.Visible = true;
            }
        }