https://www.youtube.com/watch?v=g1EU9gnZKOg&list=PLZX6sKChTg8GQxnABqxYGX2zLs4Hfa4Ca&index=33
===============================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace pt
{
public partial class Form1 : Form
{
weberpEntities db = new weberpEntities();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = "";
var allitem = db.bas_item.ToList();
foreach (var item in allitem)
{
label1.Text += item.mname + "\r\n";
}
}
private void button2_Click(object sender, EventArgs e)
{
label1.Text = "";
var item = db.bas_item.Select(p => p.mname).ToList();
foreach (var fn in item)
{
label1.Text += fn + "\r\n";
}
}
private void button3_Click(object sender, EventArgs e)
{
label1.Text = "";
var item = db.bas_item.Where(p=>p.price_sale==500).Select(p => p.mname+":費用"+p.price_sale).ToList();
foreach (var fn in item)
{
label1.Text += fn + "\r\n";
}
}
private void button4_Click(object sender, EventArgs e)
{
label1.Text = "";
var YesOrNo= db.bas_item.All(p => p.price_sale == 500);
label1.Text = YesOrNo.ToString();
}
private void button5_Click(object sender, EventArgs e)
{
label1.Text = "";
var YesOrNo = db.bas_item.Any(p => p.price_sale == 500);
label1.Text = YesOrNo.ToString();
}
private void button6_Click(object sender, EventArgs e)
{
label1.Text = "";
var groups = db.bas_item.GroupBy(p => p.mname).ToList();
foreach (var g in groups)
{
label1.Text += g.Key + ":" + g.Count() + "\r\n";
}
}
private void button7_Click(object sender, EventArgs e)
{
label1.Text = "";
var count = db.bas_item.Count(p => p.placeid == 1);
label1.Text = count.ToString();
}
}
}
沒有留言:
張貼留言