public NewIzmerenie() { InitializeComponent(); dbContex = new MyLinqDataContext(); updateComBoxTYPE(); updateComBoxCATEGORY(); }
public NewCategory(int flag) { InitializeComponent(); talk = flag; dbContex = new MyLinqDataContext(); if (flag == 0) { var reader = (from type in dbContex.type select type.Название).ToArray(); foreach (var curr in reader) { comboBox.Items.Add(curr); comboBox1.Items.Add(curr); } /*SqlConnection sqlConnection1 = new SqlConnection(Data.value); * SqlCommand cmd = new SqlCommand(); * * cmd.CommandText = "SELECT Название FROM type"; * cmd.CommandType = CommandType.Text; * cmd.Connection = sqlConnection1; * * sqlConnection1.Open(); * * using (var reader = cmd.ExecuteReader()) * while (reader.Read()) * { * comboBox.Items.Add((string)reader.GetValue(0)); * comboBox1.Items.Add((string)reader.GetValue(0)); * } * sqlConnection1.Close();*/ } if (flag == 1) { /*SqlConnection sqlConnection1 = new SqlConnection(Data.value); * SqlCommand cmd = new SqlCommand(); * * cmd.CommandText = "SELECT Название FROM Category"; * cmd.CommandType = CommandType.Text; * cmd.Connection = sqlConnection1; * * sqlConnection1.Open(); * * using (var reader = cmd.ExecuteReader()) * while (reader.Read()) * { * comboBox.Items.Add((string)reader.GetValue(0)); * comboBox1.Items.Add((string)reader.GetValue(0)); * } * sqlConnection1.Close();*/ var reader = (from Category in dbContex.Category select Category.Название).ToArray(); foreach (var curr in reader) { comboBox.Items.Add(curr); comboBox1.Items.Add(curr); } } }
public static IQueryable getTinTuc() { MyLinqDataContext data = new MyLinqDataContext(); var tintuc = from c in data.zNews select new { c.NewsID, c.CatID, c.Title, c.Content }; return(tintuc); }
public static IQueryable getTintuc() { MyLinqDataContext data = new MyLinqDataContext(); var tintuc = from c in data.zNews select new { c.Title, c.Content, c.image, c.DateCreated, c.NewsID, c.Description }; return(tintuc); }
protected void Page_Load(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString["id"]); MyLinqDataContext data = new MyLinqDataContext(); var content = from c in data.zNews where c.NewsID == id select new { c.Title, c.Content, c.DateCreated }; Repeater1.DataSource = content; Repeater1.DataBind(); ListLink.DataSource = TinTuc.getTintuc(); ListLink.DataBind(); }