private object LoadForm(long HeaderId) { ReportDocument rptDoc = ReportFactory.GetReport(); var dc = DCFactory.GetDataContext<PartDataContext>(); var sv = DCFactory.GetDataContext<ServiceDataContext>(); header = NotGoodDAO.GetNGHeader(HeaderId); if (header != null) { rptDoc.Load(HttpContext.Current.Server.MapPath(@"~/Part/Report/Crystal/NGSheet.rpt")); var data = from d in header.NGFormDetails join p in dc.Parts.Where(p => p.DatabaseCode == header.Dealer.DatabaseCode) on d.PartCode equals p.PartCode select new NGFormDetail(d) { PartName = p.VietnamName, Broken = sv.Brokens.FirstOrDefault(b => b.BrokenCode == d.BrokenCode), }; rptDoc.SetDataSource(data); string dealer = header.Dealer.DealerName; rptDoc.SetParameterValue("NGDate", header.CreatedDate); rptDoc.SetParameterValue("Voucher", string.IsNullOrEmpty(header.NotGoodNumber) ? "" : header.NotGoodNumber); rptDoc.SetParameterValue("Dealer", dealer); } return rptDoc; }
void CreateNGForm(string Status) { if (!Page.IsValid) return; UpdateOrderData(); if (!CheckPartNo(true)) return; var db = DCFactory.GetDataContext<PartDataContext>(); if (OrderId == 0) { var h = new NGFormHeader { CreatedDate = DateTime.Now, Status = Status, NGType = NGType.Special, DealerCode = UserHelper.DealerCode, ApproveLevel = 0 }; foreach (var item in NotGoodManualDAO.Parts) { if (!string.IsNullOrEmpty(item.PartCode)) { var obj = new NGFormDetail { PartCode = item.PartCode, RequestQuantity = item.Quantity, BrokenCode = item.BrokenCode, DealerComment = item.Comment, NGFormHeader = h }; } } if (Status == OrderStatus.OrderSent) { var count = db.NGFormHeaders.Count(q => q.NotGoodNumber.Contains("NG-M-" + DateTime.Now.ToString("yyyyMM"))); NotGoodNumber = h.NotGoodNumber = "NG-M-" + DateTime.Now.ToString("yyyyMM") + (count + 1).ToString(); } db.NGFormHeaders.InsertOnSubmit(h); db.SubmitChanges(); } else { foreach (var item in NotGoodManualDAO.Parts) { if (item.NGFormDetailId != 0) { var od = db.NGFormDetails.SingleOrDefault(p => p.NGFormDetailId == item.NGFormDetailId); if (string.IsNullOrEmpty(item.PartCode) || item.Quantity == 0) db.NGFormDetails.DeleteOnSubmit(od); else { od.PartCode = item.PartCode; od.RequestQuantity = item.Quantity; od.BrokenCode = item.BrokenCode; od.DealerComment = item.Comment; }; } else { db.NGFormDetails.InsertOnSubmit(new NGFormDetail { PartCode = item.PartCode, RequestQuantity = item.Quantity, BrokenCode = item.BrokenCode, DealerComment = item.Comment }); } db.SubmitChanges(); } } NotGoodManualDAO.Clear(); lblSaveOk1.Visible = true; DisableButton(); }
private void detach_NGFormHeaders(NGFormHeader entity) { this.SendPropertyChanging(); entity.ReceiveHeader = null; }
private void attach_NGFormHeaders(NGFormHeader entity) { this.SendPropertyChanging(); entity.Dealer = this; }
static NGFormDetail CreateNGItem(string PartCode, int Quantity, string Status, string Comment, NGFormHeader h) { return new NGFormDetail { DealerComment = Comment, NGFormHeader = h, PartCode = PartCode, PartStatus = Status, RequestQuantity = Quantity }; }
/// <summary> /// Save receive and create NG form if neccesary /// </summary> /// <param name="rh">The list of receive header. Tip-Top can send multi-receive at one</param> /// <param name="rd">The list of receive detail, contains the list of part of all receive</param> /// <param name="WarehouseId">The warehouse of receive</param> public static void SaveReceive(List<ReceiveHeader> rh, List<ReceiveDetail> rd, long WarehouseId) { var db = DCFactory.GetDataContext<PartDataContext>(); // already recevied then return if (db.ReceiveHeaders.Count(p => rh.Select(q => q.IssueNumber).Contains(p.IssueNumber)) > 0) return; // create NG form rh.ForEach(p => { if (rd.Count(q => q.IssueNumber == p.IssueNumber && q.ShippingQuantity != q.GoodQuantity) > 0) { //var count = db.NGFormHeaders.Count(q => q.NotGoodNumber.Contains("NG-" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString())); var h = new NGFormHeader { CreatedDate = DateTime.Now, Status = NGStatus.Sent, DealerCode = UserHelper.DealerCode, //ReceiveHeaderId = p.ReceiveHeaderId, ReceiveHeader = p, ApproveLevel = 0, NGType = NGType.Normal, NotGoodNumber = "NG-" + p.IssueNumber }; var list = new List<NGFormDetail>(); foreach (var item in rd.Where(q => q.IssueNumber == p.IssueNumber && q.GoodQuantity != q.ShippingQuantity)) { if (item.BrokenQuantity != 0) list.Add(CreateNGItem(item.PartCode, item.BrokenQuantity, PartNGType.Broken, item.DealerComment, h)); if (item.WrongQuantity != 0) list.Add(CreateNGItem(item.PartCode, item.WrongQuantity, PartNGType.Wrong, item.DealerComment, h)); if (item.LackQuantity != 0) list.Add(CreateNGItem(item.PartCode, item.LackQuantity, PartNGType.Lack, item.DealerComment, h)); } //db.NGFormHeaders.InsertOnSubmit(h); //db.SubmitChanges(); //db.ReceiveHeaders.Single(q => q.ReceiveHeaderId == p.ReceiveHeaderId).NotGoodNumber = h.NotGoodNumber; //db.SubmitChanges(); p.NotGoodNumber = h.NotGoodNumber; MessageDAO.SendNGAlert(h.NotGoodNumber, h.DealerCode); } }); // save receive db.ReceiveHeaders.InsertAllOnSubmit(rh); db.SubmitChanges(); // update current inventory, inventory day rd.ForEach(p => { PartDAO.StockAdjust(p.PartCode, "P", UserHelper.DealerCode, WarehouseId, null, DateTime.Now, InventoryAction.NormalImport, p.UnitPrice * p.GoodQuantity, p.GoodQuantity, p.DealerComment, string.Empty, null); }); db.SubmitChanges(); }
private void attach_NGFormHeaders(NGFormHeader entity) { this.SendPropertyChanging("NGFormHeaders"); entity.ReceiveHeader = this; }
private void detach_NGFormHeaders(NGFormHeader entity) { this.SendPropertyChanging("NGFormHeaders"); entity.Dealer = null; }