public PartTransfer(TransferDetail td) : this() { var dc = DCFactory.GetDataContext<PartDataContext>(); this.TransferQuantity = td.Quantity; this.PartNo = td.PartCode; try { this.PartName = td.PartInfo.PartType == VDMS.II.Entity.PartType.Part ? dc.Parts.SingleOrDefault(p => p.PartCode == td.PartCode && p.DatabaseCode == td.TransferHeader.Dealer.DatabaseCode).VietnamName : td.PartInfo.Accessory.VietnamName; } catch { } }
public static long TransferParts(string key, long shId, long fromWhId, long toWhId, DateTime tDate, string status, string comment) { long res = 0; Warehouse wh = WarehouseDAO.GetWarehouse(fromWhId); Warehouse wh2 = WarehouseDAO.GetWarehouse(toWhId); if ((wh == null) || (wh2 == null)) return res; List<PartTransfer> parts = STParts(key); parts.RemoveAll(p => p.CurrentQuantity <= 0); if (parts.Count > 0) { var dc = DCFactory.GetDataContext<PartDataContext>(); TransferHeader th = GetTransferHeader(shId); if (th == null) { th = new TransferHeader() { CreatedBy = UserHelper.Username, CreatedDate = DateTime.Now, VoucherNumber = PartTransferDAO.GenVoucherNumber(wh.Code, wh2.Code, DateTime.Now), }; } else { dc.TransferDetails.DeleteAllOnSubmit(th.TransferDetails); } th.FromWarehouseId = fromWhId; th.ToWarehouseId = toWhId; th.DealerCode = wh.DealerCode; th.Status = status; th.TransferDate = tDate.Date; th.TransferComment = comment; bool ok = true; foreach (PartTransfer p in parts.Where(p => p.State == ST_ItemState.New)) { if (string.IsNullOrEmpty(p.PartType)) { p.PartType = AccessoryDAO.IsAccessoryExist(p.PartNo, UserHelper.DealerCode) ? PartType.Accessory : PartType.Part; } PartInfo pi = PartInfoDAO.GetPartInfo(p.PartNo, wh.DealerCode, p.PartType); if ((pi != null) && (p.CurrentQuantity >= p.TransferQuantity)) { TransferDetail td = new TransferDetail() { Quantity = p.TransferQuantity, PartCode = p.PartNo, PartInfoId = pi.PartInfoId, PartComment = p.Remark }; if (th.TransferHeaderId > 0) { td.TransferHeaderId = th.TransferHeaderId; dc.TransferDetails.InsertOnSubmit(td); } else td.TransferHeader = th; if (status == ST_Status.Transfered) { ok = ok && PartDAO.StockAdjust(p.PartNo, p.PartType, wh.DealerCode, fromWhId, toWhId, tDate, InventoryAction.StockTransfer, 0, p.TransferQuantity * -1, p.Remark, null, null); p.State = ST_ItemState.Moved; } } else { p.State = ST_ItemState.Wrong; ok = false; } } if (th.TransferHeaderId == 0) dc.TransferHeaders.InsertOnSubmit(th); if (ok && th.TransferDetails.Count > 0) { dc.SubmitChanges(); res = th.TransferHeaderId; } } return res; }
private void detach_TransferDetails(TransferDetail entity) { this.SendPropertyChanging(); entity.TransferHeader = null; }
private void detach_TransferDetails(TransferDetail entity) { this.SendPropertyChanging(); entity.PartInfo = null; }
private void attach_TransferDetails(TransferDetail entity) { this.SendPropertyChanging("TransferDetails"); entity.TransferHeader = this; }