protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { var dep = (from d in ctx.TBL_Departman select new { d.Departman, d.ID, adet = ctx.TBL_Gorev.Where(x => x.dlt == 0 && x.Departman_ID == d.ID).Count() }).ToList(); Departman_ID.DataSource = dep.Where(x => x.adet > 0).ToList(); //ctx.TBL_Departman.Where(x => x.dlt == 0).OrderBy(x => x.Departman).ToList(); Departman_ID.DataTextField = "Departman"; Departman_ID.DataValueField = "ID"; Departman_ID.DataBind(); int departman = Convert.ToInt32(Departman_ID.SelectedValue); Gorev_ID.DataSource = ctx.TBL_Gorev.Where(x => x.dlt == 0 && x.Departman_ID == departman).OrderBy(x => x.Gorev).ToList(); Gorev_ID.DataTextField = "Gorev"; Gorev_ID.DataValueField = "ID"; Gorev_ID.DataBind(); Firma_ID.DataSource = ctx.TBL_Firmalar.Where(x => x.dlt == 0).OrderBy(x => x.Firma).ToList(); Firma_ID.DataTextField = "Firma"; Firma_ID.DataValueField = "ID"; Firma_ID.DataBind(); TagTipi.Items.Add(new ListItem("İnsan", "fa-male")); TagTipi.Items.Add(new ListItem("Araç", "fa-car")); TagTipi.Items.Add(new ListItem("Cihaz", "fa-cube")); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int id = Convert.ToInt32(Request.QueryString["id"]); var personel = ctx.TBL_Personel.SingleOrDefault(x => x.ID == id && x.dlt == 0); Ad.Text = personel.Ad; Soyad.Text = personel.Soyad; TagNo.Text = personel.TagNo; Aciklama.Text = personel.Aciklama; Departman_ID.SelectedValue = personel.Departman_ID.ToString(); Gorev_ID.SelectedValue = personel.Gorev_ID.ToString(); Firma_ID.SelectedValue = personel.Firma_ID.ToString(); KamraIp.Text = personel.KamraIp; Departman_ID.DataSource = ctx.TBL_Departman.Where(x => x.dlt == 0).OrderBy(x => x.Departman).ToList(); Departman_ID.DataTextField = "Departman"; Departman_ID.DataValueField = "ID"; Departman_ID.DataBind(); Departman_ID.SelectedValue = personel.Departman_ID.ToString(); Gorev_ID.DataSource = ctx.TBL_Gorev.Where(x => x.dlt == 0 && x.Departman_ID == personel.Departman_ID).OrderBy(x => x.Gorev).ToList(); Gorev_ID.DataTextField = "Gorev"; Gorev_ID.DataValueField = "ID"; Gorev_ID.DataBind(); Gorev_ID.SelectedValue = personel.Gorev_ID.ToString(); Firma_ID.DataSource = ctx.TBL_Firmalar.Where(x => x.dlt == 0).OrderBy(x => x.Firma).ToList(); Firma_ID.DataTextField = "Firma"; Firma_ID.DataValueField = "ID"; Firma_ID.DataBind(); Firma_ID.SelectedValue = personel.Firma_ID.ToString(); TagTipi.Items.Add(new ListItem("İnsan", "fa-male")); TagTipi.Items.Add(new ListItem("Araç", "fa-car")); TagTipi.Items.Add(new ListItem("Cihaz", "fa-cube")); TagTipi.SelectedValue = personel.TagTipi; } }