Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            netEntities1 db     = new netEntities1();
            var          result = from a in db.sp select a;

            if (comboBox1.SelectedIndex != 0)
            {
                string gysid = Convert.ToString(comboBox1.SelectedValue);
                result = from a in result where a.spgysid == gysid select a;
            }
            if (comboBox2.SelectedIndex != 0)
            {
                string zlid = Convert.ToString(comboBox2.SelectedValue);
                result = from a in result where a.spzlid == zlid select a;
            }
            if (textBox1.Text != "")
            {
                result = from a in result where a.spid.Contains(textBox1.Text) select a;
            }
            if (textBox2.Text != "")
            {
                result = from a in result where a.spname.Contains(textBox2.Text) select a;
            }
            dataGridView1.DataSource = (from a in result select new { a.spid, a.spname, a.spgysid, a.spzlid }).ToList();
        }
Example #2
0
        private void 新增_Load(object sender, EventArgs e)
        {
            netEntities1 db  = new netEntities1();
            var          gys = from p in db.gys select p;

            comboBox1.ValueMember   = "gysid";
            comboBox1.DisplayMember = "gysname";
            comboBox1.DataSource    = gys.ToList();
            var zl = from p in db.zl select p;

            comboBox2.ValueMember   = "zlid";
            comboBox2.DisplayMember = "zlname";
            comboBox2.DataSource    = zl.ToList();
            if (mode == "update")
            {
                string a1   = spid.ToString();
                sp     new1 = db.sp.SingleOrDefault(a => a.spid == a1);
                label5.Text             = new1.spid;
                textBox1.Text           = new1.spname;
                comboBox1.SelectedValue = new1.spgysid;
                comboBox2.SelectedValue = new1.spzlid;
            }
            if (spid == "0")
            {
                label5.Text  = "自动生成";
                button1.Text = "新增";
            }
            else
            {
                button1.Text = "修改";
            }
        }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            netEntities1 db   = new netEntities1();
            新增           new1 = new 新增();

            new1.value("0", "insert");
            new1.ShowDialog();
            var sj = from a in db.sp select new { a.spid, a.spname, a.spgysid, a.spzlid };

            dataGridView1.DataSource = sj.ToList();
        }
Example #4
0
        private void 商品列表_Load(object sender, EventArgs e)
        {
            netEntities1 db  = new netEntities1();
            var          gys = from p in db.gys select p;

            comboBox1.ValueMember   = "gysid";
            comboBox1.DisplayMember = "gysname";
            comboBox1.DataSource    = gys.ToList();
            var zl = from p in db.zl select p;

            comboBox2.ValueMember   = "zlid";
            comboBox2.DisplayMember = "zlname";
            comboBox2.DataSource    = zl.ToList();
        }
Example #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                string id = dataGridView1.SelectedRows[0].Cells["spid"].Value.ToString();

                新增 new1 = new 新增();
                new1.value(id, "update");
                new1.ShowDialog();
                netEntities1 db = new netEntities1();
                var          sj = from a in db.sp select new { a.spid, a.spname, a.spgysid, a.spzlid };
                dataGridView1.DataSource = sj.ToList();
            }
            else
            {
                MessageBox.Show("请先选择行!");
            }
        }
Example #6
0
        private void button4_Click(object sender, EventArgs e)
        {
            netEntities1 db = new netEntities1();

            if (dataGridView1.SelectedRows.Count > 0)
            {
                string id   = dataGridView1.SelectedRows[0].Cells["spid"].Value.ToString();
                sp     new1 = db.sp.SingleOrDefault(a => a.spid == id);
                db.sp.Remove(new1);
                db.SaveChanges();
                MessageBox.Show("删除成功!");
                var sj = from a in db.sp select new { a.spid, a.spname, a.spgysid, a.spzlid };
                dataGridView1.DataSource = sj.ToList();
            }
            else
            {
                MessageBox.Show("请先选择行!");
            }
        }
Example #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            netEntities1 db = new netEntities1();

            if (textBox1.Text != "" && textBox2.Text != "")
            {
                var ym = textBox1.Text.Trim();
                var ma = textBox2.Text.Trim();
                var dl = (from p in db.list where p.yonghuming == ym && p.mima == ma select p).Count();
                if (dl != 0)
                {
                    商品列表 new1 = new 商品列表();
                    new1.ShowDialog();
                }
                else
                {
                    MessageBox.Show("密码错误");
                }
            }
            else
            {
                MessageBox.Show("请输入用户名和密码");
            }
        }
Example #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            netEntities1 db   = new netEntities1();
            sp           new1 = new sp();

            new1.spzlid  = Convert.ToString(comboBox2.SelectedValue);
            new1.spgysid = Convert.ToString(comboBox1.SelectedValue);
            if (mode == "insert")
            {
                string a = DateTime.Now.Ticks.ToString();
                a         = a.Substring(a.Length - 7);
                new1.spid = a;
                db.sp.Add(new1);
            }
            if (mode == "update")
            {
                new1.spid = label5.Text;
                db.Entry <sp>(new1).State = EntityState.Modified;
            }

            new1.spname = textBox1.Text;
            db.SaveChanges();
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }