public void BindGrid() { ClPermissionPack cl = new ClPermissionPack(); cl.PackID = Convert.ToInt32(DDPackID.SelectedValue); DataSet ds = PermissionPackClass.GetList(cl); DataView dv = new DataView(ds.Tables[0]); if (ViewState["UserPermission"] == null) { ViewState["UserPermission"] = "PermissionPAckID Desc"; } dv.Sort = ViewState["UserPermission"].ToString(); GridView1.DataSource = dv; GridView1.DataBind(); if (GridView1.Rows.Count > 0) { BtnUpdate.Visible = true; } else { BtnUpdate.Visible = false; } }
protected void BtnUpdate_Click(object sender, EventArgs e) { string sql = ""; int tt = 0; ClPermissionPack cl = new ClPermissionPack(); for (int i = 0; i < GridView1.Rows.Count - 1; i++) { GridViewRow gr = GridView1.Rows[i]; Label lblup = (Label)gr.FindControl("LblUpID"); CheckBox chview = (CheckBox)gr.FindControl("chview"); CheckBox chInsert = (CheckBox)gr.FindControl("chInsert"); CheckBox chUpdate = (CheckBox)gr.FindControl("chUpdate"); CheckBox chDel = (CheckBox)gr.FindControl("chDel"); cl.PermissionPAckID = Convert.ToInt32(lblup.Text); cl.Canview = chview.Checked; cl.CanUpdate = chUpdate.Checked; cl.CanInsert = chInsert.Checked; cl.CanDel = chDel.Checked; tt += PermissionPackClass.Update(cl); // sql += "update Tbl_UserPermission set CanDel=" + CSharp.PublicFunction.BTS(chDel.Checked) + ",CanInsert=" + CSharp.PublicFunction.BTS(chInsert.Checked) + ",CanUpdate=" + CSharp.PublicFunction.BTS(chUpdate.Checked) + ",CanView=" + CSharp.PublicFunction.BTS(chUpdate.Checked) + " where UserPermissinID=" + lblup.Text + ""; } if (tt != 0) { BindGrid(); } else { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('خطا در ویرایش');", true); } }
protected void BtnInsert_Click(Object sender, System.EventArgs e) { ClPermissionPack cl = Data; int t = 0; if (CSharp.PublicFunction.ModeInsert(cl.PermissionPAckID.ToString())) { t = PermissionPackClass.insert(cl); } else { t = PermissionPackClass.Update(cl); } if (t == 0) { LblMsg.ForeColor = System.Drawing.Color.Red; LblMsg.Text = "خطا در ثبت"; } else { LblMsg.ForeColor = System.Drawing.Color.Green; LblMsg.Text = "ثبت انجام شد."; BindPermission(); BindGrid(); } }
private void BindPermission() { ClPermissionPack cl = new ClPermissionPack(); cl.PackID = Convert.ToInt32(DDPackID.SelectedValue); DDPermissionID.DataSource = PermissionPackClass.GetPAckNotPermisson(cl); DDPermissionID.DataTextField = "PermissianName"; DDPermissionID.DataValueField = "PermissionID"; DDPermissionID.DataBind(); }
public void DeleteItem(object sender, System.EventArgs e) { String UserPermissinID = ((HtmlAnchor)sender).HRef.ToString(); int i = PermissionPackClass.Delete(UserPermissinID); if (i == 0) { LblMsg.Text = " error "; ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('خطا در حذف');", true); } else { BindGrid(); BindPermission(); } LightBox.Value = "0"; }