public TenderQuantityTable SaveQuantityTableBulkItems(long tableId, List <TenderQuantityItemDTO> lst, string tableName) { Name = string.IsNullOrEmpty(tableName) ? "اسم الجدول" : tableName; var lastIndex = QuantitiyItemsJson.TenderQuantityTableItems.Count != 0 ? QuantitiyItemsJson.TenderQuantityTableItems.Max(D => D.ItemNumber) : 0; foreach (var item in lst) { byte[] gb = Guid.NewGuid().ToByteArray(); long IId = BitConverter.ToInt64(gb, 0); var idExsit = QuantitiyItemsJson.TenderQuantityTableItems.Any(x => x.Id == IId); while (idExsit) { gb = Guid.NewGuid().ToByteArray(); IId = BitConverter.ToInt64(gb, 0); idExsit = QuantitiyItemsJson.TenderQuantityTableItems.Any(x => x.Id == IId); } QuantitiyItemsJson.TenderQuantityTableItems.Add(new TenderQuantityTableItem(IId, item.ColumnId, item.TenderFormHeaderId, item.TemplateId, item.ColumnName, item.Value, item.ItemNumber + lastIndex)); } if (tableId == 0) { EntityCreated(); QuantitiyItemsJson.SetAddedState(); } else { EntityUpdated(); QuantitiyItemsJson.SetUpdateState(); } return(this); }
public TenderQuantityTable DeleteTenderQuantityTablesItems() { if (QuantitiyItemsJson != null) { QuantitiyItemsJson.Delete(); } return(this); }
public TenderQuantityTable DeleteTenderQuantityTableWithItems() { if (QuantitiyItemsJson != null) { QuantitiyItemsJson.Delete(); } DeActive(); return(this); }
public SupplierTenderQuantityTable SaveQuantityTableItems(long tableId, List <TenderQuantityItemDTO> lst, string tableName, long currentItemId, out long itemId) { itemId = 0; Name = tableName; if (QuantitiyItemsJson == null) { QuantitiyItemsJson = new SupplierTenderQuantityTableItemJson(); QuantitiyItemsJson.Create(); } bool ItemExists = QuantitiyItemsJson.SupplierTenderQuantityTableItems != null && QuantitiyItemsJson.SupplierTenderQuantityTableItems.Any(a => /*a.IsActive == true && a.SupplierTenderQuantityTableId == tableId && */ a.ItemNumber == currentItemId); var lastIndex = QuantitiyItemsJson.SupplierTenderQuantityTableItems.Any() ? QuantitiyItemsJson.SupplierTenderQuantityTableItems.OrderByDescending(t => t.ItemNumber).FirstOrDefault().ItemNumber : 0; foreach (var item in lst) { if (!ItemExists) { byte[] gb = Guid.NewGuid().ToByteArray(); long IId = BitConverter.ToInt64(gb, 0); var idExsit = QuantitiyItemsJson.SupplierTenderQuantityTableItems.Any(x => x.Id == IId); while (idExsit) { gb = Guid.NewGuid().ToByteArray(); IId = BitConverter.ToInt64(gb, 0); idExsit = QuantitiyItemsJson.SupplierTenderQuantityTableItems.Any(x => x.Id == IId); } QuantitiyItemsJson.SupplierTenderQuantityTableItems.Add(new SupplierTenderQuantityTableItem(IId, item.ColumnId, item.TenderFormHeaderId, item.TemplateId, item.Value, lastIndex + 1)); itemId = lastIndex + 1; } else { SupplierTenderQuantityTableItem QItem; if (item.Id != 0) { QItem = QuantitiyItemsJson.SupplierTenderQuantityTableItems.FirstOrDefault(q => q.Id == item.Id); } else { QItem = QuantitiyItemsJson.SupplierTenderQuantityTableItems.FirstOrDefault(q => q.ItemNumber == item.ItemNumber && q.ColumnId == item.ColumnId && q.TenderFormHeaderId == item.TenderFormHeaderId); } QItem.UpdateItems(item.ColumnId, item.TenderFormHeaderId, item.TemplateId, item.Value, currentItemId); } } if (tableId == 0) { EntityCreated(); QuantitiyItemsJson.Create(); } else { EntityUpdated(); QuantitiyItemsJson.Update(); } return(this); }
public TenderQuantityTable SaveQuantityTableItems(long tableId, List <TenderQuantityItemDTO> lst, long currentItemId, out long itemId) { itemId = 0; bool ItemExists = QuantitiyItemsJson != null && QuantitiyItemsJson.TenderQuantityTableItems != null && QuantitiyItemsJson.TenderQuantityTableItems.Any(a => a.ItemNumber == currentItemId); var lastIndex = QuantitiyItemsJson.TenderQuantityTableItems.Any() ? QuantitiyItemsJson.TenderQuantityTableItems.Max(a => a.ItemNumber) : 0; foreach (var item in lst) { if (!ItemExists) { byte[] gb = Guid.NewGuid().ToByteArray(); long IId = BitConverter.ToInt64(gb, 0); var idExsit = QuantitiyItemsJson.TenderQuantityTableItems.Any(x => x.Id == IId); while (idExsit) { gb = Guid.NewGuid().ToByteArray(); IId = BitConverter.ToInt64(gb, 0); idExsit = QuantitiyItemsJson.TenderQuantityTableItems.Any(x => x.Id == IId); } QuantitiyItemsJson.TenderQuantityTableItems.Add(new TenderQuantityTableItem(IId, item.ColumnId, item.TenderFormHeaderId, item.TemplateId, item.ColumnName, item.Value, lastIndex + 1)); itemId = lastIndex + 1; } else { TenderQuantityTableItem QItem; if (item.Id != 0) { QItem = QuantitiyItemsJson.TenderQuantityTableItems.FirstOrDefault(q => q.Id == item.Id); } else { QItem = QuantitiyItemsJson.TenderQuantityTableItems.FirstOrDefault(q => q.ItemNumber == item.ItemNumber && q.ColumnId == item.ColumnId && q.TenderFormHeaderId == item.TenderFormHeaderId); } if (QItem != null) { QItem.UpdateItems(item.ColumnId, item.TenderFormHeaderId, item.TemplateId, item.ColumnName, item.Value, currentItemId); } } } if (tableId == 0) { EntityCreated(); QuantitiyItemsJson.SetAddedState(); } else { EntityUpdated(); QuantitiyItemsJson.SetUpdateState(); } return(this); }
public SupplierTenderQuantityTable DeleteQuantityTableItems(int itemNumber) { QuantitiyItemsJson.DeleteRow(itemNumber); EntityUpdated(); return(this); }
public void SetAddedState() { Id = 0; QuantitiyItemsJson.SetAddedState(); EntityCreated(); }