public int insertMayTinh(tblMaytinh mt) { System.Data.Common.DbTransaction myTran = dt.Connection.BeginTransaction(); try { dt.Transaction = myTran; if (checkIfExist(mt.msMay) != null)// thay { return(0); } else { dt.tblMaytinhs.InsertOnSubmit(mt); dt.SubmitChanges(); dt.Transaction.Commit(); return(1); } } catch (Exception ex) { dt.Transaction.Rollback(); throw new Exception("Loi không sửa được " + ex.Message); } }
public int LuuTru() { System.Data.Common.DbTransaction myTran = dt.Connection.BeginTransaction(); try { dt.Transaction = myTran; dt.SubmitChanges(); dt.Transaction.Commit(); return(1); } catch (Exception ex) { dt.Transaction.Rollback(); throw new Exception("Lỗi cập nhật " + ex.Message); } }