public void TestSaveSupplierMng() { AppDomain.CurrentDomain.SetData("DataDirectory", AppDomain.CurrentDomain.BaseDirectory); using (var db = new PurchaseEntities()) { SupplierMng supplier = db.SupplierMng.Find(0); // supplier.SupplierName = "供应商名称2"; supplier.SupplierMngAttachmentFile.Clear(); for (int i = 0; i < 2; i++) { SupplierMngAttachmentFile attach = new SupplierMngAttachmentFile(); attach.FileName = "fileName1"; attach.SeqNO = i + 1; attach.SupplierId = supplier.Id; attach.SupplierMng = supplier; attach.UploadChk = true; attach.InDateTime = DateTime.Now; attach.InUserId = "admin"; supplier.SupplierMngAttachmentFile.Add(attach); } db.SaveChanges(); } }
public ActionResult DeleteAttach(int id, int seqNo) { SupplierMngAttachmentFile attach = db.SupplierMngAttachmentFile.Where(x => x.SupplierId == id && x.SeqNO == seqNo).FirstOrDefault(); db.SupplierMngAttachmentFile.Remove(attach); db.SaveChanges(); // DeleteFile(id + "_" + seqNo); return(Json("", JsonRequestBehavior.AllowGet)); }
private void SavePng(SupplierMng supplierMng) { supplierMng.SupplierMngAttachmentFile.Clear(); string[] attachs = Request.Form["AttachPngs"].Split(','); for (int i = 0; i < attachs.Length; i++) { int seqNo = i + 1; SupplierMngAttachmentFile attach = new SupplierMngAttachmentFile(); attach.FileName = attachs[i]; attach.SeqNO = seqNo; attach.SupplierId = supplierMng.Id; attach.SupplierMng = supplierMng; attach.UploadChk = !string.IsNullOrWhiteSpace(attach.FileName); attach.InDateTime = DateTime.Now; attach.InUserId = UserInfo.InUserId; supplierMng.SupplierMngAttachmentFile.Add(attach); } }