private void Window_Loaded(object sender, RoutedEventArgs e) { newQuotationData.Update(QuotationData); using (SqlConnection connection = new SqlConnection(Database.ConnectionString)) { string query = $"Select * From [Quotation].[_ProjectsContactsView] Where InquiryId = {newQuotationData.Inquiry.Id}"; projectContacts = new ObservableCollection <Contact>(connection.Query <Contact>(query)); viewProjectContacts = new CollectionViewSource { Source = projectContacts }; ProjectContactsList.ItemsSource = viewProjectContacts.View; query = $"Select * From Customer._Customers Where Id = {newQuotationData.Inquiry.CustomerId}"; customerData = connection.QueryFirstOrDefault <Customer>(query); query = $"Select * From [User].[_Salesmen] Where Id = {newQuotationData.Inquiry.SalesmanId}"; salesmanData = connection.QueryFirstOrDefault <Salesman>(query); query = $"Select * From [User].[_Estimators] Where Id = {newQuotationData.Inquiry.EstimatorId}"; estimatorData = connection.QueryFirstOrDefault <Estimator>(query); query = $"Select * From [Customer].[_Consultants] Where Id = {newQuotationData.Inquiry.ConsultantId}"; consultantData = connection.QueryFirstOrDefault <Consultant>(query); } if (OpenPanelsWindow) { Cancel.Visibility = Visibility.Collapsed; } viewProjectContacts.View.CollectionChanged += new NotifyCollectionChangedEventHandler(CollectionChanged); DataContext = new { newQuotationData, customerData, consultantData, salesmanData, estimatorData }; }
private void Window_Loaded(object sender, RoutedEventArgs e) { newQuotationData = new Quotation(); newQuotationData.Update(QuotationData); DataContext = newQuotationData; if (UserData.QuotationsDiscount == true && QuotationData.Status == Statuses.Running.ToString()) { DiscountInput.IsReadOnly = false; DiscountInput.Focusable = true; DiscountInput.IsHitTestVisible = true; DiscountValueInput.IsReadOnly = false; DiscountValueInput.Focusable = true; DiscountValueInput.IsHitTestVisible = true; Save.Visibility = Visibility.Visible; } }