Beispiel #1
0
        private async void Cb_customer_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {//select customer
            try
            {
                if (cb_customer.SelectedIndex != -1)
                {
                    cb_package.IsEnabled = true;
                    cb_period.IsEnabled  = true;

                    if (MainWindow.userLogin.type != "ag")
                    {
                        try
                        {
                            await FillCombo.fillPackageByCustomer(cb_package, (int)cb_customer.SelectedValue);

                            cb_package.SelectedValue = oldPackageId;
                        }
                        catch { }
                    }
                    else
                    {
                        await FillCombo.fillAgentPackage(cb_package, MainWindow.userLogin.userId);
                    }
                }
            }
            catch (Exception ex)
            {
                HelpClass.ExceptionMessage(ex, this);
            }
        }
Beispiel #2
0
        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);
            }
        }