protected void DocumentUpload_DeleteAttachments(object sender, EventArgs e) { model = GetDeliveryNoteProvider().GetDeliveryNoteModel(); if (model != null) { int hasPipe = 0; string fileToDelete = (sender as UploadAttachment).currentFile.Name; DocumentEntity obj = GetAttachmentFromDB(fileToDelete); if (obj != null) { string item = obj.Url + ";" + obj.Name; string strPhysicalFolder = Server.MapPath(obj.Url); if (File.Exists(strPhysicalFolder)) { File.Delete(strPhysicalFolder); } if (model.XMLFilePath.Contains("|")) { hasPipe = 1; } else { hasPipe = 0; } model.XMLFilePath = model.XMLFilePath.Remove(model.XMLFilePath.IndexOf(item) - hasPipe, item.Length + hasPipe); deliveryNoteRepo = new DeliveryNoteRepository(model.Session); deliveryNoteRepo.SaveDeliveryNote(model, PrincipalHelper.GetUserID()); } } }
private bool AddOrEditEntityObject(bool add = false) { if (add) { model = new DeliveryNote(session); model.DeliveryNoteID = 0; } else if (!add && model == null) { model = GetDeliveryNoteProvider().GetDeliveryNoteModel(); } model.DeliveryNoteDate = DateEditDeliveryNoteDate.Date; model.DeliveryNoteNumber = txtDeliveryNoteNumber.Text; model.RecivedMaterialDate = DateEditDeliveryNoteDate.Date; int supplierID = CommonMethods.ParseInt(GetGridLookupValue(GridLookupSupplier)); if (model.SupplierID != null) { model.SupplierID = clientRepo.GetClientByID(supplierID, model.SupplierID.Session); } else { model.SupplierID = clientRepo.GetClientByID(supplierID); } int locationID = CommonMethods.ParseInt(GetGridLookupValue(GridLookupLocation)); if (model.LocationID != null) { model.LocationID = locationRepo.GetLocationByID(locationID, model.LocationID.Session); } else { model.LocationID = locationRepo.GetLocationByID(locationID); } model.Notes = MemoNotes.Text; /*if (!String.IsNullOrEmpty(model.Picture)) * { * //UploadProfile.ProfileImage.Src = model.Picture.Replace(AppDomain.CurrentDomain.BaseDirectory, "\\"); * }*/ if (GetDeliveryNoteProvider().GetDeliveryNoteStatus() == Enums.DeliveryNoteStatus.Error && !String.IsNullOrEmpty(processError)) { model.ProcessError = processError; } model.DeliveryNoteStatusID = deliveryNoteRepo.GetDeliveryNoteStatusByCode(GetDeliveryNoteProvider().GetDeliveryNoteStatus(), model.Session); deliveryNoteID = deliveryNoteRepo.SaveDeliveryNote(model, PrincipalHelper.GetUserID()); return(true); }
protected void DocumentUpload_UploadComplete(object sender, EventArgs e) { model = GetDeliveryNoteProvider().GetDeliveryNoteModel(); if (model != null) { string pipe = ""; if (!String.IsNullOrEmpty(model.XMLFilePath)) { pipe = "|"; } deliveryNoteRepo = new DeliveryNoteRepository(model.Session); model.XMLFilePath += pipe + (sender as UploadAttachment).currentFile.Url + ";" + (sender as UploadAttachment).currentFile.Name; deliveryNoteRepo.SaveDeliveryNote(model, PrincipalHelper.GetUserID()); GetDeliveryNoteProvider().SetDeliveryNoteModel(model); //TODO: parse XML //HtmlGenericControl control = (HtmlGenericControl)attachmentsItem.FindControl("attachmentsBadge"); //control.InnerText = model.Priloge.Split('|').Length.ToString(); } }