private async void Cb_agents_SelectionChanged(object sender, SelectionChangedEventArgs e) {//select agent try { if (cb_agents.SelectedIndex != -1) { dpnl_customer.IsEnabled = true; if ((int)cb_agents.SelectedValue == 3) { await FillCombo.fillCustomer(cb_customers); } else { await FillCombo.fillCustomerByAgent(cb_customers, (int)cb_agents.SelectedValue); } } else { dpnl_customer.IsEnabled = false; cb_customers.SelectedIndex = -1; } await Search(); } catch (Exception ex) { HelpClass.ExceptionMessage(ex, this); } }
private async void Btn_updateCustomer_Click(object sender, RoutedEventArgs e) {//update customer try { Window.GetWindow(this).Opacity = 0.2; wd_newCustomer w = new wd_newCustomer(); if (cb_customer.SelectedItem != null) { w.customerID = (int)cb_customer.SelectedValue; } else { w.customerID = 0; } w.ShowDialog(); Window.GetWindow(this).Opacity = 1; if (w.isOk) { await FillCombo.fillCustomer(cb_customer); cb_customer.SelectedValue = w.customerID; } } catch (Exception ex) { HelpClass.ExceptionMessage(ex, this); } }
private async void UserControl_Loaded(object sender, RoutedEventArgs e) {//load try { HelpClass.StartAwait(grid_main); requiredControlList = new List <string> { "" }; if (MainWindow.lang.Equals("en")) { MainWindow.resourcemanager = new ResourceManager("AdministratorApp.en_file", Assembly.GetExecutingAssembly()); grid_main.FlowDirection = FlowDirection.LeftToRight; } else { MainWindow.resourcemanager = new ResourceManager("AdministratorApp.ar_file", Assembly.GetExecutingAssembly()); grid_main.FlowDirection = FlowDirection.RightToLeft; } translate(); await FillCombo.fillAgent(cb_agent); await FillCombo.fillCustomer(cb_customer); //Keyboard.Focus(tb_code); await Search(); Clear(); HelpClass.EndAwait(grid_main); } catch (Exception ex) { HelpClass.EndAwait(grid_main); HelpClass.ExceptionMessage(ex, this); } }
public async void UserControl_Loaded(object sender, RoutedEventArgs e) {//load try { if (sender != null) { HelpClass.StartAwait(grid_main); } package = new Packages(); this.DataContext = package; #region translate if (MainWindow.lang.Equals("en")) { MainWindow.resourcemanager = new ResourceManager("AdministratorApp.en_file", Assembly.GetExecutingAssembly()); grid_main.FlowDirection = FlowDirection.LeftToRight; } else { MainWindow.resourcemanager = new ResourceManager("AdministratorApp.ar_file", Assembly.GetExecutingAssembly()); grid_main.FlowDirection = FlowDirection.RightToLeft; } translate(); #endregion requiredControlList = new List <string> { "package", "customer", "isOnline", "period" }; FillCombo.fillServerState(cb_isOnline); if (MainWindow.userLogin.type.Equals("ag")) { try { await FillCombo.fillCustomerByAgent(cb_customer, MainWindow.userLogin.userId); } catch { await FillCombo.fillCustomerByAgent(cb_customer, MainWindow.userLogin.userId); } try { agent = await userModel.GetByID(MainWindow.userLogin.userId); } catch { agent = await userModel.GetByID(MainWindow.userLogin.userId); } await FillCombo.fillAgentPackage(cb_package, MainWindow.userLogin.userId); cb_package.IsEnabled = true; } else { try { await FillCombo.fillCustomer(cb_customer); } catch { await FillCombo.fillCustomer(cb_customer); } try { agent = await userModel.GetByID(3); } catch { agent = await userModel.GetByID(3); } cb_agent.Visibility = Visibility.Collapsed; } if (oldPackageId == 0) { Clear(); btn_add.Content = MainWindow.resourcemanager.GetString("trBook"); } else { #region expired date string color = "#2491EA"; if (packuser.expireDate.Value < DateTime.Now) { color = "#FF0000"; } txt_date.Text = HelpClass.setDateFormat(packuser.expireDate.Value); txt_date.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(color)); #endregion btn_add.Content = MainWindow.resourcemanager.GetString("trUpgrade"); cb_customer.SelectedValue = oldCustomerId; try { agent = await userModel.GetByID(MainWindow.userLogin.userId); } catch { agent = await userModel.GetByID(MainWindow.userLogin.userId); } if (MainWindow.userLogin.type.Equals("ag")) { cb_package.SelectedValue = oldPackageId; cb_period.SelectedValue = oldCountryPackageId; } cb_isOnline.SelectedValue = isOnline; if (isOnline) { txt_offlineActivation.Visibility = Visibility.Collapsed; btn_download.Visibility = Visibility.Collapsed; txt_activationCodeTitle.Visibility = Visibility.Visible; tb_activationCode.Visibility = Visibility.Visible; } else { txt_offlineActivation.Visibility = Visibility.Visible; btn_download.Visibility = Visibility.Visible; txt_activationCodeTitle.Visibility = Visibility.Collapsed; tb_activationCode.Visibility = Visibility.Collapsed; } tgl_isActive.IsChecked = Convert.ToBoolean(packuser.isActive); tgl_device.IsChecked = Convert.ToBoolean(packuser.canChngSer); } cb_agent.Text = agent.name + " " + agent.lastName; if (sender != null) { HelpClass.EndAwait(grid_main); } } catch (Exception ex) { if (sender != null) { HelpClass.EndAwait(grid_main); } HelpClass.ExceptionMessage(ex, this); } }