private void cmdSave_Click(object sender, EventArgs e) { try { using (var Scope = new TransactionScope()) { using (var dbScope = new SharedDbConnectionScope()) { var exists = Exists(); if (exists) { int record = new Update(BangGium.Schema).Set(BangGium.Columns.Price).EqualTo(nmrPrice.Value) .Where(BangGium.Columns.TestTypeId).IsEqualTo(_TestTypeId).And( BangGium.Columns.TestDataId) .IsEqualTo(-1).Execute(); if (record <= 0) { BangGium bangGium = new BangGium(); bangGium.TestTypeId = _TestTypeId; bangGium.TestDataId = "-1"; bangGium.Price = Utility.DecimaltoDbnull(nmrPrice.Value, 0); bangGium.IsNew = true; bangGium.Save(); } } else { decimal price = Utility.DecimaltoDbnull(grdDataControl.CurrentRow.Cells["Price"].Value, 0); nmrPrice.Value = price; int record = new Update(BangGium.Schema).Set(BangGium.Columns.Price).EqualTo(nmrPrice.Value) .Where(BangGium.Columns.TestTypeId).IsEqualTo(_TestTypeId) .And(BangGium.Columns.TestDataId).IsEqualTo(_TestDataId).Execute(); if (record <= 0) { BangGium bangGium = new BangGium(); bangGium.TestTypeId = _TestTypeId; bangGium.TestDataId = _TestDataId; bangGium.Price = Utility.DecimaltoDbnull(nmrPrice.Value, 0); bangGium.IsNew = true; bangGium.Save(); } } } Scope.Complete(); //Utility.ShowMsg("Lưu thông tin thành công."); } } catch (Exception) { Utility.ShowMsg("Có lỗi trong quá trình lưu thông tin"); throw; } }
public void Insert(int TestTypeId,string TestDataId,decimal Price) { BangGium item = new BangGium(); item.TestTypeId = TestTypeId; item.TestDataId = TestDataId; item.Price = Price; item.Save(UserName); }
public void Update(int Id,int TestTypeId,string TestDataId,decimal Price) { BangGium item = new BangGium(); item.MarkOld(); item.IsLoaded = true; item.Id = Id; item.TestTypeId = TestTypeId; item.TestDataId = TestDataId; item.Price = Price; item.Save(UserName); }