protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    using (QCAstServiceClient client = new QCAstServiceClient())
                    {
                        int  idUser = int.Parse(Session["IdUser"].ToString());
                        User user   = client.GetUserFromId(idUser);

                        if (user.IdProfile != 4 & user.IdProfile != 3)
                        {
                            Response.Redirect("ErrorPage.aspx?Error=NotAuthorised", false);
                        }
                        else
                        {
                            ddlPrefContactMethod.DataSource = client.GetAllContactMethods();
                            ddlPrefContactMethod.DataBind();
                            lbSearchedClients.DataSource = client.GetAllClients("All", "");
                            lbSearchedClients.DataBind();
                            ddlPrefContactMethod.Items.Insert(0, new ListItem("Please select..", "0"));
                            trButtons.Visible      = false;
                            ibEditClient.Enabled   = false;
                            ibDeleteClient.Enabled = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    NotifyWebmasterOfError("Billing", "Client Management Page Load", ex.ToString());
                    Response.Redirect("ErrorPage.aspx?Error=GeneralError", true);
                }
            }
        }
        protected void lbSearchedUsers_SelectedIndexChanged(object sender, EventArgs e)
        {
            int id = int.Parse(((ListBox)sender).SelectedValue);

            try
            {
                using (QCAstServiceClient client = new QCAstServiceClient())
                {
                    User user = client.GetUserFromId(id);
                    tbUserId.Text             = user.IdUser.ToString();
                    tbUsername.Text           = user.Username;
                    tbPassword.Text           = user.Password;
                    ddlProfiles.SelectedIndex = user.IdProfile;
                    if (user.IdClient != null)
                    {
                        ddlClient.SelectedIndex = ddlClient.Items.IndexOf(ddlClient.Items.FindByValue(user.IdClient.Value.ToString()));
                    }
                    else
                    {
                        ddlClient.SelectedIndex = 0;
                    }
                }
                ibEditUser.Enabled   = true;
                ibDeleteUser.Enabled = true;
            }
            catch (Exception ex)
            {
                NotifyWebmasterOfError("Billing", "User Management SearchSelectedIndexChanged", ex.ToString());
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IdUser"] == null)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                if (!IsPostBack)
                {
                    try
                    {
                        HideDivs();
                        idUser = int.Parse(Session["IdUser"].ToString());
                        int idProfile = 0;
                        using (QCAstServiceClient serviceRef = new QCAstServiceClient())
                        {
                            idProfile = serviceRef.GetUserFromId(idUser).IdProfile;

                            switch (idProfile)
                            {
                            case 1:
                                divUserMenu.Visible = true;
                                break;

                            case 2:
                                divDatamanagerMenu.Visible = true;
                                break;

                            case 3:
                                divClientManagerMenu.Visible = true;
                                break;

                            case 4:
                                divAdminMenu.Visible = true;
                                break;

                            case 5:
                                divClientMenu.Visible = true;
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        NotifyWebmasterOfError("QCAstBilling", "Site.Master", ex.ToString());
                        Response.Redirect("ErrorPage.aspx?Error=GeneralError", true);
                    }
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["IdUser"] == null)
     {
         FormsAuthentication.RedirectToLoginPage();
     }
     else
     {
         if (!IsPostBack)
         {
             try
             {
                 using (QCAstServiceClient client = new QCAstServiceClient())
                 {
                     int  idUser = int.Parse(Session["IdUser"].ToString());
                     User user   = client.GetUserFromId(idUser);
                     if (user.IdClient == null)
                     {
                         Response.Redirect("AdminBilling.aspx");
                     }
                     else
                     {
                         int idClient = user.IdClient.Value;
                         ddlClientInvoiceHistory.Items.Clear();
                         ddlClientInvoiceHistory.DataSource = client.GetInvoicesForClient(idClient);
                         ddlClientInvoiceHistory.DataBind();
                         ddlClientInvoiceHistory.Items.Insert(0, new ListItem("Please select..", "0"));
                         Session.Add("IdClient", idClient);
                     }
                 }
             }
             catch (Exception ex)
             {
                 NotifyWebmasterOfError("Billing", "ClientBilling Page_Load", ex.ToString());
                 Response.Redirect("ErrorPage.aspx?Error=GeneralError");
             }
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (Session["IdUser"] == null)
         {
             FormsAuthentication.RedirectToLoginPage();
         }
         else
         {
             var idUser = int.Parse(Session["IdUser"].ToString());
             try
             {
                 using (var serviceClient = new QCAstServiceClient())
                 {
                     var user = serviceClient.GetUserFromId(idUser);
                     if (user.IdProfile != 4)
                     {
                         Response.Redirect("ErrorPage.aspx?Error=NotAuthorised");
                     }
                     else
                     {
                         ddlReport.DataSource = serviceClient.GetAllReports();
                         ddlReport.DataBind();
                         ddlReport.Items.Insert(0, new ListItem("Please select..", "0"));
                         ddlClient.DataSource = serviceClient.GetAllClients("All", "");
                         ddlClient.DataBind();
                         ddlClient.Items.Insert(0, new ListItem("Please select..", "0"));
                         ClearListAndTextBoxes();
                     }
                 }
             }
             catch (Exception ex)
             {
                 NotifyWebmasterOfError("Billing", "Reports PageLoad", ex.ToString());   
             }
         }
     }
 }