Exemple #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            QLDT_LINQDataContext db = new QLDT_LINQDataContext();

            try
            {
                DeTai insDetai = new DeTai();
                insDetai.MaDeTai  = txtMa.Text.Trim();
                insDetai.TenDeTai = txtTen.Text.Trim();
                if (rdHThanh.Checked)
                {
                    insDetai.TinhTrang = true;
                }
                else
                {
                    insDetai.TinhTrang = false;
                }
                insDetai.NgayNhanDeTai = dpkNgayNhan.Value;
                insDetai.MaCapDeTai    = db.CapDeTais.Where(p => p.TenCapDeTai.Equals(cbbCapDeTai.SelectedItem.ToString())).Select(p => p.MaCapDeTai).SingleOrDefault().ToString();
                insDetai.ChuNhiem      = cbbChuNhiem.SelectedItem.ToString();
                db.DeTais.InsertOnSubmit(insDetai);
            }
            finally
            {
                db.SubmitChanges();
                MessageBox.Show("Success!!");
            }
        }
 partial void DeleteDeTai(DeTai instance);
 partial void UpdateDeTai(DeTai instance);
 partial void InsertDeTai(DeTai instance);
 private void detach_DeTais(DeTai entity)
 {
     this.SendPropertyChanging();
     entity.CapDeTai = null;
 }
 private void attach_DeTais(DeTai entity)
 {
     this.SendPropertyChanging();
     entity.CapDeTai = this;
 }