예제 #1
0
 public void ResetOffice()
 {
     SelectedUsersected.DataTextField  = "UserName";
     SelectedUsersected.DataValueField = "uid";
     SelectedUsersected.DataSource     = DatabaseConnection.CreateDataset("SELECT UID,(SURNAME+' '+NAME) AS USERNAME FROM ACCOUNT WHERE UID=" + UC.UserId);
     SelectedUsersected.DataBind();
 }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session.IsNewSession)
            {
                HttpContext.Current.Response.Redirect("/login.aspx");
            }


            UC        = (UserConfig)HttpContext.Current.Session["UserConfig"];
            controlId = this.ID;



            SearchUserSubmit.Attributes.Add("ondownloadready", "DownloadElement = this;GroupPostBack = false;");
            SearchUserSubmit.Attributes.Add("ondownloadnotsupported", "GroupPostBack = true;");
            SearchUserSubmit.Attributes.Add("onclick", "checkMode('GetXmlAccount.aspx?c=' + document.getElementById('" + controlId + "_SearchUser').value,'" + controlId + "OfficeUsers',this);return false;");


            if (!Page.IsPostBack)
            {
                FillOffices();
                OfficeUsers.Items.Clear();
                if (SelectedUsersected.Items.Count <= 0)
                {
                    SelectedUsersected.DataTextField  = "UserName";
                    SelectedUsersected.DataValueField = "uid";
                    try
                    {
                        SelectedUsersected.DataSource = DatabaseConnection.CreateDataset("SELECT UID,(SURNAME+' '+NAME) AS USERNAME FROM ACCOUNT WHERE UID=" + UC.UserId);
                    }
                    catch
                    {
                        SelectedUsersected.DataSource = DatabaseConnection.CreateDataset("SELECT UID,(SURNAME+' '+NAME) AS USERNAME FROM ACCOUNT WHERE UID=1");
                    }
                    SelectedUsersected.DataBind();
                }
                if (ClearUserList)
                {
                    this.CleanUsers();
                }
            }
            else
            {
                if (GroupValue.Value.Length > 0)
                {
                    SetAccount(GroupValue.Value);
                }
            }
        }
예제 #3
0
        public void SetAccount(string value)
        {
            string query = String.Empty;

            GroupValue.Value = value;
            try
            {
                string[] arryD = value.ToString().Split('|');
                foreach (string ut in arryD)
                {
                    if (ut.Length > 0)
                    {
                        query += "ACCOUNT.UID=" + ut + " OR ";
                    }
                }
                query = query.Substring(0, query.Length - 3);

                SelectedUsersected.Items.Clear();
                if (SelectedUsersected.Items.Count <= 0)
                {
                    SelectedUsersected.DataTextField  = "descrizione";
                    SelectedUsersected.DataValueField = "uid";
                    string sqlString = "SELECT ACCOUNT.UID, (ACCOUNT.SURNAME+' '+ACCOUNT.NAME+' ('+OFFICES.OFFICE+')') AS DESCRIZIONE ";
                    sqlString += "FROM ACCOUNT INNER JOIN OFFICES ON ACCOUNT.OFFICEID=OFFICES.ID WHERE (" + query + ") ORDER BY SURNAME,NAME ASC";
                    SelectedUsersected.DataSource = DatabaseConnection.CreateDataset(sqlString);
                    SelectedUsersected.DataBind();

                    foreach (ListItem liSelected in this.SelectedUsersected.Items)
                    {
                        foreach (ListItem liUser in this.OfficeUsers.Items)
                        {
                            if (liSelected.Value == liUser.Value)
                            {
                                OfficeUsers.Items.Remove(liUser);
                                break;
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }