public static bool UpdateDCL(DutyClear dcl) { try { if (dcl.Id != Guid.Empty && dcl.PO != null && dcl.PO.Id != Guid.Empty && dcl.PODetail != null && dcl.PODetail.Id != Guid.Empty) { PurchaseDataManager.UpdateDCL(POMap.reMapDCLData(dcl)); ResetCache(); } return(true); } catch (Exception ex) { ExceptionHandler.Error("Something went wrong. Details: " + ex.Message, ex); } return(false); /*string PONumber = keyvalues["ponumber"]; * string DCLNumber = keyvalues["dclnumber"]; * string DCLId = keyvalues["dclid"]; * * PurchaseOrder PO = GetPO(PONumber); * DutyClear Dcl = GetDCL(DCLNumber); * if (PO != null && Dcl != null) * { * Dcl.DCLDate = keyvalues.ContainsKey("DCLDate") ? DateTime.Parse(keyvalues["DCLDate"]) : DateTime.Now; * Dcl.PODetail = new Reference() { Id = new Guid(keyvalues["Customer"]), Name = PO.PONumber }; * Dcl.Store = StoreManager.GetStoreRef(keyvalues["Store"]); * Dcl.Quantity = keyvalues.ContainsKey("Quantity") ? decimal.Parse(keyvalues["Quantity"]) : 0; * Dcl.Remarks = keyvalues.ContainsKey("Remarks") ? keyvalues["Remarks"] : ""; * Dcl.ModifiedOn = DateTime.Now; * Dcl.ModifiedBy = UserManager.GetUserRef(Common.CurrentUser.Id.ToString()); * foreach (PODetail pod in PO.PODetailsList) * { * foreach (DutyClear dcl in pod.DutyClearsList) * if (dcl.Id.ToString() == DCLId || dcl.DCLNumber == DCLNumber) * { * pod.DutyClearsList.Remove(dcl); * break; * } * if (pod.Id == Dcl.PODetail.Id) * { * pod.DutyClearsList.Add(Dcl); * break; * } * } * * PurchaseDataManager.CalculatePO(PO); * if (PO.isValid) * PurchaseDataManager.UpdateDCL(POMap.reMapDCLData(Dcl)); * else * { * ExceptionHandler.Error("Something went wrong! PO Quantity is not valid."); * return null; * } * ResetCache(); * * * return Dcl; * } * return null;*/ }
public static bool CreateDutyClear(DutyClear dcl) { try { if (dcl.PO != null && dcl.PO.Id != Guid.Empty && dcl.PODetail != null && dcl.PODetail.Id != Guid.Empty) { Guid dclId = PurchaseDataManager.CreateDCL(POMap.reMapDCLData(dcl)); dcl.Id = dclId; PurchaseOrder po = GetPO(dcl.PO.Name); StoreDataManager.CreateStockMovement(StoreMap.reMapStockMovementData(po, dcl)); //TODO ResetCache(); } return(true); } catch (Exception ex) { ExceptionHandler.Error("Something went wrong. Details: " + ex.Message, ex); } return(false); /*string poNumber = keyvalues.ContainsKey("PO") ? keyvalues["PO"] : ""; * string cusId = keyvalues.ContainsKey("Customer") ? keyvalues["Customer"] : ""; * * if (poNumber != "" && cusId != "") * { * PurchaseOrder PO = GetPO(poNumber); * PODetail POD = null; * foreach (PODetail pod in PO.PODetailsList) * { * if (pod.Customer.Id == new Guid(cusId)) * POD = pod; * } * if (POD != null) * { * if (POD.DutyClearsList == null) * POD.DutyClearsList = new List<DutyClear>(); * DutyClear Dcl = NewDCL(); * Dcl.PO = new Reference() { Id = PO.Id, Name = PO.PONumber }; * Dcl.PODetail = new Reference() { Id = POD.Id, Name = PO.PONumber }; * if (keyvalues.ContainsKey("Store")) * Dcl.Store = StoreManager.GetStoreRef(keyvalues["Store"].ToString()); * Dcl.Quantity = keyvalues.ContainsKey("Quantity") ? decimal.Parse(keyvalues["Quantity"]) : 0; * Dcl.Remarks = keyvalues.ContainsKey("Remarks") ? keyvalues["Remarks"] : ""; * POD.DutyClearsList.Add(Dcl); * * PurchaseDataManager.CalculatePO(PO); * if (PO.isValid) * { * PurchaseDataManager.CreateDCL(POMap.reMapDCLData(Dcl)); * //todo stock movement * } * else * { * ExceptionHandler.Error("Something went wrong! PO Quantity is not valid."); * PurchaseDataManager.ResetCache(); * return null; * } * PurchaseDataManager.ResetCache(); * return Dcl; * } * } * return null;*/ }