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 Materials_Status : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ToString()); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { string xadmin = Session["admin"].ToString(); if (xadmin == "True") { if (Session["User"] == "6" || Session["User"] == "21" || Session["User"] == "45" || Session["User"] == "49" || Session["User"] == "1") { GrvAll.DataBind(); GRVSR.Visible = false; } else { //Response.Redirect("Default.aspx"); } } } catch (Exception ex) { Response.Write(ex.ToString()); ; throw; } } } protected void GrvAll_SelectedIndexChanged(object sender, EventArgs e) { txtDesc.Visible = true; btnapprov.Visible = true; btnrefuse.Visible = true; Session["lastt"] = GrvAll.SelectedRow.Cells[0].Text.ToString(); } protected void btnapproved_Click(object sender, EventArgs e) { lblerror.Text = ""; txtDesc.Visible = false; btnapprov.Visible = false; btnrefuse.Visible = false; SDSSR.SelectCommand = "SELECT Users.NameD, Materials.Code, Materials.Name, Materials.Type, Materials.URL, Materials.Detail, Material_Trust.Refused, Material_Trust.UpdateDate FROM Users INNER JOIN Materials ON Users.Code = Materials.UserInfo INNER JOIN Material_Trust ON Materials.Code = Material_Trust.Material WHERE (Material_Trust.Staus = @status33) AND (Material_Trust.UserTrust = @userTrust33)"; SDSSR.SelectParameters.Add("userTrust33", Session["User"].ToString()); SDSSR.SelectParameters.Add("status33", "1"); GRVSR.DataBind(); GrvAll.Visible = false; GRVSR.Visible = true; lblNamed.Text = ""; lblNamed.Text = "المواد المعتمدة من قبلك"; } protected void btnrefused_Click(object sender, EventArgs e) { lblerror.Text = ""; txtDesc.Visible = false; btnapprov.Visible = false; btnrefuse.Visible = false; SDSSR.SelectCommand = "SELECT Users.NameD, Materials.Code, Materials.Name, Materials.Type, Materials.URL, Materials.Detail, Material_Trust.Refused, Material_Trust.UpdateDate FROM Users INNER JOIN Materials ON Users.Code = Materials.UserInfo INNER JOIN Material_Trust ON Materials.Code = Material_Trust.Material WHERE (Material_Trust.Staus = @status20) AND (Material_Trust.UserTrust = @userTrust20)"; SDSSR.SelectParameters.Add("userTrust20", Session["User"].ToString()); SDSSR.SelectParameters.Add("status20", "2"); GRVSR.DataBind(); GrvAll.Visible = false; GRVSR.Visible = true; lblNamed.Text = ""; lblNamed.Text = "المواد المرفوضة من قبلك"; } protected void btnWating_Click(object sender, EventArgs e) { lblerror.Text = ""; txtDesc.Visible = false; btnapprov.Visible = false; btnrefuse.Visible = false; GrvAll.DataBind(); GrvAll.Visible = true; GRVSR.Visible = false; lblNamed.Text = ""; lblNamed.Text = "المواد في انتظار الاعتماد من قبلك"; } protected void btnapprov_Click(object sender, EventArgs e) { try { if (txtDesc.Text == "") { return; } SqlCommand cmdInsert = new SqlCommand("update Material_Trust set Staus=1 , Refused=N'" + txtDesc.Text + "' ,UpdateDate=N'" + DateTime.Now.ToString("d") + "' " + " where Material =" + Session["lastt"].ToString() + " and UserTrust=" + Session["User"].ToString() + " ", con); if (con.State == ConnectionState.Closed) con.Open(); cmdInsert.ExecuteNonQuery(); con.Close(); lblerror.Text = "تم اعتماد المادة"; } catch (Exception ex) { lblerror.Text = "حدث الخطا التالي قم بنسخه وارساله الى المهندس المسئول :" + ex.ToString(); } } protected void btnrefuse_Click(object sender, EventArgs e) { try { if (txtDesc.Text == "") { return; } SqlCommand cmdInsert = new SqlCommand("update Material_Trust set Staus=2 , Refused=N'" + txtDesc.Text + "' ,UpdateDate=N'" + DateTime.Now.ToString("d") + "' " + " where Material =" + Session["lastt"].ToString() + " and UserTrust=" + Session["User"].ToString() + " ", con); if (con.State == ConnectionState.Closed) con.Open(); cmdInsert.ExecuteNonQuery(); con.Close(); lblerror.Text = "تم رفض المادة"; } catch (Exception ex) { lblerror.Text = "حدث الخطا التالي قم بنسخه وارساله الى المهندس المسئول :" + ex.ToString(); } } }