public void PasteRowCommand()
        {
            try
            {
                CompanyColumnMetaDataList.Sort(delegate(ColumnMetaData c1, ColumnMetaData c2)
                                               { return(c1.Order.CompareTo(c2.Order)); });

                char[] rowSplitter    = { '\r', '\n' };
                char[] columnSplitter = { '\t' };
                //get the text from clipboard
                IDataObject dataInClipboard   = Clipboard.GetDataObject();
                string      stringInClipboard = (string)dataInClipboard.GetData(DataFormats.Text);
                //split it into rows...
                string[] rowsInClipboard = stringInClipboard.Split(rowSplitter, StringSplitOptions.RemoveEmptyEntries);

                foreach (string row in rowsInClipboard)
                {
                    NewCompanyCommand(); //this will generate a new item and set it as the selected item...
                    //split row into cell values
                    string[] valuesInRow = row.Split(columnSplitter);
                    int      i           = 0;
                    foreach (string columnValue in valuesInRow)
                    {
                        SelectedCompany.SetPropertyValue(CompanyColumnMetaDataList[i].Name, columnValue);
                        i++;
                    }
                }
            }
            catch (Exception ex)
            {
                NotifyMessage(ex.InnerException.ToString());
            }
        }
示例#2
0
 public override void AttachListeners()
 {
     //if (HasProductCompany)
     if (SelectedCompany != null)
     {
         SelectedCompany.AddTeamListener(this);
     }
 }
        private void SelectedCompany_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {//these properties are not to be persisted or autochanged fields we will igore them...
            if (e.PropertyName == "IsSelected" ||
                e.PropertyName == "IsExpanded" ||
                e.PropertyName == "IsValid" ||
                e.PropertyName == "NotValidMessage" ||
                e.PropertyName == "LastModifiedBy" ||
                e.PropertyName == "LastModifiedByDate")
            {
                return;
            }
            //Key ID Logic...
            if (e.PropertyName == "CompanyID")
            {     //make sure it is has changed...
                if (SelectedCompanyMirror.CompanyID != SelectedCompany.CompanyID)
                { //if their are no records it is a key change
                    if (CompanyList != null && CompanyList.Count == 0 &&
                        SelectedCompany != null && !string.IsNullOrEmpty(SelectedCompany.CompanyID))
                    {
                        ChangeKeyLogic();
                        return;
                    }

                    EntityStates entityState = GetCompanyState(SelectedCompany);

                    if (entityState == EntityStates.Unchanged ||
                        entityState == EntityStates.Modified)
                    {                             //once a key is added it can not be modified...
                        if (Dirty && AllowCommit) //dirty record exists ask if save is required...
                        {
                            NotifySaveRequired("Do you want to save changes?", _saveRequiredResultActions.ChangeKeyLogic);
                        }
                        else
                        {
                            ChangeKeyLogic();
                        }

                        return;
                    }
                }
            }//end KeyID logic...

            object propertyChangedValue = SelectedCompany.GetPropertyValue(e.PropertyName);
            object prevPropertyValue    = SelectedCompanyMirror.GetPropertyValue(e.PropertyName);
            string propertyType         = SelectedCompany.GetPropertyType(e.PropertyName);
            //in some instances the value is not really changing but yet it still is tripping property change..
            //This will ensure that the field has physically been modified...
            //As well when we revert back it constitutes a property change but they will be = and it will bypass the logic...
            bool objectsAreEqual;

            if (propertyChangedValue == null)
            {
                if (prevPropertyValue == null)//both values are null
                {
                    objectsAreEqual = true;
                }
                else//only one value is null
                {
                    objectsAreEqual = false;
                }
            }
            else
            {
                if (prevPropertyValue == null)//only one value is null
                {
                    objectsAreEqual = false;
                }
                else //both values are not null use .Equals...
                {
                    objectsAreEqual = propertyChangedValue.Equals(prevPropertyValue);
                }
            }
            if (!objectsAreEqual)
            {
                //Here we do property change validation if false is returned we will reset the value
                //Back to its mirrored value and return out of the property change w/o updating the repository...
                if (CompanyPropertyChangeIsValid(e.PropertyName, propertyChangedValue, prevPropertyValue, propertyType))
                {
                    Update(SelectedCompany);
                    SelectedCompanyMirror.SetPropertyValue(e.PropertyName, propertyChangedValue);
                    SelectedCompanyMirror.IsValid         = SelectedCompany.IsValid;
                    SelectedCompanyMirror.IsExpanded      = SelectedCompany.IsExpanded;
                    SelectedCompanyMirror.NotValidMessage = SelectedCompany.NotValidMessage;
                }
                else
                {//revert back to its previous value...
                    SelectedCompany.SetPropertyValue(e.PropertyName, prevPropertyValue);
                    SelectedCompany.IsValid         = SelectedCompanyMirror.IsValid;
                    SelectedCompany.IsExpanded      = SelectedCompanyMirror.IsExpanded;
                    SelectedCompany.NotValidMessage = SelectedCompanyMirror.NotValidMessage;
                }
            }
        }
示例#4
0
        private async Task OnSelectedCompanyChanged()
        {
            IsLoading = true;
            try
            {
                using (var client = new HttpClient())
                {
                    client.DefaultRequestHeaders.Add("Accept", "application/json");
                    var url      = string.Format(AZURE_FUNCTION_URI + "&company={0}", SelectedCompany.ToLower());
                    var response = await client.GetAsync(url);

                    var json = await response.Content.ReadAsStringAsync();

                    var addresses = JsonConvert.DeserializeObject <IEnumerable <Address> >(json);

                    Addresses = addresses;
                }
            }
            catch (Exception)
            {
                //Going to ignore it for now
            }
            finally
            {
                IsLoading = false;
            }
        }