private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if (!IsPostBack) { //this.TxtStartTime.Attributes.Add("onfocus", "javascript:calendar()"); //this.TxtEndTime.Attributes.Add("onfocus", "javascript:calendar()"); string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString; SqlConnection Sqlconn = new SqlConnection(connstr); DataSet ds = new DataSet(); string Personstr = "select E_ID,E_Name from Tb_employee order by E_ID desc"; string Kindstr = "select L_ID,L_Kind from Tb_leaver_kind order by L_ID desc"; string Agreerstr = "select D_ID,D_Chief from Tb_department order by D_ID desc"; //读取考勤字段 SqlDataAdapter SqlPerson = new SqlDataAdapter(Personstr, Sqlconn); SqlDataAdapter SqlKind = new SqlDataAdapter(Kindstr, Sqlconn); SqlDataAdapter SqlAgreer = new SqlDataAdapter(Agreerstr, Sqlconn); Sqlconn.Open(); SqlPerson.Fill(ds, "Person"); Person.DataSource = ds.Tables["Person"].DefaultView; Person.DataTextField = "E_Name"; Person.DataValueField = "E_ID"; Person.DataBind(); SqlKind.Fill(ds, "Kind"); Kind.DataSource = ds.Tables["Kind"].DefaultView; Kind.DataTextField = "L_Kind"; Kind.DataValueField = "L_ID"; Kind.DataBind(); SqlAgreer.Fill(ds, "Agreer"); Agreer.DataSource = ds.Tables["Agreer"].DefaultView; Agreer.DataTextField = "D_Chief"; Agreer.DataValueField = "D_ID"; Agreer.DataBind(); Sqlconn.Close(); } }
protected void Page_Load(object sender, EventArgs e) { stage = Convert.ToInt32(Request.QueryString["stage"]); switch (stage) { case 0: Name.Visible = true; Base.Visible = true; Difficult.Visible = true; Kind.Visible = true; MText.Visible = true; Product.Visible = false; gramm.Visible = false; price.Visible = false; Button2.Visible = false; File1.Visible = false; break; case 1: Name.Visible = false; Base.Visible = false; Difficult.Visible = false; Kind.Visible = false; MText.Visible = false; Product.Visible = true; gramm.Visible = true; price.Visible = false; Button2.Visible = true; File1.Visible = false; break; case 2: Name.Visible = false; Base.Visible = false; Difficult.Visible = false; Kind.Visible = false; MText.Visible = false; Product.Visible = false; gramm.Visible = false; price.Visible = true; Button2.Visible = false; File1.Visible = false; break; case 3: Name.Visible = false; Base.Visible = false; Difficult.Visible = false; Kind.Visible = false; MText.Visible = false; Product.Visible = false; gramm.Visible = false; price.Visible = false; Button2.Visible = false; File1.Visible = true; break; default: break; } List <Portion> pAdd = new List <Portion>(); List <Porca> pAddd = new List <Porca>(); pAdd = (List <Portion>)Session["ListPortion"]; if (pAdd != null) { foreach (Portion asd in pAdd) { Porca assf = new Porca(); assf.Product = Repository.Products.Where(p => p.ProductId == asd.ProductId).FirstOrDefault().Name; assf.PrMass = asd.PrMass; pAddd.Add(assf); } } decimal priceAdd = 0; if (Session["DishAdd"] != null) { priceAdd = ((Dish)Session["DishAdd"]).Price > 0 ? (decimal)((Dish)Session["DishAdd"]).Price : priceAdd; } if (stage == 2 && price.Text == "") { if (pAdd != null) { foreach (Portion asd in pAdd) { priceAdd += Repository.Products.Where(p => p.ProductId == asd.ProductId).FirstOrDefault().Price *asd.PrMass / 100; } } price.Text = Convert.ToString(Math.Round(priceAdd, 2)); } Dish dAdd = (Dish)Session["DishAdd"]; if (dAdd != null) { DishLabel.Text = "Наименование рецепта: " + dAdd.Name + "<br/>" + "Основа рецепта: " + dAdd.Base + "<br/>" + "Сложность: " + dAdd.Difficult + "<br/>" + "Тип рецепта: " + Repository.Kinds.Where(p => p.KindId == dAdd.KindId).FirstOrDefault().Name + "<br/>" + "Стоимость: " + Math.Round(priceAdd, 2) + "<br/>" + "Описание: " + (String)Session["OpisDish"]; } List <String> ListKind = new List <string>(); foreach (Kind sd in Repository.Kinds) { ListKind.Add(sd.Name); } Kind.DataSource = ListKind.OrderBy(p => p); Kind.DataBind(); List <String> ListProduct = new List <string>(); foreach (Product sd in Repository.Products) { ListProduct.Add(sd.Name); } /*Product.DataSource = ListProduct.OrderBy(p => p); * Product.DataBind();*/ Repeater1.DataSource = pAddd; Repeater1.DataBind(); }