public void Page_Load(object sender, EventArgs e) { if (!Main.Instance.AdminApi.IsPluginAuthorized) { HttpContext.Current.Response.Write("<h1>未授权访问</h1>"); HttpContext.Current.Response.End(); return; } _configInfo = Utils.GetConfigInfo(); if (!string.IsNullOrEmpty(Request.QueryString["delete"]) && !string.IsNullOrEmpty(Request.QueryString["groupId"])) { GroupDao.Delete(Convert.ToInt32(Request.QueryString["groupId"])); LtlMessage.Text = Utils.GetMessageHtml("删除成功!", true); } if (IsPostBack) { return; } var groupInfoList = GroupDao.GetGroupInfoList(); groupInfoList.Insert(0, Utils.GetDefaultGroupInfo(_configInfo)); RptContents.DataSource = groupInfoList; RptContents.ItemDataBound += RptContents_ItemDataBound; RptContents.DataBind(); BtnAdd.OnClientClick = $"location.href = '{PageWritingSettings.GetAddUrl()}';return false;"; }
private void Delete(int _id) { try { GroupDao.Delete(_ConfigItem, _id); } catch (Exception ex) { throw ex; } }
public void DeleteTest() { using (var db = DbHelper.GetDataContext()) { var data = db.Group.FirstOrDefault(); if (data != null) { target.Delete(data.GroupId); var group = target.GetGroup(data.GroupId); Assert.AreEqual(1, group.Deleted); } } }
private void B_DELETE_Click(object sender, EventArgs e) { if (MessageBox.Show("Really delete?", "Confirm delete", MessageBoxButtons.YesNo) == DialogResult.Yes) { ModelGroup model = new ModelGroup(); model.id = this.id; model.group_code = txtCode.Text; model.group_description = txtDesc.Text; model.group_order = Convert.ToInt32(txtOrder.Text); Boolean result = groupDao.Delete(model); if (result) { MessageBox.Show("ลบข้อมูลเรียบร้อยแล้ว"); refresh(); } } }
public ActionResult Delete(Guid id) { try { // TODO: Add delete logic here GroupDao bdDao = new GroupDao(); GroupUserDao prDao = new GroupUserDao(); if (prDao.FindByGroupID(id).Count > 0) { SetAlert("Đang sử dụng không được phép xóa", Common.CommonConstant.ALERT_DANGER); return(RedirectToAction("Index")); } bdDao.Delete(id); // SetAlert("Xóa thành công", "success"); return(RedirectToAction("Index")); } catch { // SetAlert("Không xóa được", "danger"); return(View()); } }
//public Dictionary<string, RightLevel> GetAllRightLevels(int accountId, int agentId) //{ // var selfRights = GetAllRightNames(accountId).ToDictionary(r => r, r => RightLevel.SelfRight); // if (agentId > 0) // { // var agentRights = GetAllRightNames(agentId).ToDictionary(r => r, r => RightLevel.SelfRight); // //把代理权限也赋予本人,但标明为代理权限。 // foreach (var kv in agentRights) // { // if (selfRights.ContainsKey(kv.Key)) // { // selfRights[kv.Key] = kv.Value; // } // else // { // selfRights.Add(kv.Key, kv.Value); // } // } // } // return selfRights; //} //public Dictionary<string, RightLevel> CheckRights(IEnumerable<string> rightNames, int accountId, int agentId) //{ // var result = rightNames.ToDictionary(r => r, r => RightLevel.NoRight); // var allRights = GetAllRightLevels(accountId, agentId); // foreach (var name in rightNames) // { // if (allRights.ContainsKey(name)) // { // result[name] = allRights[name]; // } // } // return result; //} public void Delete(int groupId) { Dao.Delete(groupId); }