public void SaveMaterial2Supplier(Sender sender, SaveMaterial2SupplierArgs args) { try { using (ObjectProxy op = new ObjectProxy(true)) { Material2Supplier obj = new Material2Supplier(); obj.MaterialID = args.Material2Supplier.MaterialID; obj.SupplierID = args.Material2Supplier.SupplierID; if (op.LoadMaterial2SupplierByMaterialID_SupplierID(obj) == 0) { op.InsertMaterial2Supplier(args.Material2Supplier); } else { op.UpdateMaterial2SupplierByMaterialID_SupplierID(args.Material2Supplier); } op.CommitTransaction(); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
public void SaveMaterial(Sender sender, SaveMaterialArgs args) { try { using (ObjectProxy op = new ObjectProxy(true)) { Material obj = new Material(); obj.MaterialID = args.Material.MaterialID; if (op.LoadMaterialByMaterialID(obj) == 0) { args.Material.Created = DateTime.Now; args.Material.CreatedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); args.Material.Modified = DateTime.Now; args.Material.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); op.InsertMaterial(args.Material); } else { args.Material.Modified = DateTime.Now; args.Material.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); op.UpdateMaterialByMaterialID(args.Material); } if (args.Material2Suppliers != null) { foreach (Material2Supplier item in args.Material2Suppliers) { Material2Supplier subObj = new Material2Supplier(); subObj.MaterialID = item.MaterialID; subObj.SupplierID = item.SupplierID; if (op.LoadMaterial2SupplierByMaterialID_SupplierID(subObj) == 0) { op.InsertMaterial2Supplier(item); } else { op.UpdateMaterial2SupplierByMaterialID_SupplierID(item); } } } op.CommitTransaction(); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
public Material2Supplier GetMaterial2Supplier(Sender sender, Guid MaterialID, Guid SupplierID) { try { using (ObjectProxy op = new ObjectProxy()) { Material2Supplier obj = new Material2Supplier(); obj.SupplierID = SupplierID; obj.MaterialID = MaterialID; if (op.LoadMaterial2SupplierByMaterialID_SupplierID(obj) == 0) { return(null); } return(obj); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }