예제 #1
0
 private void detach_NGFormDetails(NGFormDetail entity)
 {
     this.SendPropertyChanging();
     entity.NGFormHeader = null;
 }
예제 #2
0
 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 attach_NGFormDetails(NGFormDetail entity)
 {
     this.SendPropertyChanging("NGFormDetails");
     entity.NGFormHeader = this;
 }