Websharp 个人记录
1.根据主键获得实体
PersistenceManager pm = PersistenceManagerFactory.Instance().CreatePersistenceManager();
se_OrderMain order = pm.FindObjectByPrimaryKey(this.Tag.ToString(), typeof(se_OrderMain)) as se_OrderMain;
2.事务处理
PersistenceManager pm = PersistenceManagerFactory.Instance().CreatePersistenceManager();
Transaction trans = pm.CurrentTransaction;
trans.Begin();
try
{
putin.InnerID = Guid.NewGuid().ToString();
putin.PackID = "";
pm.PersistNewObject(putin);
updateSQL = "update ba_Product set Inventory=" + putin.TotalQuantityFact + " where InnerID='" + putin.ProdectID + "'";
pm.updatebySql(updateSQL);
trans.Commit();
SHIFT.MesShowOK("成功盘点");
}
catch (Exception ex)
{
PublicDAL.writelog("盘点数据异常[异常信息:" + ex.Message + "]");
trans.Rollback();
}
finally
{
pm.Close();
}
3. 查询
QueryParameterCollection parameters = new QueryParameterCollection();
string code=this.txtFreightMode.Text.Trim();
parameters.Add("@ParentCode", code);
Query q = pm.NewQuery(typeof(ba_FreightMode), "ParentCode=@ParentCode", parameters);
ba_FreightMode[] c3 = q.QueryObjects() as ba_FreightMode[];