/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (AssetNumber != null) { hashCode = hashCode * 59 + AssetNumber.GetHashCode(); } if (SubNumber != null) { hashCode = hashCode * 59 + SubNumber.GetHashCode(); } if (CompanyCode != null) { hashCode = hashCode * 59 + CompanyCode.GetHashCode(); } if (Status != null) { hashCode = hashCode * 59 + Status.GetHashCode(); } if (Checked != null) { hashCode = hashCode * 59 + Checked.GetHashCode(); } return(hashCode); } }
//All senior tables(Companies, Parts, Orders, ect...) tend to have a generic table called TableNameCodes //i.e. CompanyCodes PartCodes, OrderCodes... //So this will constitute the meta data for that Code table... //Xerp attempts to use generic naming where possible to allow for cloning... public static List <Temp> GetMetaData(this CompanyCode entityObject) { XERP.Server.DAL.CompanyDAL.DALUtility dalUtility = new DALUtility(); List <Temp> tempList = new List <Temp>(); int id = 0; using (CompanyEntities ctx = new CompanyEntities(dalUtility.EntityConectionString)) { var c = ctx.CompanyCodes.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 DeleteFromRepository(CompanyCode itemCode) { if (_repositoryContext.GetEntityDescriptor(itemCode) != null) {//if it exists in the db delete it from the db CompanyEntities context = new CompanyEntities(_rootUri); context.MergeOption = MergeOption.AppendOnly; context.IgnoreResourceNotFoundException = true; CompanyCode deletedCompanyCode = (from q in context.CompanyCodes where q.CompanyCodeID == itemCode.CompanyCodeID select q).FirstOrDefault(); if (deletedCompanyCode != null) { context.DeleteObject(deletedCompanyCode); context.SaveChanges(); } context = null; _repositoryContext.MergeOption = MergeOption.AppendOnly; //if it is being tracked remove it... if (GetCompanyCodeEntityState(itemCode) != EntityStates.Detached) { _repositoryContext.Detach(itemCode); } } }
public IQueryable <Temp> GetMetaData(string tableName) { switch (tableName) { case "Companies": Company item = new Company(); return(item.GetMetaData().AsQueryable()); case "CompanyTypes": CompanyType itemType = new CompanyType(); return(itemType.GetMetaData().AsQueryable()); case "CompanyCodes": CompanyCode itemCode = new CompanyCode(); return(itemCode.GetMetaData().AsQueryable()); default: //no table exists for the given tablename given... List <Temp> tempList = new List <Temp>(); Temp temp = new Temp(); temp.ID = 0; temp.Int_1 = 0; temp.Bool_1 = true; //bool_1 will flag it as an error... temp.Name = "Error"; temp.ShortChar_1 = "Table " + tableName + " Is Not A Valid Table Within The Given Entity Collection, Or Meta Data Was Not Defined For The Given Table Name"; tempList.Add(temp); return(tempList.AsQueryable()); } }
public IEnumerable <CompanyCode> GetCompanyCodes(CompanyCode itemCodeQuerryObject) { _repositoryContext = new CompanyEntities(_rootUri); _repositoryContext.MergeOption = MergeOption.AppendOnly; _repositoryContext.IgnoreResourceNotFoundException = true; var queryResult = from q in _repositoryContext.CompanyCodes select q; if (!string.IsNullOrEmpty(itemCodeQuerryObject.Code)) { queryResult = queryResult.Where(q => q.Code.StartsWith(itemCodeQuerryObject.Code.ToString())); } if (!string.IsNullOrEmpty(itemCodeQuerryObject.Description)) { queryResult = queryResult.Where(q => q.Description.StartsWith(itemCodeQuerryObject.Description.ToString())); } if (!string.IsNullOrEmpty(itemCodeQuerryObject.CompanyCodeID)) { queryResult = queryResult.Where(q => q.Description.StartsWith(itemCodeQuerryObject.CompanyCodeID.ToString())); } return(queryResult); }
private void ChangeKeyLogic() { if (!string.IsNullOrEmpty(SelectedCompanyCode.CompanyCodeID)) {//check to see if key is part of the current list... CompanyCode query = CompanyCodeList.Where(item => item.CompanyCodeID == SelectedCompanyCode.CompanyCodeID && item.AutoID != SelectedCompanyCode.AutoID).FirstOrDefault(); if (query != null) {//revert it back SelectedCompanyCode.CompanyCodeID = SelectedCompanyCodeMirror.CompanyCodeID; //change to the newly selected item... SelectedCompanyCode = query; return; } //it is not part of the existing list try to fetch it from the db... CompanyCodeList = GetCompanyCodeByID(SelectedCompanyCode.CompanyCodeID); if (CompanyCodeList.Count == 0)//it was not found do new record required logic... { NotifyNewRecordNeeded("Record " + SelectedCompanyCode.CompanyCodeID + " Does Not Exist. Create A New Record?"); } else { SelectedCompanyCode = CompanyCodeList.FirstOrDefault(); } } else { string errorMessage = "ID Is Required."; NotifyMessage(errorMessage); //revert back to the value it was before it was changed... if (SelectedCompanyCode.CompanyCodeID != SelectedCompanyCodeMirror.CompanyCodeID) { SelectedCompanyCode.CompanyCodeID = SelectedCompanyCodeMirror.CompanyCodeID; } } }
//CompanyCode Object Scope Validation check the entire object for validity... private byte CompanyCodeIsValid(CompanyCode item, out string errorMessage) { //validate key errorMessage = ""; if (string.IsNullOrEmpty(item.CompanyCodeID)) { errorMessage = "ID Is Required."; return(1); } EntityStates entityState = GetCompanyCodeState(item); if (entityState == EntityStates.Added && CompanyCodeExists(item.CompanyCodeID)) { errorMessage = "Item All Ready Exists."; return(1); } //check cached list for duplicates... int count = CompanyCodeList.Count(q => q.CompanyCodeID == item.CompanyCodeID); 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); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //项目下拉框 DataTable dt = CompanyBusiness.GetCompanyProjects(CompanyCode.ToString()); ControlHelper.BindListControl(ddlProject, dt, "PROJECTNAME", "PROJECTID"); ddlProject.Items.Remove(ddlProject.Items.FindByValue(CommonMethod.GetConfigValue("SYSPROJECTID"))); if (ProjectId > 0) { ControlHelper.SelectFlg(ddlProject, ProjectId.ToString()); } if (Request.QueryString["pid"] != null) { ControlHelper.SelectFlg(ddlProject, Enc.Decrypt(Request.QueryString["pid"], UrlEncKey)); } if (ddlProject.Items.Count > 1 && ProjectId == 0) //不是自动登录并且开通项目大于1个 { ExecStartScript("$('#sProject').show();"); } else { lblTip.Visible = true; } } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (InventoryVariantName != null) { hashCode = hashCode * 59 + InventoryVariantName.GetHashCode(); } if (TagId != null) { hashCode = hashCode * 59 + TagId.GetHashCode(); } if (AssetNumber != null) { hashCode = hashCode * 59 + AssetNumber.GetHashCode(); } if (SubNumber != null) { hashCode = hashCode * 59 + SubNumber.GetHashCode(); } if (CompanyCode != null) { hashCode = hashCode * 59 + CompanyCode.GetHashCode(); } if (Description != null) { hashCode = hashCode * 59 + Description.GetHashCode(); } return(hashCode); } }
public void DeleteCompanyCodeCommand() { try { int i = 0; int ii = 0; for (int j = SelectedCompanyCodeList.Count - 1; j >= 0; j--) { CompanyCode item = (CompanyCode)SelectedCompanyCodeList[j]; //get Max Index... i = CompanyCodeList.IndexOf(item); if (i > ii) { ii = i; } Delete(item); CompanyCodeList.Remove(item); } if (CompanyCodeList != null && CompanyCodeList.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 >= CompanyCodeList.Count()) { ii = CompanyCodeList.Count - 1; } SelectedCompanyCode = CompanyCodeList[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 the item to 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("CompanyCode/s Can Not Be Deleted. Contact XERP Admin For More Details."); Refresh(); } }
public async Task <CompanyCode> AddCompanyCode(CompanyCode code) { var result = await _context.CompanyCodes.AddAsync(code); await _context.SaveChangesAsync(); return(result.Entity); }
private BindingList <CompanyCode> GetCompanyCodes(CompanyCode item) { BindingList <CompanyCode> itemList = new BindingList <CompanyCode>(_serviceAgent.GetCompanyCodes(item).ToList()); Dirty = false; AllowCommit = false; return(itemList); }
public override int GetHashCode() { int hashCode = 13; hashCode = (hashCode * 7) + CompanyID.GetHashCode(); hashCode = (hashCode * 7) + CompanyCode.GetHashCode(); return(hashCode); }
/// <summary> /// Получение хэша для группировки допуслуг. /// Группировка производится относительноп пассажира и данных допуслуги /// </summary> /// <returns>Хэш группировки</returns> public int ComputeGroupingHashCode() { // Если в клиентском коде не была указана ссылка на пассажира, заваливаем вычесление // т.к. без указания ссылки на пассажира хэш не будет валидным if (TravellerRef.Count == 0) { throw new ArgumentException("TravellerRef"); } if (Name == null) { throw new ArgumentException("Name"); } if (RFIC == null) { throw new ArgumentException("RFIC"); } if (RFISC == null) { throw new ArgumentException("RFISC"); } if (CompanyCode == null) { throw new ArgumentException("CompanyCode"); } unchecked { var hash = TravellerRef[0] + Name.GetHashCode() + RFIC.GetHashCode() + RFISC.GetHashCode() + IsFree.GetHashCode() + Status.GetHashCode() + CompanyCode.GetHashCode(); if (SSRCode != null) { hash += SSRCode.GetHashCode(); } if (SSRText != null) { hash += SSRText.GetHashCode(); } if (TypeCode != null) { hash += TypeCode.GetHashCode(); } return(hash); } }
/// <summary> /// Returns true if InventoryOrderAssetPutResource instances are equal /// </summary> /// <param name="other">Instance of InventoryOrderAssetPutResource to be compared</param> /// <returns>Boolean</returns> public bool Equals(InventoryOrderAssetPutResource other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( AssetNumber == other.AssetNumber || AssetNumber != null && AssetNumber.Equals(other.AssetNumber) ) && ( SubNumber == other.SubNumber || SubNumber != null && SubNumber.Equals(other.SubNumber) ) && ( CompanyCode == other.CompanyCode || CompanyCode != null && CompanyCode.Equals(other.CompanyCode) ) && ( Status == other.Status || Status != null && Status.Equals(other.Status) ) && ( Checked == other.Checked || Checked != null && Checked.Equals(other.Checked) ) && ( CommentCostCenter == other.CommentCostCenter || CommentCostCenter != null && CommentCostCenter.Equals(other.CommentCostCenter) ) && ( CommentLocation == other.CommentLocation || CommentLocation != null && CommentLocation.Equals(other.CommentLocation) ) && ( CommentOther == other.CommentOther || CommentOther != null && CommentOther.Equals(other.CommentOther) ) && ( CommentPlant == other.CommentPlant || CommentPlant != null && CommentPlant.Equals(other.CommentPlant) )); }
public static void SetPropertyValue(this CompanyCode myObj, object propertyName, object propertyValue) { var propInfo = typeof(CompanyCode).GetProperty((string)propertyName); if (propInfo != null) { propInfo.SetValue(myObj, propertyValue, null); } }
private void SetAsEmptySelection() { SelectedCompanyCode = new CompanyCode(); AllowEdit = false; AllowDelete = false; Dirty = false; AllowCommit = false; AllowRowCopy = false; }
public void UpdateRepository(CompanyCode itemCode) { if (_repositoryContext.GetEntityDescriptor(itemCode) != null) { itemCode.LastModifiedBy = XERP.Client.ClientSessionSingleton.Instance.SystemUserID; itemCode.LastModifiedByDate = DateTime.Now; _repositoryContext.MergeOption = MergeOption.AppendOnly; _repositoryContext.UpdateObject(itemCode); } }
public EntityStates GetCompanyCodeEntityState(CompanyCode itemCode) { if (_repositoryContext.GetEntityDescriptor(itemCode) != null) { return(_repositoryContext.GetEntityDescriptor(itemCode).State); } else { return(EntityStates.Detached); } }
public void OnChangeCompanyCodes(CompanyCode itemCode, UpdateOperations operations) { if (operations == UpdateOperations.Delete) {//update a null to any place the Code was used by its parent record... XERP.Server.DAL.CompanyDAL.DALUtility dalUtility = new DALUtility(); var context = new CompanyEntities(dalUtility.EntityConectionString); context.Companies.MergeOption = System.Data.Objects.MergeOption.NoTracking; string codeID = itemCode.CompanyCodeID; string sqlstring = "UPDATE Companies SET CompanyCodeID = null Where CompanyCodeID = '" + codeID + "'"; context.ExecuteStoreCommand(sqlstring); } }
public static string GetPropertyType(this CompanyCode myObj, string propertyName) { var propInfo = typeof(CompanyCode).GetProperty(propertyName); if (propInfo != null) { return(propInfo.PropertyType.Name.ToString()); } else { return(null); } }
public static object GetPropertyValue(this CompanyCode myObj, string propertyName) { var propInfo = typeof(CompanyCode).GetProperty(propertyName); if (propInfo != null) { return(propInfo.GetValue(myObj, null)); } else { return(string.Empty); } }
//udpate merely updates the repository a commit is required //to commit it to the db... private bool Update(CompanyCode item) { _serviceAgent.UpdateCompanyCodeRepository(item); Dirty = true; if (CommitIsAllowed()) { AllowCommit = true; } else { AllowCommit = false; } return(AllowCommit); }
public async Task <CompanyCode> UpdateCompanyCode(CompanyCode code) { var result = await _context.CompanyCodes.FirstOrDefaultAsync(s => s.Id == code.Id); if (result != null) { result.Code = code.Code; await _context.SaveChangesAsync(); return(result); } return(null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //项目下拉框 DataTable dt = CompanyBusiness.GetCompanyProjects(CompanyCode.ToString()); ControlHelper.BindListControl(ddlProject, dt, "PROJECTNAME", "PROJECTID"); if (ProjectId > 0) { ControlHelper.SelectFlg(ddlProject, ProjectId.ToString()); } lblProject.Visible = ddlProject.Visible = (dt != null && dt.Rows.Count > 0 && ProjectId == 0); BindData(0); } }
private bool NewCompanyCode(string itemID) { CompanyCode newItem = new CompanyCode(); _newCompanyCodeAutoId = _newCompanyCodeAutoId - 1; newItem.AutoID = _newCompanyCodeAutoId; newItem.CompanyCodeID = itemID; newItem.IsValid = 1; newItem.NotValidMessage = "New Record Key Field/s Are Required."; CompanyCodeList.Add(newItem); _serviceAgent.AddToCompanyCodeRepository(newItem); SelectedCompanyCode = CompanyCodeList.LastOrDefault(); AllowEdit = true; Dirty = false; return(true); }
public bool SerializeToPRM(string prm_path) { using (st = System.IO.File.OpenWrite(prm_path)) { WriteToPRM("DocType", DocType); WriteToPRM("Sender", Sender); WriteToPRM("Receiver", Receiver); //WriteToPRM("MsgDateTime", MsgDateTime.ToShortDateString()); WriteToPRM("MsgDate", MsgDate); WriteToPRM("MsgTime", MsgTime); WriteToPRM("InvoiceType", InvoiceType); WriteToPRM("InvoiceNumber", InvoiceNumber); WriteToPRM("SupplierName", SupplierName); WriteToPRM("DiscountAmount", DiscountAmount); WriteToPRM("CompanyCode", CompanyCode.ToString()); WriteToPRM("InvoiceDate", InvoiceDate.ToShortDateString()); WriteToPRM("ExchangeRate", ExchangeRate.ToString()); WriteToPRM("Currentcy", Currentcy); WriteToPRM("TaxInvoice", TaxInvoice); WriteToPRM("DocumentInvoiceType", DocumentInvoiceType); WriteToPRM("SupplierPrivateCompanyCode", SupplierPrivateCompanyCode); WriteToPRM("RetailerPrivateCompanyCode", RetailerPrivateCompanyCode); WriteToPRM("CurrencyDocumentSum", CurrencyDocumentSum.ToString()); WriteToPRM("DocumentSum", DocumentSum.ToString()); WriteToPRM("TaxSum", TaxSum.ToString()); WriteToPRM("TaxSumNIS", TaxSumNIS.ToString()); WriteToPRM("CurrencyRate", CurrencyRate.ToString()); WriteToPRM("TaxRate", TaxRate); WriteToPRM("CompanyName", CompanyName); WriteToPRM("Address", Address); WriteToPRM("City", City); WriteToPRM("State", State); WriteToPRM("Country", Country); WriteToPRM("POB", POB); WriteToPRM("Zipcode", Zipcode); WriteToPRM("Bank", Bank); WriteToPRM("Account", Account); WriteToPRM("Details", Details); WriteToPRM("TotalLines", TotalLines.ToString()); foreach (InvoiceLine line in Lines) { WriteToPRM(line); } } return(true); }
public async Task <ActionResult <CompanyCode> > CreateCompanyCode(CompanyCode code) { try { if (code == null) { return(BadRequest()); } var createdCode = await _codeRepository.AddCompanyCode(code); return(createdCode); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error retrieving data from the database.")); } }
void XF_CompanyFinder_Load(object sender, EventArgs e) { if (!IsFinder) { laySelect.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; } else { menuNewCompany.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; col_Edit.Visible = false; } this.DbContext = DB.GetContext(); LoadDefaults(); LoadData(); CompanyCode.Select(); }
public CodeSearchViewModel(ICompanyServiceAgent serviceAgent) { this._serviceAgent = serviceAgent; SearchObject = new CompanyCode(); ResultList = new BindingList <CompanyCode>(); SelectedList = new BindingList <CompanyCode>(); //make sure of session authentication... if (XERP.Client.ClientSessionSingleton.Instance.SessionIsAuthentic)//make sure user has rights to UI... { DoFormsAuthentication(); } else {//User is not authenticated... RegisterToReceiveMessages <bool>(MessageTokens.StartUpLogInToken.ToString(), OnStartUpLogIn); FormIsEnabled = false; //we will do forms authentication once the log in returns a valid System User... } }