public DirectResult DeleteMapping(IList <string> selectedEmps, int operationTypeId) { try { string[] selectedEmpList = selectedEmps[0].Split(':'); foreach (var s in selectedEmpList) { if (s == "") { continue; } var empId = int.Parse(s); var filtered = _userMapping.GetAll().Where(p => p.UserId == empId && p.OperationTypeId == operationTypeId).ToList(); foreach (var filt in filtered) { _userMapping.Delete(c => c.Id == filt.Id); } } return(this.Json(new { success = true, data = "removed successfully!" })); } catch (Exception exception) { return(this.Json(new { success = false, data = "Error!" })); } }
public ActionResult DeleteDetail(int id) { try { _PackingSurveyDetail.Delete(c => c.Id == id); return(this.Json(new { success = true, data = "Record has been successfully deleted!" })); } catch (Exception) { return(this.Json(new { success = false, data = "Could not delete the selected record!" })); } }
public ActionResult Delete(int id) { try { _invoiceDetail.Delete(c => c.InvoiceId == id); _invoiceHeader.Delete(c => c.Id == id); return(this.Json(new { success = true, data = "record has been successfully deleted!" })); } catch (Exception) { return(this.Json(new { success = false, data = "Could not delete the selected record!" })); } }
public ActionResult Save(string operationTypes, int operationTypeId) { operationTypes = operationTypes.Remove(operationTypes.Length - 1); var servicesCollection = operationTypes.Split(new[] { ';' }); _OperationDocumentTemplate.Delete(o => o.OperationTypeId == operationTypeId); for (var i = 0; i < servicesCollection.Count(); i++) { var service = servicesCollection[i].Split(new[] { ':' }); var objOperationDocumentTemplate = new iffsOperationDocumentTemplate(); objOperationDocumentTemplate.DocumentTypeId = int.Parse(service[0]); objOperationDocumentTemplate.OperationTypeId = operationTypeId; _OperationDocumentTemplate.AddNew(objOperationDocumentTemplate); } return(this.Json(new { success = true, data = "Data has been saved successfully!" })); }
public ActionResult Delete(int id) { try { _documentNoSetting.Delete(c => c.Id == id); return(this.Json(new { success = true, data = "record has been successfully deleted!" })); } catch (Exception) { return(this.Json(new { success = false, data = "Could not delete the selected record!" })); } }
public ActionResult Delete(int id) { try { _termsAndConditionsTemplate.Delete(c => c.Id == id); return(this.Json(new { success = true, data = "record has been successfully deleted!" })); } catch (Exception) { return(this.Json(new { success = false, data = "Could not delete the selected record!" })); } }
public ActionResult DeleteAbsentDays(int id) { try { _PackingStaff.Delete(c => c.Id == id); return this.Json(new { success = true, data = "Record has been successfully deleted!" }); } catch (Exception) { return this.Json(new { success = false, data = "Could not delete the selected record!" }); } }
public ActionResult Delete(int id) { using (var transaction = new TransactionScope()) { _context.Database.Connection.Open(); try { var detail = _CrateAndBoxRequestDetail.GetAll().Where(d => d.HeaderId == id).Select(item => new { item.Id }).ToList(); foreach (var item in detail) { _CrateAndBoxRequestDetail.Delete(d => d.Id == item.Id); } _CrateAndBoxRequestHeader.Delete(c => c.Id == id); _context.SaveChanges(); transaction.Complete(); return(this.Json(new { success = true, data = "Record has been successfully deleted!" })); } catch (Exception) { return(this.Json(new { success = false, data = "Could not delete the selected record!" })); } } }
public void Delete(ESRI.ArcGIS.Geodatabase.IWorkspace Workspace, BaseModel BaseModel, ModelProperty _property) { ModelProperty _mpChaveFromField = BaseModel.ModelProperties.Where(x => x.Attribute is EntityKeyFieldAttribute).First(); int chave = (int)BaseModel.GetType().GetProperty(_mpChaveFromField.Property.Name).GetValue(BaseModel, null); object[] _parametros = { (object)Workspace }; EntityManyToManyFieldAttribute _attribute = (EntityManyToManyFieldAttribute)_property.Attribute; BaseModel _mtmField = (BaseModel)Activator.CreateInstance(_attribute.TargetModelType, _parametros); BaseModel _relateField = (BaseModel)Activator.CreateInstance(_attribute.RelateModelType, _parametros); _relateField.Delete(_attribute.FromFieldName + "=" + chave); }
public void SaveInvoiceOperations(string operationIds, int invoiceId) { var operationId = 0; var operationIdCollection = operationIds.Split(new[] { ',' }); _invoiceOperation.Delete(q => q.InvoiceHeaderId == invoiceId); IList <iffsInvoiceOperation> invoiceQuotationList = new List <iffsInvoiceOperation>(); for (var i = 0; i < operationIdCollection.Count(); i++) { int.TryParse(operationIdCollection[i], out operationId); var objInvoiceQuotation = new iffsInvoiceOperation { InvoiceHeaderId = invoiceId, OperationId = operationId }; _invoiceOperation.AddNew(objInvoiceQuotation); } }
public ActionResult Delete(int id) { try { var objServiceAgreement = _serviceAgreement.Get(d => d.Id == id); if (objServiceAgreement != null) { string appPath = HttpContext.Request.ApplicationPath; string physicalPath = HttpContext.Request.MapPath(appPath); string fullPath = physicalPath + "\\Upload\\ServiceAgreement\\" + objServiceAgreement.AgreementFile; System.IO.File.Delete(fullPath); } _serviceAgreement.Delete(u => u.Id == id); return(this.Json(new { success = true, data = "Service Agreement has been deleted successfully!" })); } catch (System.Exception ex) { return(this.Json(new { success = false, data = ex.InnerException != null ? ex.InnerException.Message : ex.Message })); } }
public ActionResult Delete(IList <iffsPackingMaterialList> packingMaterialList) { using (var transaction = new TransactionScope()) { _context.Database.Connection.Open(); try { //var detail = _PackingMaterialSetting.GetAll().Where(d => d.Id == id).Select(item => new { item.Id }).ToList(); foreach (var item in packingMaterialList) { _PackingMaterialSetting.Delete(c => c.Id == item.Id); } _context.SaveChanges(); transaction.Complete(); return(this.Json(new { success = true, data = "Record has been successfully deleted!" })); } catch (Exception) { return(this.Json(new { success = false, data = "Could not delete the selected record!" })); } } }
public DirectResult SaveExpense(int operationId, string rec) { _operationExpense.Delete(f => f.OperationId == operationId); var expenseString = rec; expenseString = expenseString.Remove(expenseString.Length - 1); var expensees = expenseString.Split(new[] { ';' }); for (var i = 0; i < expensees.Count(); i++) { var expense = expensees[i].Split(new[] { ':' }); var operationExpense = new iffsOperationExpense { OperationId = operationId, ExpenseTypeId = int.Parse(expense[0]), CurrencyId = int.Parse(expense[1]), ExchangeRate = decimal.Parse(expense[2]), Amount = decimal.Parse(expense[3]), }; _operationExpense.AddNew(operationExpense); } return(this.Json(new { success = true, data = "Operation expense have been saved successfully!" })); }
public string Save(ESRI.ArcGIS.Geodatabase.IWorkspace Workspace, BaseModel BaseModel, ModelProperty Property) { object[] _parametros = { (object)Workspace }; ModelProperty _mpChaveFromField = BaseModel.ModelProperties.Where(x => x.Attribute is EntityKeyFieldAttribute).First(); int chave = (int)BaseModel.GetType().GetProperty(_mpChaveFromField.Property.Name).GetValue(BaseModel, null); EntityManyToManyFieldAttribute _attribute = (EntityManyToManyFieldAttribute)Property.Attribute; BaseModel _mtmField = (BaseModel)Activator.CreateInstance(_attribute.TargetModelType, _parametros); BaseModel _relateField = (BaseModel)Activator.CreateInstance(_attribute.RelateModelType, _parametros); _relateField.Delete(_attribute.FromFieldName + "=" + chave); foreach (ModelProperty _mp in BaseModel.ModelProperties.Where(x => x.Attribute.FieldName.Equals(Property.Attribute.FieldName))) { if (_mp.Property.GetValue(BaseModel, null) != null) { IList _list = (IList)_mp.Property.GetValue(BaseModel, null); foreach (var _item in _list) { ModelProperty _mpChaveToField = BaseModel.ModelProperties.Where(x => x.Attribute is EntityKeyFieldAttribute).First(); int _value = Convert.ToInt32(_item.GetType().GetProperty(_mpChaveToField.Property.Name).GetValue(_item, null).ToString()); var _objFinal = Activator.CreateInstance(_attribute.RelateModelType, _parametros); _objFinal.GetType().GetProperty(_attribute.FromFieldName.Split('.')[1]).SetValue(_objFinal, chave, null); _objFinal.GetType().GetProperty(_attribute.ToFieldName.Split('.')[1]).SetValue(_objFinal, _value, null); ((BaseModel)_objFinal).Save(); } } } return(""); }
public void SaveJobOrderDetails(iffsJobOrderHeader jobOrderHeader, IList <string> voucherDetails, string action, IList <string> quotationDetails) { var jobOrderHeaderId = jobOrderHeader.Id; if (action == "Add") { for (var i = 0; i < voucherDetails.Count(); i++) { var row = voucherDetails[i].Split(new[] { ':' }); var fieldCategory = row[0].ToString(); var field = row[1].ToString(); var value = row[2].ToString(); var jobDetail = new iffsJobOrderDetail(); jobDetail.Id = 0; jobDetail.JobOrderHeaderId = jobOrderHeaderId; jobDetail.FieldCategory = fieldCategory; jobDetail.Field = row[1] != null ? field : ""; jobDetail.Value = row[2] != null ? value : ""; _jobOrderDetail.AddNew(jobDetail); _context.SaveChanges(); } //Save Job Order Quotations for (var j = 0; j < quotationDetails.Count(); j++) { var rowquote = quotationDetails[j].Split(new[] { ':' }); var quotationId = int.Parse(rowquote[0]); var jobOrderQuotation = new iffsJobOrderQuotation(); jobOrderQuotation.Id = 0; jobOrderQuotation.JobOrderId = jobOrderHeaderId; jobOrderQuotation.QuotationId = quotationId; _jobOrderQuotation.AddNew(jobOrderQuotation); _context.SaveChanges(); } } else if (action == "Edit") { _jobOrderDetail.Delete(s => s.JobOrderHeaderId == jobOrderHeaderId); for (int i = 0; i < voucherDetails.Count(); i++) { var row = voucherDetails[i].Split(new[] { ':' }); var fieldCategory = row[0].ToString(); var field = row[1].ToString(); var value = row[2].ToString(); var jobDetail = new iffsJobOrderDetail(); jobDetail.Id = 0; jobDetail.JobOrderHeaderId = jobOrderHeaderId; jobDetail.FieldCategory = fieldCategory; jobDetail.Field = row[1] != null ? field : ""; jobDetail.Value = row[2] != null ? value : ""; _jobOrderDetail.AddNew(jobDetail); _context.SaveChanges(); } _jobOrderQuotation.Delete(q => q.JobOrderId == jobOrderHeaderId); //Save Job Order Quotations for (var j = 0; j < quotationDetails.Count(); j++) { var rowquote = quotationDetails[j].Split(new[] { ':' }); var quotationId = int.Parse(rowquote[0]); var jobOrderQuotation = new iffsJobOrderQuotation(); jobOrderQuotation.Id = 0; jobOrderQuotation.JobOrderId = jobOrderHeaderId; jobOrderQuotation.QuotationId = quotationId; _jobOrderQuotation.AddNew(jobOrderQuotation); _context.SaveChanges(); } } else if (action == "Revised") { _jobOrderDetail.Delete(j => j.JobOrderHeaderId == jobOrderHeaderId); for (var i = 0; i < voucherDetails.Count(); i++) { var row = voucherDetails[i].Split(new[] { ':' }); var fieldCategory = row[0].ToString(); var field = row[1].ToString(); var value = row[2].ToString(); var jobDetail = new iffsJobOrderDetail(); jobDetail.Id = 0; jobDetail.JobOrderHeaderId = jobOrderHeaderId; jobDetail.FieldCategory = fieldCategory; jobDetail.Field = field; jobDetail.Value = value; _jobOrderDetail.AddNew(jobDetail); _context.SaveChanges(); } _jobOrderQuotation.Delete(q => q.JobOrderId == jobOrderHeaderId); //Save Job Order Quotations for (var j = 0; j < quotationDetails.Count(); j++) { var rowquote = quotationDetails[j].Split(new[] { ':' }); var quotationId = int.Parse(rowquote[0]); var jobOrderQuotation = new iffsJobOrderQuotation(); jobOrderQuotation.Id = 0; jobOrderQuotation.JobOrderId = jobOrderHeaderId; jobOrderQuotation.QuotationId = quotationId; _jobOrderQuotation.AddNew(jobOrderQuotation); _context.SaveChanges(); } } }
public void SaveServiceRequestDetails(iffsServiceRequest serviceRequestHeader, IList <string> serviceRequestDetails, string action) { var serviceRequestHeaderId = serviceRequestHeader.Id; if (action == "Add") { for (var i = 0; i < serviceRequestDetails.Count(); i++) { var row = serviceRequestDetails[i].Split(new[] { ':' }); var operationTypeId = int.Parse(row[0]); int? commodityTypeId = int.Parse(row[1]); decimal volume = Convert.ToDecimal(row[2].ToString()); decimal weight = Convert.ToDecimal(row[3].ToString()); var pcs = row[4].ToString(); var containerTypeId = int.Parse(row[5]); var poe = row[6].ToString(); var pod = row[7].ToString(); var description = row[8] != null && row[8] != "undefined" ? row[8].ToString() : ""; var tareWeight = row[9] != null && row[9] != "undefined" ? row[9].ToString() : ""; var sr = new iffsServiceRequestDetail { HeaderId = serviceRequestHeaderId, OperationTypeId = operationTypeId, CommodityTypeId = commodityTypeId == 0 ? null : commodityTypeId, Volume = volume, Weight = weight, Pcs = pcs, ContainerTypeId = containerTypeId, POE = poe, POD = pod, Description = description, TareWeight = tareWeight }; _serviceRequestDetails.AddNew(sr); _context.SaveChanges(); } } else if (action == "Edit") { _serviceRequestDetails.Delete(s => s.HeaderId == serviceRequestHeaderId); for (int i = 0; i < serviceRequestDetails.Count(); i++) { var row = serviceRequestDetails[i].Split(new[] { ':' }); var operationTypeId = int.Parse(row[0]); int? commodityTypeId = int.Parse(row[1]); decimal volume = Convert.ToDecimal(row[2].ToString()); decimal weight = Convert.ToDecimal(row[3].ToString()); var pcs = row[4].ToString(); var containerTypeId = int.Parse(row[5]); var poe = row[6].ToString(); var pod = row[7].ToString(); var description = row[8] != null && row[8] != "undefined" ? row[8].ToString() : ""; var tareWeight = row[9] != null && row[9] != "undefined" ? row[9].ToString() : ""; var sr = new iffsServiceRequestDetail { HeaderId = serviceRequestHeaderId, OperationTypeId = operationTypeId, CommodityTypeId = commodityTypeId == 0 ? null : commodityTypeId, Volume = volume, Weight = weight, Pcs = pcs, ContainerTypeId = containerTypeId, POE = poe, POD = pod, Description = description, TareWeight = tareWeight }; _serviceRequestDetails.AddNew(sr); _context.SaveChanges(); } } }
/// <summary> /// 删除数据 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="gird"></param> protected void DeleteData <T>(Grid gird) where T : BaseModel <T, long> { BaseModel <T, long> .Delete(Sql.Builder .Where("Id IN (@ids)", new { ids = GetSelectedIds(gird) })); }