Exemplo n.º 1
0
        private void Refresh(bool fromServer)
        {
            string originalStatus = Status;

            try
            {
                if ((_unsavedChanges) && (fromServer) &&
                    (UIHelper.AskQuestion("There are unsaved changes. Are you sure you want to refresh from server. All unsaved changes will be lost.") !=
                     DialogResult.Yes))
                {
                    return;
                }
                using (WaitCursor w = new WaitCursor())
                {
                    if (fromServer)
                    {
                        Status = "Refreshing from server ...";
                        if (_customerCache.RefreshFromServer())
                        {
                            return;
                        }
                        _unsavedChanges = false;
                    }
                    int index = UIHelper.GetSelectedGridRowIndex(grdCustomers);
                    Dictionary <string, object> properties = new Dictionary <string, object>();
                    properties.Add(EntityReader <Customer> .GetPropertyName(p => p.CompanyName, false), txtCompanyName.Text);
                    grdCustomers.DataSource = _customerCache.GetDataTable(properties, false, true);
                    _hiddenColumns.ForEach(p => grdCustomers.Columns[p].Visible = false);
                    UIHelper.SelectGridRow(grdCustomers, index);
                }
            }
            finally
            {
                if (Status != originalStatus)
                {
                    Status = originalStatus;
                }
            }
        }