Esempio n. 1
0
        private void ShowData(string strSql)
        {
            string         strConn = ConfigurationSettings.AppSettings["strConn"];
            SqlConnection  SqlConn = new SqlConnection(strConn);
            SqlDataAdapter SqlCmd  = new SqlDataAdapter(strSql, SqlConn);
            DataSet        SqlDS   = new DataSet();

            SqlCmd.Fill(SqlDS, "UserInfo");
            RowNum = DataGridUser.CurrentPageIndex * DataGridUser.PageSize + 1;

            string SortExpression = DataGridUser.Attributes["SortExpression"];
            string SortDirection  = DataGridUser.Attributes["SortDirection"];

            SqlDS.Tables["UserInfo"].DefaultView.Sort = SortExpression + " " + SortDirection;

            DataGridUser.DataSource = SqlDS.Tables["UserInfo"].DefaultView;
            DataGridUser.DataBind();
            for (int i = 0; i < DataGridUser.Items.Count; i++)
            {
            }
            LabelRecord.Text      = Convert.ToString(SqlDS.Tables["UserInfo"].Rows.Count);
            LabelCountPage.Text   = Convert.ToString(DataGridUser.PageCount);
            LabelCurrentPage.Text = Convert.ToString(DataGridUser.CurrentPageIndex + 1);
            SqlConn.Dispose();
        }
Esempio n. 2
0
        /// <summary>
        /// Обработчик события нажатия на кнопку добавить
        /// которая позволяет добавить пользователя
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddClickUser(object sender, RoutedEventArgs e)
        {
            saveUser.IsEnabled   = true;
            editUser.IsEnabled   = false;
            UndoUser.IsEnabled   = true;
            serchUser.IsEnabled  = false;
            addUser.IsEnabled    = false;
            removeUser.IsEnabled = false;
            User employee = new User();

            try
            {
                employee.ID       = dataEntities.User.Count() + 1;
                employee.Login    = "******";
                employee.Password = "******";
                employee.Email    = "не задано";
                employee.Location = "";
                employee.TotalID  = 3;
                dataEntities.User.Add(employee);
                dataEntities.SaveChanges();
                DataGridUser.BeginEdit();
                TableUsers(sender, e);
            }
            catch
            {
                MessageBox.Show("Сначала сохраните изменения");
            }
        }
Esempio n. 3
0
 private void ShowUsers()
 {
     try
     {
         int        serverId = (int)ViewState[WebConfig.ParamServerId];
         GameServer server   = TheAdminServer.GameServerManager.GetGameServer(serverId);
         if (server == null)
         {
             LabelOpMsg.Text = string.Format(StringDef.MsgCannotBeNone, StringDef.GameServer);
             return;
         }
         if (!server.IsConnected)
         {
             LabelOpMsg.Text = StringDef.NoConnectionAlert;
             return;
         }
         string    cmdText = "SELECT current_user;";
         SqlResult result  = WebUtil.QueryGameServerDb(CurrentUser.Id, server, new SqlCommand(cmdText, null));
         if (result != null && result.Success)
         {
             DataGridUser.DataSource = CreateUserDataSource(result);
             DataGridUser.DataBind();
         }
         else
         {
             LabelOpMsg.Text = StringDef.OperationFail;
             return;
         }
     }
     catch (Exception)
     {
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Обработчик события нажатия на кнопку редактировать
        /// позволяющаая редактировать данные о позволяет
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditClickUser(object sender, RoutedEventArgs e)
        {
            saveUser.IsEnabled   = true;
            editUser.IsEnabled   = false;
            UndoUser.IsEnabled   = true;
            serchUser.IsEnabled  = false;
            addUser.IsEnabled    = false;
            removeUser.IsEnabled = false;

            DataGridUser.IsReadOnly = false;
            DataGridUser.BeginEdit();
        }
Esempio n. 5
0
        private void ShowData(string strSql)
        {
            string         strConn = ConfigurationSettings.AppSettings["strConn"];
            SqlConnection  SqlConn = new SqlConnection(strConn);
            SqlDataAdapter SqlCmd  = new SqlDataAdapter(strSql, SqlConn);
            DataSet        SqlDS   = new DataSet();

            SqlCmd.Fill(SqlDS, "UserInfo");
            RowNum = DataGridUser.CurrentPageIndex * DataGridUser.PageSize + 1;
            LinNum = 0;

            string SortExpression = DataGridUser.Attributes["SortExpression"];
            string SortDirection  = DataGridUser.Attributes["SortDirection"];

            SqlDS.Tables["UserInfo"].DefaultView.Sort = SortExpression + " " + SortDirection;

            DataGridUser.DataSource = SqlDS.Tables["UserInfo"].DefaultView;
            DataGridUser.DataBind();
            for (int i = 0; i < DataGridUser.Items.Count; i++)
            {
                LinkButton LBEditUser = (LinkButton)DataGridUser.Items[i].FindControl("LinkButEditUser");
                LinkButton LBDel      = (LinkButton)DataGridUser.Items[i].FindControl("LinkButDel");

                if ((myLoginID.Trim().ToUpper() == "ADMIN") || (myLoginID.Trim().ToUpper() == DataGridUser.Items[i].Cells[10].Text.Trim().ToUpper()))
                {
                    LBEditUser.Attributes.Add("onclick", "javascript:jscomNewOpenByFixSize('EditOneUser.aspx?UserID=" + DataGridUser.Items[i].Cells[0].Text + "','EditOneUser',550,445); return false;");
                    if ((DataGridUser.Items[i].Cells[3].Text.Trim().ToUpper() == "ADMIN") || (DataGridUser.Items[i].Cells[3].Text.Trim().ToUpper() == "GUEST"))
                    {
                        LBDel.Attributes.Add("onclick", "javascript:alert('系统内置帐号,不能删除!');return false;");
                    }
                    else
                    {
                        LBDel.Attributes.Add("onclick", "javascript:{if(confirm('确定要删除选择帐户吗?')==false) return false;}");
                    }
                }
                else
                {
                    LBEditUser.Attributes.Add("onclick", "javascript:alert('对不起,您没有此操作权限!');return false;");
                    LBDel.Attributes.Add("onclick", "javascript:alert('对不起,您没有此操作权限!');return false;");
                }
            }
            LabelRecord.Text      = Convert.ToString(SqlDS.Tables["UserInfo"].Rows.Count);
            LabelCountPage.Text   = Convert.ToString(DataGridUser.PageCount);
            LabelCurrentPage.Text = Convert.ToString(DataGridUser.CurrentPageIndex + 1);
            SqlConn.Dispose();
        }
Esempio n. 6
0
        private void ShowData(string strSql)
        {
            string         strConn = ConfigurationSettings.AppSettings["strConn"];
            SqlConnection  SqlConn = new SqlConnection(strConn);
            SqlDataAdapter SqlCmd  = new SqlDataAdapter(strSql, SqlConn);
            DataSet        SqlDS   = new DataSet();

            SqlCmd.Fill(SqlDS, "UserInfo");
            RowNum = DataGridUser.CurrentPageIndex * DataGridUser.PageSize + 1;

            string SortExpression = DataGridUser.Attributes["SortExpression"];
            string SortDirection  = DataGridUser.Attributes["SortDirection"];

            SqlDS.Tables["UserInfo"].DefaultView.Sort = SortExpression + " " + SortDirection;

            DataGridUser.DataSource = SqlDS.Tables["UserInfo"].DefaultView;
            DataGridUser.DataBind();
            for (int i = 0; i < DataGridUser.Items.Count; i++)
            {
                LinkButton LBUser     = (LinkButton)DataGridUser.Items[i].FindControl("LinkButUser");
                LinkButton LBTestType = (LinkButton)DataGridUser.Items[i].FindControl("LinkButTestType");
                LinkButton LBMenu     = (LinkButton)DataGridUser.Items[i].FindControl("LinkButMenu");
//				if (bJoySoftware==false)
//				{
//					LBUser.Attributes.Add("onclick", "javascript:alert('对不起,未注册用户不能设置评卷帐号!');return false;");
//					LBTestType.Attributes.Add("onclick", "javascript:alert('对不起,未注册用户不能设置评卷题型!');return false;");
//					LBMenu.Attributes.Add("onclick", "javascript:alert('对不起,未注册用户不能设置角色菜单!');return false;");
//				}
//				else
//				{
                LBUser.Attributes.Add("onclick", "var str=window.showModalDialog('SelectUser.aspx?UserID=" + DataGridUser.Items[i].Cells[0].Text.Trim() + "','','dialogHeight:415px;dialogWidth:490px;edge:Raised;center:Yes;help:Yes;resizable:No;scroll:No;status:No;');return false;");
                LBTestType.Attributes.Add("onclick", "var str=window.showModalDialog('SelectTestType.aspx?UserID=" + DataGridUser.Items[i].Cells[0].Text.Trim() + "','','dialogHeight:373px;dialogWidth:490px;edge:Raised;center:Yes;help:Yes;resizable:No;scroll:No;status:No;');return false;");
                LBMenu.Attributes.Add("onclick", "var str=window.showModalDialog('SelectMenu.aspx?UserID=" + DataGridUser.Items[i].Cells[0].Text.Trim() + "','','dialogHeight:373px;dialogWidth:490px;edge:Raised;center:Yes;help:Yes;resizable:No;scroll:No;status:No;');return false;");
//				}
            }
            LabelRecord.Text      = Convert.ToString(SqlDS.Tables["UserInfo"].Rows.Count);
            LabelCountPage.Text   = Convert.ToString(DataGridUser.PageCount);
            LabelCurrentPage.Text = Convert.ToString(DataGridUser.CurrentPageIndex + 1);
            SqlConn.Dispose();
        }
Esempio n. 7
0
 protected void DataGridUser_PageIndexChanged(Object sender, DataGridPageChangedEventArgs e)
 {
     DataGridUser.CurrentPageIndex = e.NewPageIndex;
     DataGridUser.DataSource       = new DataView(ViewState["User"] as DataTable);
     DataGridUser.DataBind();
 }
Esempio n. 8
0
 private void CreateDataGridUser()
 {
     DataGridUser.DataSource = CreateDataSource(AdminServer.TheInstance.SecurityManager.GetAllUsers());
     DataGridUser.DataBind();
 }