using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Data.SqlClient; public partial class stu_Open : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ToString()); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //if (xadmin == "") // Response.Redirect("/mt/Default.aspx"); lbltitle.Text = Request.QueryString["name"].ToString(); DataBind(); } } protected void grdDocs_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //------------------ Have Document or Not --------------------- String Act_Edit; Act_Edit = (String)e.Row.Cells[9].Text; if (Act_Edit == "0") e.Row.Cells[9].Text = ""; else e.Row.Cells[9].Text = ""; CheckBox chk = (CheckBox)e.Row.FindControl("CHBTaha"); if (Act_Edit == "0") chk.Checked = false; else chk.Checked = true; } } protected void chkboxSelectAll_CheckedChanged(object sender, EventArgs e) { CheckBox ChkBoxHeader = (CheckBox)grdtbl0.HeaderRow.FindControl("chkboxSelectAll"); foreach (GridViewRow row in grdtbl0.Rows) { CheckBox ChkBoxRows = (CheckBox)row.FindControl("CHBTaha"); if (ChkBoxHeader.Checked == true) { ChkBoxRows.Checked = true; } else { ChkBoxRows.Checked = false; } } } protected void btnUse_Click(object sender, EventArgs e) { string xadmin = Session["admin"].ToString(); if (xadmin == "") Response.Redirect("/mt/Default.aspx"); if (xadmin == "True") { int c = 0; foreach (GridViewRow row in grdtbl0.Rows) { CheckBox chk = (CheckBox)row.FindControl("CHBTaha"); String Rcode = row.Cells[0].Text; String RS = ""; if (chk != null && chk.Checked == true) { RS = "1"; } else RS = "0"; SqlCommand cmdinsert = new SqlCommand("Update Pro_StuShow set Stu_Status =" + RS + " where Code=" + Rcode + "", con); if (con.State == ConnectionState.Closed) con.Open(); // Response.Write(cmdinsert.CommandText.ToString()); cmdinsert.ExecuteNonQuery(); con.Close(); c = c + 1; } if (c > 0) { lblResult.Text = "تم حفظ التغيرات بنجاح لعدد " + c.ToString() + " طلب"; lblRes.Text = "تم حفظ التغيرات بنجاح لعدد " + c.ToString() + " طلب"; } DataBind(); } } protected void btnDelete_Click(object sender, EventArgs e) { string xadmin = Session["admin"].ToString(); if (xadmin == "") Response.Redirect("/mt/Default.aspx"); if (xadmin == "True") { int c = 0; foreach (GridViewRow row in grdtbl0.Rows) { CheckBox chk = (CheckBox)row.FindControl("CHBTaha"); String Rcode = row.Cells[0].Text; String RS = ""; if (chk != null && chk.Checked == true) { SqlCommand cmdinsert = new SqlCommand("Delete Pro_StuShow where Code=" + Rcode + "", con); if (con.State == ConnectionState.Closed) con.Open(); // Response.Write(cmdinsert.CommandText.ToString()); cmdinsert.ExecuteNonQuery(); con.Close(); c = c + 1; } else RS = "0"; } if (c > 0) { lblResult.Text = "تم الحذف بنجاح لعدد " + c.ToString() + " طلب"; lblRes.Text = "تم الحذف بنجاح لعدد " + c.ToString() + " طلب"; } DataBind(); } } protected void btnall_Click(object sender, EventArgs e) { Response.Redirect("Stu_Print_All.aspx?Pro=" + Request.QueryString["pro"].ToString() + "&name=" + Request.QueryString["name"].ToString() + ""); } protected void btnactive_Click(object sender, EventArgs e) { Response.Redirect("Stu_Print_Active.aspx?Pro=" + Request.QueryString["pro"].ToString() + "&name=" + Request.QueryString["name"].ToString() + ""); } protected void btnnot_Click(object sender, EventArgs e) { Response.Redirect("Stu_Print_Not.aspx?Pro=" + Request.QueryString["pro"].ToString() + "&name=" + Request.QueryString["name"].ToString() + ""); } }