protected void Page_Load(object sender, EventArgs e) { CheckAccount(); if (!string.IsNullOrEmpty(Request["PlanId"])) { _planId = Int32.Parse(Request["PlanId"]); } if (!string.IsNullOrEmpty(Request["ret"])) { _retUrl = HttpUtility.HtmlDecode(Request["ret"]); } else { Grafik.Visible = false; } App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()); _planIds = db.GetPlans(User.Identity.Name, _planId); _prim = db.GetPrim(User.Identity.Name, _planId); List <TheN> n = new List <TheN>(); foreach (DataRow dr in _prim.Rows) { n.Add(new TheN() { N = (int)dr["N"] }); } _data = db.GetReglamentWorks(_planId); _data.Columns.Add("bDone", Type.GetType("System.Boolean")); _data.Columns.Add("AddPrim", Type.GetType("System.String")); _data.Columns.Add("PrimExists", Type.GetType("System.String")); foreach (DataRow dr in _data.Rows) { if (dr["Done"] is DBNull || bool.Parse(dr["Done"].ToString()) == false) { dr["bDone"] = false; } else { dr["bDone"] = true; } // if (dr["WorksId"] is DBNull) // было закомментировано dr["AddPrim"] = "~/AddPrim.aspx?PlanId=" + _planIds + "&ReglamentId=" + dr["ReglamentId"].ToString(); // else // было закомментировано 2 стр. // dr["AddPrim"] = "~/AddPrim.aspx?WorksId=" + dr["WorksId"].ToString() + "&PlanId=" + _planId + "&ReglamentId=" + dr["ReglamentId"].ToString(); dr["PrimExists"] = ""; if (!(dr["N"] is DBNull)) { int N = (int)dr["N"]; if (n.Find(delegate(TheN i) { return(i.N == N); }) != null) { dr["PrimExists"] = "!!!"; } } } _liftsId = db.GetLiftsId(_planId); _liftId = db.GetLiftId(_planId); /* string liftsId = string.Empty;// начало коммента * foreach (string s in _liftsId) * if (string.IsNullOrEmpty(liftsId)) * liftsId = s; * else * liftsId += "," + s; */ // конец коммента List <Data> data = new List <Data>(); using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { conn.Open(); SqlCommand cmd = new SqlCommand("select TpId from [Plan] where Id=@id", conn); cmd.Parameters.AddWithValue("id", _planId); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { _TpId = dr["TpId"].ToString(); } dr.Close(); } // using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { conn.Open(); TpId.Text = _TpId; LiftsId.Text = _liftId; SqlCommand cmd = new SqlCommand("select r.[Title] from [Reglament] r " + "where r.[TpId]=@rId", conn); /* if (TpId.Text == "ТР") * cmd.Parameters.AddWithValue("rId", "ТР"); * else if (TpId.Text == "ТР1") * cmd.Parameters.AddWithValue("rId", "ТР1"); * else if (TpId.Text == "ТР2") * cmd.Parameters.AddWithValue("rId", "ТР2"); * else if (TpId.Text == "ТР3") * cmd.Parameters.AddWithValue("rId", "ТР3"); * else */ cmd.Parameters.AddWithValue("rId", TpId.Text); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { data.Add(new Data() { Title = dr["Title"].ToString() }); Out.DataSource = data; Out.DataBind(); } dr.Close(); } // if (!IsPostBack) { ReglamentWorks.DataSource = _data; ReglamentWorks.DataBind(); Msg.Text = string.Empty; List <Base.ZPrim> list = db.GetNotDonePrim(_liftId, Request.Url.ToString()); ZPrim.DataSource = list; ZPrim.DataBind(); using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { conn.Open(); SqlCommand cmd = new SqlCommand("select Done from [Plan] where Id=@id", conn); cmd.Parameters.AddWithValue("id", _planId); object o = cmd.ExecuteScalar(); if (o != null) { Done.Checked = bool.Parse(o.ToString()); } cmd = new SqlCommand("select Prn from [Plan] where Id=@id", conn); cmd.Parameters.AddWithValue("id", _planId); string op = cmd.ExecuteScalar().ToString(); if (op == "") { Prin.Checked = false; } else { Prin.Checked = bool.Parse(op.ToString()); } } if (User.Identity.Name == "Volodin" || User.Identity.Name == "Puzin" || User.Identity.Name == "manager") { Prin.Visible = true; btnPrin.Visible = true; } if (TpId.Text == "ВР" && User.Identity.Name == "manager") { AddBP.Visible = true; TextBox1.Visible = true; L1.Visible = true; } } }