protected void Btn_Search_Click(object sender, EventArgs e) { if (role.SelectedValue == "用户编号") { if (TxtContent.Text.Trim() == "") { Response.Write("<script>alert('用户名不能为空!')</script>"); } else { string sql = "select ID 用户编号,userName 用户名,userRole 用户权限 from [Tb_User_Login] where ID='" + TxtContent.Text.Trim() + "'"; user Search = new user(); SqlDataReader myreader = Search.Login(sql); User_List.DataSource = myreader; User_List.DataBind(); } } else { if (TxtContent.Text.Trim() == "") { Response.Write("<script>alert('用户名不能为空!')</script>"); } else { string sql = "select ID 用户编号,userName 用户名,userRole 用户权限 from [Tb_User_Login] where userName='******'"; user Search = new user(); SqlDataReader myreader = Search.Login(sql); User_List.DataSource = myreader; User_List.DataBind(); } } }
public bool Update(User_List ul) { using (var db = new PingPingEntities()) { var ulNew = db.User_List.Where(o => o.UserID == ul.UserID && o.ListID == ul.ListID).FirstOrDefault(); ulNew.Type = ul.Type; return(db.SaveChanges() == 1 ? true : false); } }
public bool Add(User_List ul) { using (var db = new PingPingEntities()) { ul.Time = DateTime.Now; ul.Status = 1; db.User_List.Add(ul); return(db.SaveChanges() == 1 ? true : false); } }
private void pictureBox4_Click(object sender, EventArgs e) { Form parentForm = (this.Parent as Form); parentForm.Controls.Clear(); parentForm.Text = "تركيزي- عرض قائمة المستخدمين"; User_List UserList_Control = new User_List(cName, CID); parentForm.Controls.Add(UserList_Control); }
private void label9_Click(object sender, EventArgs e) //If click back to Main window { Form parentForm = (this.Parent as Form); parentForm.Controls.Clear(); parentForm.Text = "تركيزي- عرض قائمة المستخدمين"; User_List UserList_Control = new User_List(cName, CID); parentForm.Controls.Add(UserList_Control); }
private void button2_Click(object sender, EventArgs e) //If click cancel button { Form parentForm = (this.Parent as Form); parentForm.Controls.Clear(); parentForm.Text = "تركيزي- عرض قائمة المستخدمين"; User_List User_List_control = new User_List(cName, CID); parentForm.Controls.Add(User_List_control); }
public Boolean Release(List list, int userId) { User_List userList = new User_List(); if (listHandler.Add(list)) { userList.UserID = userId; userList.ListID = list.ListID; userList.Type = 1; return(userListHandler.Add(userList)); } return(false); }
public void TestUserListHandler() { User_List ul = new User_List(); //ul.UserID = 1; //ul.ListID = 1; //ul.Type = 1; //Assert.IsTrue(ulHandler.Add(ul)); ul = ulHandler.GetUserListById(1, 1); if (ul != null) { Console.WriteLine(ul.User); Console.WriteLine(ul.Time); Console.WriteLine(ul.Type); Console.WriteLine(ul.Status); } }
public bool Follow(int userId, int listId) { User_List ul, ul2; if (userHandler.GetUserById(userId) != null && listHandler.GetListById(listId) != null) { ul = userListHandler.GetUserListById(userId, listId); if (ul == null) { ul2 = new User_List(); ul2.ListID = listId; ul2.UserID = userId; ul2.Type = 2; return(userListHandler.Add(ul2)); } else if (ul.Type == 3) { ul.Type = 2; return(userListHandler.Update(ul)); } } return(false); }
public ActionResult Detail(int id) { if (id > 0) { List list = mapService.Search(id); if (list != null) { ViewData["RelesseUserID"] = mapService.SearchReleaseIdByListId(list.ListID); ViewData["userListType"] = -1; if (Session["userId"] != null) { int userId = int.Parse(Session["userId"].ToString()); User_List ul = mapService.SearchUserListByListId(userId, id); if (ul != null) { ViewData["userListType"] = (int)ul.Type; } } return(View(list)); } } return(Redirect("~/ZuChe/Search")); }
protected void Page_Load(object sender, EventArgs e) { LiHyperLink.SetNameToCompare(Context, "UserManagement"); IGraffitiUser currentUser = GraffitiUsers.Current; if (Request.QueryString["user"] != null) { if (!IsPostBack) { user = GraffitiUsers.GetUser(Request.QueryString["user"]); if (user == null) { throw new Exception("This user does not exist or cannot be edited."); } if (!GraffitiUsers.IsAdmin(currentUser) && user.Name != currentUser.Name) { throw new SecurityException("You do not have permission to edit this user"); } if (Request.QueryString["new"] != null && !IsPostBack) { Message.Text = "The user <strong>" + user.Name + "</strong> was created."; Message.Type = StatusType.Success; } PageText.Text = "Update " + user.ProperName + "'s profile."; AdminUserLinks.Visible = true; PasswordLink.NavigateUrl = string.Format("~/graffiti-admin/user-management/users/changepassword.aspx?user={0}", Request.QueryString["user"]); if (GraffitiUsers.CanRenameUsers && GraffitiUsers.IsAdmin(GraffitiUsers.Current)) { AdminUserLinksDelim.Visible = true; RenameLink.Visible = true; RenameLink.NavigateUrl = string.Format("javascript:Telligent_Modal.Open('RenameUser.aspx?user={0}', 400, 200, null);", Request.QueryString["user"]); } txtExistingUserName.Text = Server.HtmlDecode(user.Name); txtProperName.Text = Server.HtmlDecode(user.ProperName); txtExistingEmail.Text = user.Email; txtAvatar.Text = user.Avatar; Editor.Text = user.Bio; txtWebsite.Text = string.IsNullOrEmpty(user.WebSite) ? new Macros().FullUrl(new Urls().Home) : Server.HtmlEncode(user.WebSite); bool isAdmin = GraffitiUsers.IsUserInRole(GraffitiUsers.Current.Name, GraffitiUsers.AdminRole); role_section.Visible = isAdmin; AllRoles.Visible = isAdmin; if (!isAdmin) { Cancel_Edit.NavigateUrl = "~/graffiti-admin/"; } if (isAdmin) { RolePermissionsCollection rp = RolePermissionManager.GetRolePermissions(); RolePermissionsCollection newrp = new RolePermissionsCollection(); newrp.AddRange(rp); RolePermissions temp = newrp.Find(delegate(RolePermissions r) { return(r.RoleName == GraffitiUsers.EveryoneRole); }); if (temp != null) { newrp.Remove(temp); } newrp.Sort(delegate(RolePermissions rp1, RolePermissions rp2) { return(Comparer <string> .Default.Compare(rp1.RoleName, rp2.RoleName)); }); Roles.DataSource = newrp; Roles.DataBind(); foreach (string role in user.Roles) { if (role == GraffitiUsers.AdminRole) { chkAdmin.Checked = true; if (GraffitiUsers.Current.Name == user.Name) { chkAdmin.Enabled = false; } } } } } new_user_container.Visible = false; User_List.Visible = false; user_edit_form.Visible = true; } else { if (!GraffitiUsers.IsUserInRole(currentUser.Name, GraffitiUsers.AdminRole)) { Response.Redirect("?user="******"*"); User_List.DataSource = users; User_List.DataBind(); // filter out everyone if they are not a content publisher for licensing List <IGraffitiUser> filteredUsers = new List <IGraffitiUser>(); filteredUsers.AddRange(users); bool isEveryonePublisher = RolePermissionManager.IsEveryoneAContentPublisher(); if (!isEveryonePublisher) { foreach (IGraffitiUser user in users) { if (user.Roles != null && user.Roles[0] == GraffitiUsers.EveryoneRole) { filteredUsers.Remove(user); } } } } }
private void button1_Click(object sender, EventArgs e) //If click add button { Form1 f1 = new Form1(); bool empty = false; if (string.IsNullOrWhiteSpace(this.textBox1.Text)) //check the fields before adding { MessageBox.Show("أدخل الاسم الأول من فضلك", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); empty = true; } if (string.IsNullOrWhiteSpace(this.textBox2.Text)) { MessageBox.Show("أدخل الاسم الأخير من فضلك", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); empty = true; } if (empty == false && string.IsNullOrWhiteSpace(this.textBox3.Text)) { MessageBox.Show("أدخل العمر من فضلك", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); empty = true; } if (empty == false && string.IsNullOrWhiteSpace(this.textBox4.Text)) { MessageBox.Show("أدخل رقم الهاتف من فضلك", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); empty = true; } if (empty == false && string.IsNullOrWhiteSpace(this.textBox5.Text)) { MessageBox.Show("أدخل العنوان من فضلك", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); empty = true; } if (empty == false) { int selectedStatus = 0, selectedOthersDisorders = 0; selectedStatus = Convert.ToInt32(comboBox1.SelectedIndex); selectedOthersDisorders = Convert.ToInt32(comboBox2.SelectedIndex); try { Char sex; if (radioButton1.Checked == true) { sex = 'M'; } else { sex = 'F'; } String FirstName = textBox1.Text.ToString().Replace(" ", string.Empty); String LastName = textBox2.Text.ToString().Replace(" ", string.Empty); string sql = "SELECT * FROM users where FName='" + FirstName + "' and LName ='" + LastName + "' and CID= '" + CID + "';"; f1.objMySqlCon = new MySqlConnection(f1.cs); MySqlCommand cmdSel = new MySqlCommand(sql, f1.objMySqlCon); f1.objMySqlCon.Open(); f1.rdr = cmdSel.ExecuteReader(); if (!(f1.rdr.Read())) //if all data are ok, start to insert the user to the DB { string insertSQL = "INSERT INTO users(FName, LName, Age, PhoneNo, Address, Status, OtherDisorders, CID, sex) VALUES ('" + FirstName + "', '" + LastName + "', '" + textBox3.Text.ToString() + "', '" + textBox4.Text.ToString() + "', '" + textBox5.Text.ToString() + "','" + selectedStatus + "','" + selectedOthersDisorders + "','" + CID + "','" + sex + "')"; f1.objMySqlCon = new MySqlConnection(f1.cs); MySqlCommand cmd = new MySqlCommand(insertSQL, f1.objMySqlCon); f1.objMySqlCon.Open(); int executed = 0; executed = cmd.ExecuteNonQuery(); f1.objMySqlCon.Close(); if (executed == 1) { MessageBox.Show("تمت عملية الإضافة", "تم!"); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; Form parentForm = (this.Parent as Form); parentForm.Controls.Clear(); parentForm.Text = "تركيزي"; User_List User_List_control = new User_List(cName, CID); parentForm.Controls.Add(User_List_control); } else { MessageBox.Show("حدث خطأ أثناء عملية الإضافة، حاول مرة أخرى", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); } } else { MessageBox.Show("هذا المستخدم موجود مسبقاً!", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); } } catch (MySqlException ex) { Console.WriteLine("Error: {0}", ex.ToString()); } } }