示例#1
0
        void ThemDoDung()
        {
            tblDoDung dd = new tblDoDung();

            if (dgvDoDung.Rows.Count <= 1)
            {
                dd.IDDoDung = 1;
            }
            else
            {
                dd.IDDoDung = db.tblDoDungs.Select(n => n.IDDoDung).Max() + 1;
            }
            dd.TenDoDung = txtTenDoDung.Text;
            if (txtSoLuong.Text == "")
            {
                dd.SoLuong = null;
            }
            else
            {
                dd.SoLuong = int.Parse(txtSoLuong.Text);
            }
            if (txtDonGia.Text == "")
            {
                dd.DonGia = null;
            }
            else
            {
                dd.DonGia = int.Parse(txtDonGia.Text);
            }
            db.tblDoDungs.InsertOnSubmit(dd);
            db.SubmitChanges();
        }
示例#2
0
        void XoaDoDung()
        {
            tblDoDung dd = db.tblDoDungs.Where(n => n.IDDoDung == int.Parse(txtIDDoDung.Text)).First();

            db.tblDoDungs.DeleteOnSubmit(dd);
            db.SubmitChanges();
        }
示例#3
0
        void SuaDoDung()
        {
            tblDoDung dd = db.tblDoDungs.Where(n => n.IDDoDung == int.Parse(txtIDDoDung.Text)).First();

            dd.TenDoDung = txtTenDoDung.Text;
            if (txtSoLuong.Text == "")
            {
                dd.SoLuong = null;
            }
            else
            {
                dd.SoLuong = int.Parse(txtSoLuong.Text);
            }
            if (txtDonGia.Text == "")
            {
                dd.DonGia = null;
            }
            else
            {
                dd.DonGia = int.Parse(txtDonGia.Text);
            }
            db.SubmitChanges();
        }
示例#4
0
 partial void DeletetblDoDung(tblDoDung instance);
示例#5
0
 partial void UpdatetblDoDung(tblDoDung instance);
示例#6
0
 partial void InserttblDoDung(tblDoDung instance);