public void DeleteFromRepository(WarehouseType itemType) { if (_repositoryContext.GetEntityDescriptor(itemType) != null) {//if it exists in the db delete it from the db WarehouseEntities context = new WarehouseEntities(_rootUri); context.MergeOption = MergeOption.AppendOnly; context.IgnoreResourceNotFoundException = true; WarehouseType deletedWarehouseType = (from q in context.WarehouseTypes where q.WarehouseTypeID == itemType.WarehouseTypeID select q).FirstOrDefault(); if (deletedWarehouseType != null) { context.DeleteObject(deletedWarehouseType); context.SaveChanges(); } context = null; _repositoryContext.MergeOption = MergeOption.AppendOnly; //if it is being tracked remove it... if (GetWarehouseTypeEntityState(itemType) != EntityStates.Detached) { _repositoryContext.Detach(itemType); } } }
public List <WarehouseLink> GetWarehouseItems(Guid?id, long?ownerId, WarehouseType warehouseType, byte?slot) { var list = new List <WarehouseLink>(); if (id == null) { var warehouse = _warehouseDao.FirstOrDefaultAsync(s => s.Type == warehouseType && s.CharacterId == (warehouseType == WarehouseType.FamilyWareHouse ? null : ownerId) && s.FamilyId == (warehouseType == WarehouseType.FamilyWareHouse ? ownerId : null)); if (slot == null) { //todo add } else { //todo add } } else { var warehouseLink = new WarehouseLink(); list.Add(warehouseLink); } return(list); }
public async Task <bool> DepositItemAsync(long ownerId, WarehouseType warehouseType, ItemInstanceDto?itemInstance, short slot) { var item = itemInstance as IItemInstanceDto; item !.Id = Guid.NewGuid(); item = await _itemInstanceDao.TryInsertOrUpdateAsync(item).ConfigureAwait(true); var warehouse = new WarehouseDto { CharacterId = warehouseType == WarehouseType.FamilyWareHouse ? null : (long?)ownerId, Id = Guid.NewGuid(), FamilyId = warehouseType == WarehouseType.FamilyWareHouse ? (long?)ownerId : null, Type = warehouseType, }; warehouse = await _warehouseDao.TryInsertOrUpdateAsync(warehouse).ConfigureAwait(true); var warehouseItem = new WarehouseItemDto { Slot = slot, Id = Guid.NewGuid(), ItemInstanceId = item !.Id, WarehouseId = warehouse.Id }; await _warehouseItemDao.TryInsertOrUpdateAsync(warehouseItem).ConfigureAwait(true); return(true); } }
private void Refresh() {//refetch current records... long selectedAutoID = SelectedWarehouseType.AutoID; string autoIDs = ""; //bool isFirstItem = true; foreach (WarehouseType itemType in WarehouseTypeList) {//auto seeded starts at 1 any records at 0 or less or not valid records... if (itemType.AutoID > 0) { autoIDs = autoIDs + itemType.AutoID.ToString() + ","; } } if (autoIDs.Length > 0) { //ditch the extra comma... autoIDs = autoIDs.Remove(autoIDs.Length - 1, 1); WarehouseTypeList = new BindingList <WarehouseType>(_serviceAgent.RefreshWarehouseType(autoIDs).ToList()); SelectedWarehouseType = (from q in WarehouseTypeList where q.AutoID == selectedAutoID select q).FirstOrDefault(); Dirty = false; AllowCommit = false; } }
public void Put(String Type, [FromBody] WarehouseType ware) { if (ModelState.IsValid) { WarehouseTypeRepository.Update(Type, ware); } }
public static List <Temp> GetMetaData(this WarehouseType entityObject) { XERP.Server.DAL.WarehouseDAL.DALUtility dalUtility = new DALUtility(); List <Temp> tempList = new List <Temp>(); int id = 0; using (WarehouseEntities ctx = new WarehouseEntities(dalUtility.EntityConectionString)) { var c = ctx.WarehouseTypes.FirstOrDefault(); var queryResults = from meta in ctx.MetadataWorkspace.GetItems(DataSpace.CSpace) .Where(m => m.BuiltInTypeKind == BuiltInTypeKind.EntityType) from query in (meta as EntityType).Properties .Where(p => p.DeclaringType.Name == entityObject.GetType().Name) select query; if (queryResults.Count() > 0) { foreach (var queryResult in queryResults.ToList()) { Temp temp = new Temp(); temp.ID = id; temp.Name = queryResult.Name.ToString(); temp.ShortChar_1 = queryResult.TypeUsage.EdmType.Name; if (queryResult.TypeUsage.EdmType.Name == "String") { temp.Int_1 = Convert.ToInt32(queryResult.TypeUsage.Facets["MaxLength"].Value); } temp.Bool_1 = false; //we use this as a error trigger false = not an error... tempList.Add(temp); id++; } } } return(tempList); }
public void Post([FromBody] WarehouseType Type) { if (ModelState.IsValid) { WarehouseTypeRepository.Add(Type); } }
//WarehouseType Object Scope Validation check the entire object for validity... private byte WarehouseTypeIsValid(WarehouseType item, out string errorMessage) { //validate key errorMessage = ""; if (string.IsNullOrEmpty(item.WarehouseTypeID)) { errorMessage = "ID Is Required."; return(1); } EntityStates entityState = GetWarehouseTypeState(item); if (entityState == EntityStates.Added && WarehouseTypeExists(item.WarehouseTypeID, ClientSessionSingleton.Instance.CompanyID)) { errorMessage = "Item All Ready Exists."; return(1); } //check cached list for duplicates... int count = WarehouseTypeList.Count(q => q.WarehouseTypeID == item.WarehouseTypeID); if (count > 1) { errorMessage = "Item All Ready Exists."; return(1); } //validate Description if (string.IsNullOrEmpty(item.Description)) { errorMessage = "Description Is Required."; return(1); } //a value of 2 is pending changes... //On Commit we will give it a value of 0... return(2); }
private void ChangeKeyLogic() { if (!string.IsNullOrEmpty(SelectedWarehouseType.WarehouseTypeID)) {//check to see if key is part of the current companylist... WarehouseType query = WarehouseTypeList.Where(company => company.WarehouseTypeID == SelectedWarehouseType.WarehouseTypeID && company.AutoID != SelectedWarehouseType.AutoID).FirstOrDefault(); if (query != null) {//revert it back... SelectedWarehouseType.WarehouseTypeID = SelectedWarehouseTypeMirror.WarehouseTypeID; //change to the newly selected company... SelectedWarehouseType = query; return; } //it is not part of the existing list try to fetch it from the db... WarehouseTypeList = GetWarehouseTypeByID(SelectedWarehouseType.WarehouseTypeID, XERP.Client.ClientSessionSingleton.Instance.CompanyID); if (WarehouseTypeList.Count == 0)//it was not found do new record required logic... { NotifyNewRecordNeeded("Record " + SelectedWarehouseType.WarehouseTypeID + " Does Not Exist. Create A New Record?"); } else { SelectedWarehouseType = WarehouseTypeList.FirstOrDefault(); } } else { string errorMessage = "ID Is Required."; NotifyMessage(errorMessage); //revert back to the value it was before it was changed... if (SelectedWarehouseType.WarehouseTypeID != SelectedWarehouseTypeMirror.WarehouseTypeID) { SelectedWarehouseType.WarehouseTypeID = SelectedWarehouseTypeMirror.WarehouseTypeID; } } }
public IEnumerable <WarehouseType> GetWarehouseTypes(WarehouseType itemTypeQuerryObject, string companyID) { _repositoryContext = new WarehouseEntities(_rootUri); _repositoryContext.MergeOption = MergeOption.AppendOnly; _repositoryContext.IgnoreResourceNotFoundException = true; var queryResult = from q in _repositoryContext.WarehouseTypes where q.CompanyID == companyID select q; if (!string.IsNullOrEmpty(itemTypeQuerryObject.Type)) { queryResult = queryResult.Where(q => q.Type.StartsWith(itemTypeQuerryObject.Type.ToString())); } if (!string.IsNullOrEmpty(itemTypeQuerryObject.Description)) { queryResult = queryResult.Where(q => q.Description.StartsWith(itemTypeQuerryObject.Description.ToString())); } if (!string.IsNullOrEmpty(itemTypeQuerryObject.WarehouseTypeID)) { queryResult = queryResult.Where(q => q.Description.StartsWith(itemTypeQuerryObject.WarehouseTypeID.ToString())); } return(queryResult); }
public void DeleteWarehouseTypeCommand() { try {//company is fk to 100's of tables deleting it can be tricky... int i = 0; int ii = 0; for (int j = SelectedWarehouseTypeList.Count - 1; j >= 0; j--) { WarehouseType item = (WarehouseType)SelectedWarehouseTypeList[j]; //get Max Index... i = WarehouseTypeList.IndexOf(item); if (i > ii) { ii = i; } Delete(item); WarehouseTypeList.Remove(item); } if (WarehouseTypeList != null && WarehouseTypeList.Count > 0) { //back off one index from the max index... ii = ii - 1; //if they delete the first row... if (ii < 0) { ii = 0; } //make sure it does not exceed the list count... if (ii >= WarehouseTypeList.Count()) { ii = WarehouseTypeList.Count - 1; } SelectedWarehouseType = WarehouseTypeList[ii]; //we will only enable committ for dirty validated records... if (Dirty == true) { AllowCommit = CommitIsAllowed(); } else { AllowCommit = false; } } else//only one record, deleting will result in no records... { SetAsEmptySelection(); } }//we try catch company delete as it may be used in another table as a key... //As well we will force a refresh to sqare up the UI after the botched delete... catch { NotifyMessage("WarehouseType/s Can Not Be Deleted. Contact XERP Admin For More Details."); Refresh(); } }
public ActionResult DeleteConfirmed(long id) { WarehouseType warehouseType = db.WarehouseTypes.Find(id); db.WarehouseTypes.Remove(warehouseType); db.SaveChanges(); return(RedirectToAction("Index")); }
private BindingList <WarehouseType> GetWarehouseTypes(WarehouseType itemType, string companyID) { BindingList <WarehouseType> itemTypeList = new BindingList <WarehouseType>(_serviceAgent.GetWarehouseTypes(itemType, companyID).ToList()); Dirty = false; AllowCommit = false; return(itemTypeList); }
private void SetAsEmptySelection() { SelectedWarehouseType = new WarehouseType(); AllowEdit = false; AllowDelete = false; Dirty = false; AllowCommit = false; AllowRowCopy = false; }
public static void SetPropertyValue(this WarehouseType myObj, object propertyName, object propertyValue) { var propInfo = typeof(WarehouseType).GetProperty((string)propertyName); if (propInfo != null) { propInfo.SetValue(myObj, propertyValue, null); } }
/// <summary> /// 根据仓库类型获取仓库列表 /// </summary> /// <param name="warehouseType">仓库类型</param> /// <returns>仓库列表</returns> public List<Warehouse> GetWarehousesByType(WarehouseType warehouseType) { using (IUnitOfWork unitwork = MSSqlHelper.DataContext()) { IWarehouseRepository warehouseRep = new WarehouseRepository(unitwork); List<Warehouse> warehouses = warehouseRep.GetWarehouseByType(warehouseType); return warehouses; } }
public async Task <bool> Modify(WarehouseType _model) { _model.UpdatedUser = scopeContext.UserCode; _model.UpdatedDate = DateTime.Now; context.Update(_model); await context.SaveChangesAsync(); return(true); }
public async Task <int> Add(WarehouseType _model) { _model.CreatedUser = scopeContext.UserCode; _model.CreatedDate = DateTime.Now; context.Add(_model); await context.SaveChangesAsync(); return(_model.Id); }
public void Add(WarehouseType Type) { using (IDbConnection dbConnection = Connection) { string sQuery = "INSERT INTO WarehouseType (Type" + " VALUES(@Type)"; dbConnection.Open(); dbConnection.Execute(sQuery, Type); } }
public ActionResult Edit([Bind(Include = "Id,Type,Description,CreatedAt")] WarehouseType warehouseType) { if (ModelState.IsValid) { db.Entry(warehouseType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(warehouseType)); }
public void UpdateRepository(WarehouseType itemType) { if (_repositoryContext.GetEntityDescriptor(itemType) != null) { itemType.LastModifiedBy = XERP.Client.ClientSessionSingleton.Instance.SystemUserID; itemType.LastModifiedByDate = DateTime.Now; _repositoryContext.MergeOption = MergeOption.AppendOnly; _repositoryContext.UpdateObject(itemType); } }
public Task <bool> DepositItemAsync(long characterId, WarehouseType warehouse, IItemInstance itemInstance, short slot) { return(PostAsync <bool>(new WareHouseDepositRequest { OwnerId = characterId, WarehouseType = warehouse, ItemInstance = itemInstance.Adapt <ItemInstanceDto>(), Slot = slot })); }
public ActionResult Create([Bind(Include = "WarehouseTypeId,WarehouseName,Description")] WarehouseType warehouseType) { if (ModelState.IsValid) { db.WarehouseTypes.Add(warehouseType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(warehouseType)); }
/// <summary> /// 彻底删除一个仓库类别 /// </summary> /// <param name="delWarehType">要彻底删除的仓库类别</param> public void DelFullyWarehType(WarehouseType delWarehType) { try { _warehTypeDal.Delete(delWarehType); } catch (RepositoryException ex) { throw ex; } }
public void Update(string type, WarehouseType Type) { using (IDbConnection dbConnection = Connection) { string sQuery = " UPDATE WarehouseType SET Type = @Type " + " WHERE Type = '" + type + "'"; dbConnection.Open(); dbConnection.Execute(sQuery, Type); } }
public async Task <bool> Modify(int _id, WarehouseTypeModel _model) { WarehouseType entity = await svcWarehouseType.GetDetail(_id); if (entity == null) { return(false); } entity = iMapper.Map(_model, entity); return(await svcWarehouseType.Modify(entity)); }
private void OnSearchResult(object sender, NotificationEventArgs <BindingList <WarehouseType> > e) { if (e.Data != null && e.Data.Count > 0) { WarehouseTypeList = e.Data; SelectedWarehouseType = WarehouseTypeList.FirstOrDefault(); Dirty = false; AllowCommit = false; } UnregisterToReceiveMessages <BindingList <WarehouseType> >(MessageTokens.WarehouseTypeSearchToken.ToString(), OnSearchResult); }
public EntityStates GetWarehouseTypeEntityState(WarehouseType itemType) { if (_repositoryContext.GetEntityDescriptor(itemType) != null) { return(_repositoryContext.GetEntityDescriptor(itemType).State); } else { return(EntityStates.Detached); } }
/// <summary> /// 增加一个仓库类别 /// </summary> /// <param name="newWarehType">要增加的仓库类别</param> /// <returns>增加后的仓库类别</returns> public WarehouseType AddWarehType(WarehouseType newWarehType) { try { _warehTypeDal.Add(newWarehType); return(newWarehType); } catch (RepositoryException ex) { throw ex; } }
/// <summary> /// 修改一个仓库类别 /// </summary> /// <param name="updWarehType">要修改的仓库类别</param> /// <returns>修改后的仓库类别</returns> public WarehouseType UpdateWarehType(WarehouseType updWarehType) { try { _warehTypeDal.Update(updWarehType); return(updWarehType); } catch (RepositoryException ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { string strCateId = Request.QueryString["id"]; if (!string.IsNullOrEmpty(strCateId) && int.TryParse(strCateId, out id)) { wh = WarehouseType.findById(id); } if (!IsPostBack) { if (wh != null) { txtWarehouseName.Value = wh.WarehouseName; txtCode.Value = wh.WarehouseCode; txtAddress.Value = wh.Address; txtDesc.Value = wh.Description; } } }
protected void btnSubmit_Click(object sender, EventArgs e) { wh = new WarehouseType(); string warehouseName = Request.Form[txtWarehouseName.ID].Trim(); if (string.IsNullOrEmpty(warehouseName)) { return; } wh.WarehouseName = warehouseName; wh.WarehouseCode = txtCode.Value; wh.Address = txtAddress.Value; wh.Description = txtDesc.Value; if (id != 0) { wh.Id = id; wh.update(); } else { wh.insert(); } }
partial void OnWarehouseTypeChanging(WarehouseType value);
/// <summary> /// 根据仓库类型获得仓库 /// </summary> /// <param name="warehouseType">仓库类型</param> /// <returns>仓库列表</returns> public List<Warehouse> GetWarehouseByType(WarehouseType warehouseType) { List<Warehouse> warehouses = context.Warehouse.Where(w => w.WarehouseType == warehouseType).ToList(); return warehouses; }