protected void DD1_SelectedIndexChanged(object sender, EventArgs e) { int id = Convert.ToInt32(DD1.SelectedIndex) + 1; try { b1.kapat(); b1.ac(); SqlCommand bag1 = new SqlCommand("Select id,ilce from Ilceler where sehir='" + id + "' ", b1.baglanti); SqlDataAdapter DataAdapter1 = new SqlDataAdapter(bag1); DataSet DataSet1 = new DataSet(); DataAdapter1.Fill(DataSet1); DD2.DataSource = DataSet1; DD2.DataTextField = "ilce"; DD2.DataValueField = "id"; DD2.DataBind(); DataSet1.Clear(); b1.kapat(); } catch (Exception) { } }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request["zId"])) { // if (!string.IsNullOrEmpty(Request["zId"]) && !IsPostBack) Response.Redirect("~/About.aspx"); } _wz = Int32.Parse(Request["zId"]); if (User.Identity.Name != "ODS14") { Treg.Visible = false; Tzak.Visible = false; } if (!IsPostBack) { App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()); DataTable data = db.GetEvent(_wz); if (data.Rows.Count < 1) { Response.Redirect("~/About.aspx"); } Id.Text = _wz.ToString(); Sourse.Text = data.Rows[0]["Sourse"].ToString(); Text1.Text = data.Rows[0]["Sourse"].ToString(); IO.Text = data.Rows[0]["IO"].ToString(); DataId.Text = data.Rows[0]["DataId"].ToString(); dateReg = ((DateTime)data.Rows[0]["DataId"]); if (!string.IsNullOrEmpty(data.Rows[0]["DataId"].ToString())) { yyy = ((DateTime)data.Rows[0]["DataId"]).Year.ToString(); ddd = ((DateTime)data.Rows[0]["DataId"]).Day.ToString(); momo = ((DateTime)data.Rows[0]["DataId"]).Month.ToString(); hhh = ((DateTime)data.Rows[0]["DataId"]).Hour.ToString(); mmm = ((DateTime)data.Rows[0]["DataId"]).Minute.ToString(); } RegistrId.Text = data.Rows[0]["RegistrId"].ToString(); LiftId.Text = data.Rows[0]["LiftId"].ToString(); TextBox4.Text = data.Rows[0]["LiftId"].ToString(); TypeId.Text = data.Rows[0]["TypeId"].ToString(); EventId.Text = data.Rows[0]["EventId"].ToString(); Text.Text = data.Rows[0]["EventId"].ToString(); ToApp.Text = data.Rows[0]["ToApp"].ToString(); Text2.Text = data.Rows[0]["ToApp"].ToString(); DateToApp.Text = data.Rows[0]["DateToApp"].ToString(); if (!string.IsNullOrEmpty(data.Rows[0]["DateToApp"].ToString())) { yyy1 = ((DateTime)data.Rows[0]["DateToApp"]).Year.ToString(); ddd1 = ((DateTime)data.Rows[0]["DateToApp"]).Day.ToString(); momo1 = ((DateTime)data.Rows[0]["DateToApp"]).Month.ToString(); hhh1 = ((DateTime)data.Rows[0]["DateToApp"]).Hour.ToString(); mmm1 = ((DateTime)data.Rows[0]["DateToApp"]).Minute.ToString(); } Who.Text = data.Rows[0]["Who"].ToString(); Comment.Text = data.Rows[0]["Comment"].ToString(); Text5.Text = data.Rows[0]["Prim"].ToString(); Prim.Text = data.Rows[0]["Prim"].ToString(); DateWho.Text = data.Rows[0]["DateWho"].ToString(); // TextBox3.Text = data.Rows[0]["DateWho"].ToString(); // if (string.IsNullOrEmpty(TextBox3.Text)) // TextBox3.Text = Convert.ToString(DateTime.Now); string d = string.Empty; string d2 = string.Empty, t2 = string.Empty; TimeSpan pr = DateTime.Now - ((DateTime)data.Rows[0]["DataId"]); if (!(data.Rows[0]["DateWho"] is DBNull)) { d2 = ((DateTime)data.Rows[0]["DateWho"]).Date.ToString(); t2 = ((DateTime)data.Rows[0]["DateWho"]).TimeOfDay.ToString(); pr = ((DateTime)data.Rows[0]["DateWho"]) - ((DateTime)data.Rows[0]["DataId"]); } if (!(data.Rows[0]["DateToApp"] is DBNull)) { d = ((DateTime)data.Rows[0]["DateToApp"]).ToString(); } string prostoy = ((int)pr.TotalDays).ToString() + " " + pr.Hours.ToString() + ":" + pr.Minutes.ToString(); Timing.Text = prostoy; { yyy2 = DateTime.Now.Year.ToString(); ddd2 = DateTime.Now.Day.ToString(); momo2 = DateTime.Now.Month.ToString(); hhh2 = DateTime.Now.Hour.ToString(); mmm2 = DateTime.Now.Minute.ToString(); } } //Год/месяц/день List <string> yy = new List <string>() { yyy, "2016", "2017", "2018", "2019", "2020" }; if (!IsPostBack) { YY.DataSource = yy; YY.DataBind(); YY.SelectedIndex = 0; } List <string> yy1 = new List <string>() { yyy1, "2016", "2017", "2018", "2019", "2020" }; if (!IsPostBack) { YY1.DataSource = yy1; YY1.DataBind(); YY1.SelectedIndex = 0; } List <string> yy2 = new List <string>() { yyy2, "2016", "2017", "2018", "2019", "2020" }; if (!IsPostBack) { YY2.DataSource = yy2; YY2.DataBind(); YY2.SelectedIndex = 0; } List <string> mo = new List <string>() { momo, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }; if (!IsPostBack) { MO.DataSource = mo; MO.DataBind(); MO.SelectedIndex = 0; } List <string> mo1 = new List <string>() { momo1, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }; if (!IsPostBack) { MO1.DataSource = mo1; MO1.DataBind(); MO1.SelectedIndex = 0; } List <string> mo2 = new List <string>() { momo2, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }; if (!IsPostBack) { MO2.DataSource = mo2; MO2.DataBind(); MO2.SelectedIndex = 0; } List <string> dd = new List <string>() { ddd, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }; if (!IsPostBack) { DD.DataSource = dd; DD.DataBind(); DD.SelectedIndex = 0; } List <string> dd1 = new List <string>() { ddd1, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }; if (!IsPostBack) { DD1.DataSource = dd1; DD1.DataBind(); DD1.SelectedIndex = 0; } List <string> dd2 = new List <string>() { ddd2, "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }; if (!IsPostBack) { DD2.DataSource = dd2; DD2.DataBind(); DD2.SelectedIndex = 0; } //Часы/минуты List <string> hh = new List <string>() { hhh, "0", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }; if (!IsPostBack) { HH.DataSource = hh; HH.DataBind(); HH.SelectedIndex = 0; } List <string> hh1 = new List <string>() { hhh1, "0", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }; if (!IsPostBack) { HH1.DataSource = hh1; HH1.DataBind(); HH1.SelectedIndex = 0; } List <string> hh2 = new List <string>() { hhh2, "0", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }; if (!IsPostBack) { HH2.DataSource = hh2; HH2.DataBind(); HH2.SelectedIndex = 0; } List <string> mm = new List <string>() { mmm, "05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "00" }; if (!IsPostBack) { MM.DataSource = mm; MM.DataBind(); MM.SelectedIndex = 0; } List <string> mm1 = new List <string>() { mmm1, "05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "00" }; if (!IsPostBack) { MM1.DataSource = mm1; MM1.DataBind(); MM1.SelectedIndex = 0; } List <string> mm2 = new List <string>() { mmm2, "05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "00" }; if (!IsPostBack) { MM2.DataSource = mm2; MM2.DataBind(); MM2.SelectedIndex = 0; } //Диспетчер using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { conn.Open(); SqlCommand cmd = new SqlCommand("select p.surname, p.name, p.midlename from People p " + "where p.comments=@user and p.specialty=N'диспетчер'", conn); cmd.Parameters.AddWithValue("user", User.Identity.Name); List <string> iodisp = new List <string>() { IO.Text }; SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { iodisp.Add(dr[0].ToString() + " " + dr[1].ToString() + " " + dr[2].ToString()); } dr.Close(); if (!IsPostBack) { FIO.DataSource = iodisp; FIO.DataBind(); FIO.SelectedIndex = 0; Fdr.Visible = false; TextBox5.Text = IO.Text; } } //Механик List <string> worker = new List <string>() { ToApp.Text }; if (!IsPostBack) { Workers.DataSource = worker; Workers0.DataSource = worker; Workers.DataBind(); Workers0.DataBind(); Workers.SelectedIndex = 0; Workers0.SelectedIndex = 0; Worker_TextChanged(this, EventArgs.Empty); } if (RegistrId.Text == "Эксплуатация лифтов") { Wrk.Visible = true; Wrk0.Visible = true; Text2.Visible = false; Text3.Visible = false; } else { Wrk.Visible = false; Wrk0.Visible = false; Text2.Visible = true; Text3.Visible = true; } }