Beispiel #1
0
        private async void Dg_packageUser_SelectionChanged(object sender, SelectionChangedEventArgs e)
        { //selection
            try
            {
                HelpClass.StartAwait(grid_main);

                if (dg_packageUser.SelectedIndex != -1)
                {
                    packageUser      = dg_packageUser.SelectedItem as PackageUser;
                    this.DataContext = packageUser;

                    if (packageUser != null)
                    {
                        Packages packageModel = new Packages();
                        Packages package      = await packageModel.GetByID(packageUser.packageId.Value);
                    }
                }

                clearValidate();
                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
Beispiel #2
0
        private async void Btn_download_Click(object sender, RoutedEventArgs e)
        {//download
            try
            {
                HelpClass.StartAwait(grid_main);

                HelpClass.validateWindow(requiredControlList, this);
                if (cb_type.SelectedIndex != -1)
                {
                    //string activeState = "rn";//rn OR up  from buton
                    string activeState = cb_type.SelectedValue.ToString();

                    PackageUser pumodel = new PackageUser();
                    ReportCls   rc      = new ReportCls();
                    SendDetail  sd      = new SendDetail();
                    sd = await pumodel.ActivateServerOffline(packageUser.packageUserId, activeState);

                    packagesSend packtemp = new packagesSend();
                    if (sd.packageSend.result > 0)
                    {
                        //encode
                        string myContent = JsonConvert.SerializeObject(sd);

                        saveFileDialog.Filter = "File|*.ac;";
                        if (saveFileDialog.ShowDialog() == true)
                        {
                            string DestPath = saveFileDialog.FileName;

                            bool res = false;

                            res = rc.encodestring(myContent, DestPath);
                            // rc.DelFile(pdfpath);
                            //  rc.decodefile(DestPath,@"D:\stringlist.txt");
                            if (res)
                            {
                                //done
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopSave"), animation: ToasterAnimation.FadeIn);
                            }
                            else
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                            }
                        }
                    }
                    else
                    {
                        //error
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                    }

                    HelpClass.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
Beispiel #3
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {//load
            try
            {
                HelpClass.StartAwait(grid_main);
                btns = new Button[] { btn_firstPage, btn_prevPage, btn_activePage, btn_nextPage, btn_lastPage };

                #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;
                }
                translat();
                #endregion

                #region fill page count combo
                var typelist = new[] {
                    new { Text = "20", Value = "20" },
                    new { Text = "50", Value = "50" },
                    new { Text = "100", Value = "100" }
                };
                cb_itemPerPage.DisplayMemberPath = "Text";
                cb_itemPerPage.SelectedValuePath = "Value";
                cb_itemPerPage.ItemsSource       = typelist;
                #endregion

                chk_allSerials.IsChecked = false;
                posSerialsQuery          = await RefreshList();

                isActiveCount = posSerials.Count(s => s.isActive == 1);

                pu = await puModel.GetByID(packageUserID);

                p = await pModel.GetByID(pu.packageId.Value);

                cb_itemPerPage.SelectedIndex = 0;

                Tb_search_TextChanged(tb_search, null);

                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
        private async void Dg_book_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                //HelpClass.StartAwait(grid_main);

                BookSts book = dg_book.SelectedItem as BookSts;
                if (book.packageUserId > 0)
                {
                    PackageUser puModel     = new PackageUser();
                    PackageUser packageUser = await puModel.GetByID(book.packageUserId);

                    Packages pModel  = new Packages();
                    Packages package = await pModel.GetByID(book.packageId.Value);

                    if (packageUser.packageId > 0)
                    {
                        MainWindow.mainWindow.Btn_sales_Click(MainWindow.mainWindow.btn_sales, null);
                        uc_sales.Instance.Window_Loaded(null, null);
                        uc_sales.Instance.Btn_sale_Click(uc_sales.Instance.btn_sale, null);
                        uc_sale.Instance.UserControl_Loaded(null, null);
                        uc_sale.Instance.package = package;

                        uc_sale.Instance.oldCustomerId          = packageUser.customerId.Value;
                        uc_sale.Instance.oldAgentId             = packageUser.userId.Value;
                        uc_sale.Instance.oldPackageId           = packageUser.packageId.Value;
                        uc_sale.Instance.oldCountryPackageId    = packageUser.countryPackageId.Value;
                        uc_sale.Instance.packuser               = packageUser;
                        uc_sale.Instance.btn_serials.IsEnabled  = true;
                        uc_sale.Instance.tb_activationCode.Text = packageUser.packageSaleCode;
                        uc_sale.Instance.isOnline               = packageUser.isOnlineServer.Value;
                        HelpClass.clearValidate(uc_sale.requiredControlList, this);
                    }
                }
                //Clear();
                //ClearPackageUser();

                //HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                //HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
Beispiel #5
0
        public async Task <string> BuildReport()
        {
            //string firstTitle = "paymentsReport";
            ////string secondTitle = "";
            ////string subTitle = "";
            //string Title = "";

            List <ReportParameter> paramarr = new List <ReportParameter>();
            List <PackageUser>     purl     = new List <PackageUser>();

            packUserRep = await packUserRep.GetByID(packuser.packageUserId);
            await getdata();

            if (PayOpModel.payOpId <= 0)
            {
                return("0");//not pay yet
            }
            else
            {
                string addpath;
                bool   isArabic = ReportCls.checkLang();
                if (isArabic)
                {
                    addpath = @"\Reports\Sale\Book\Ar\ArBook.rdlc";
                }
                else
                {
                    addpath = @"\Reports\Sale\Book\En\EnBook.rdlc";
                }
                //D:\myproj\posproject3\AdministratorApp\AdministratorApp\Reports\Sale\Book\En\EnBook.rdlc
                string reppath = reportclass.PathUp(Directory.GetCurrentDirectory(), 2, addpath);
                //     subTitle = clsReports.ReportTabTitle(firstTitle, secondTitle);
                //  Title = MainWindow.resourcemanagerreport.GetString("trAccountantReport");


                clsReports.setReportLanguage(paramarr);
                clsReports.Header(paramarr);
                SetReportparam(paramarr);
                clsReports.BookSale(purl, rep, reppath, paramarr);
                rep.SetParameters(paramarr);

                rep.Refresh();
                return("1");
            }
        }
        private async void Dg_book_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                // HelpClass.StartAwait(grid_main);

                PaymentsSts payment = dg_book.SelectedItem as PaymentsSts;
                if (payment.packageUserId > 0)
                {
                    PackageUser puModel     = new PackageUser();
                    PackageUser packageUser = await puModel.GetByID(payment.packageUserId);

                    Packages pModel  = new Packages();
                    Packages package = await pModel.GetByID(payment.packageId.Value);

                    if (packageUser.packageId > 0)
                    {
                        uc_sales.Instance.isPayment     = true;
                        uc_payment.Instance.isFirstTime = false;
                        MainWindow.mainWindow.Btn_sales_Click(MainWindow.mainWindow.btn_sales, null);
                        uc_sales.Instance.Window_Loaded(null, null);
                        uc_sales.Instance.Btn_packageUser_Click(uc_sales.Instance.btn_packageUser, null);
                        uc_payment.Instance.cusID      = payment.customerId.Value;
                        uc_payment.Instance.packuserID = payment.packageUserId;
                        uc_payment.Instance.discount_  = payment.discountValue;
                        uc_payment.Instance.UserControl_Loaded(null, null);
                    }
                }
                //Clear();
                //ClearPackageUser();

                //HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                //HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
Beispiel #7
0
        private async void Btn_exportToExcel_Click(object sender, RoutedEventArgs e)
        {//excel
            try
            {
                HelpClass.StartAwait(grid_main);

                PackageUser puModel = new PackageUser();
                PackageUser pu      = await puModel.GetByID(packageUserID);

                string customer = pu.customerName + " " + pu.customerLastName;
                string package  = pu.packageName;
                string key      = pu.packageSaleCode;
                string agent    = pu.userName + " " + pu.userLastName;
                string s        = "";
                #region
                Thread t1 = new Thread(() =>
                {
                    BuildReport();
                    this.Dispatcher.Invoke(() =>
                    {
                        saveFileDialog.Filter = "EXCEL|*.xls;";
                        if (saveFileDialog.ShowDialog() == true)
                        {
                            string filepath = saveFileDialog.FileName;
                            LocalReportExtensions.ExportToExcel(rep, filepath);
                        }
                    });
                });
                t1.Start();
                #endregion

                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
Beispiel #8
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {//load
            try
            {
                HelpClass.StartAwait(grid_main);

                requiredControlList = new List <string> {
                    "type"
                };

                #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;
                }
                translat();
                #endregion

                PackageUser pu = packageUser;

                FillCombo.fillOfflineActivation(cb_type);

                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
Beispiel #9
0
        //async Task<IEnumerable<Packages>> RefreshPackagesList()
        //{
        //    packages = await package.GetAll();
        //    return packages;
        //}
        #endregion

        #region validate - clearValidate - textChange - lostFocus - . . . .
        void Clear()
        {
            try
            {
                this.DataContext = new Packages();
            }
            catch { }
            packuser = new PackageUser();
            cb_customer.SelectedIndex = -1;
            cb_isOnline.SelectedIndex = -1;
            cb_package.ItemsSource    = null;
            cb_period.ItemsSource     = null;
            tgl_device.IsChecked      = false;
            tgl_isActive.IsChecked    = true;
            oldPackageId           = 0;
            oldCountryPackageId    = 0;
            cb_package.IsEnabled   = false;
            cb_period.IsEnabled    = false;
            btn_serials.IsEnabled  = false;
            tb_activationCode.Text = "";
            txt_date.Text          = "";
            btn_add.Content        = MainWindow.resourcemanager.GetString("trBook");
            HelpClass.clearValidate(requiredControlList, this);
        }
Beispiel #10
0
        //ReportCls reportclass = new ReportCls();

        public async void  BuildReport()
        {
            List <ReportParameter> paramarr = new List <ReportParameter>();

            string addpath     = "";
            string firstTitle  = "Serials";
            string secondTitle = "";
            string subTitle    = "";
            string Title       = "";

            bool isArabic = ReportCls.checkLang();

            //if (isArabic)
            //{
            //addpath = @"\Reports\StatisticReport\Accounts\Paymetns\Ar\ArVendor.rdlc";
            //secondTitle = "vendors";
            //}
            //else
            //{
            //addpath = @"\Reports\StatisticReport\Accounts\Paymetns\En\Vendor.rdlc";
            //secondTitle = "vendors";
            //}
            addpath = @"\Reports\Sale\Book\Serials\En\serials.rdlc";

            string      reppath = reportclass.PathUp(Directory.GetCurrentDirectory(), 2, addpath);
            PackageUser puModel = new PackageUser();
            Customers   cuModel = new Customers();
            Users       agModel = new Users();

            puModel = await puModel.GetByID(packageUserID);

            cuModel = await cuModel.GetByID((int)puModel.customerId);

            agModel = await agModel.GetByID((int)puModel.userId);

            string serkey    = puModel.packageSaleCode;
            string agentname = "";

            if (agModel.userId == 3)
            {
                agentname = "Increase";
            }
            else
            {
                agentname = agModel.name + " " + agModel.lastName;
            }



            //ReportCls.checkLang();
            //subTitle = clsReports.ReportTabTitle(firstTitle, secondTitle);
            Title = "Serials";
            paramarr.Add(new ReportParameter("trTitle", Title));

            paramarr.Add(new ReportParameter("Agent", agentname));
            paramarr.Add(new ReportParameter("Customer", cuModel.custname + " " + cuModel.lastName));
            paramarr.Add(new ReportParameter("serverKey", serkey));

            List <PosSerials> repserialList = new List <PosSerials>();

            repserialList = await posSerialModel.GetByPackUserId(packageUserID);

            clsReports.serialsReport(repserialList.Where(s => s.isActive == 1), rep, reppath, paramarr);
            //clsReports.setReportLanguage(paramarr);
            //clsReports.Header(paramarr);

            rep.SetParameters(paramarr);

            rep.Refresh();
        }
Beispiel #11
0
        private async void Btn_upload_Click(object sender, RoutedEventArgs e)
        {//upload
            try
            {
                HelpClass.StartAwait(grid_main);

                HelpClass.validateWindow(requiredControlList, this);
                if (cb_type.SelectedIndex != -1)
                {
                    PackageUser pumodel = new PackageUser();
                    //activeState = "up";
                    activeState = cb_type.SelectedValue.ToString();

                    if (activeState == "up")
                    {
                        string filepath = "";
                        openFileDialog.Filter = "INC|*.ac; ";

                        if (openFileDialog.ShowDialog() == true)
                        {
                            filepath = openFileDialog.FileName;

                            // bool resr = ReportCls.decodefile(filepath, @"D:\stringlist.txt");//comment
                            SendDetail dc        = new SendDetail();
                            string     objectstr = "";

                            objectstr = ReportCls.decodetoString(filepath);

                            dc = JsonConvert.DeserializeObject <SendDetail>(objectstr, new JsonSerializerSettings {
                                DateParseHandling = DateParseHandling.None
                            });

                            if (dc.packageSend.packageUserId == packageUser.packageUserId)
                            {
                                int res = await pumodel.updatecustomerdata(dc, activeState);

                                //   MessageBox.Show(res.ToString());
                                if (res > 0)
                                {
                                    if (res == 1)
                                    {
                                        // update done
                                        Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trRestoreDoneSuccessfuly"), animation: ToasterAnimation.FadeIn);
                                    }
                                    //else if (res == 2)
                                    //{
                                    //    //no update
                                    //    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trRestoreNotComplete"), animation: ToasterAnimation.FadeIn);
                                    //}
                                }
                                else
                                {
                                    // error
                                    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trRestoreNotComplete"), animation: ToasterAnimation.FadeIn);
                                }
                            }
                            else
                            {
                                // The File dosn't belong to this Package
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trRestoreNotComplete") + "The File dosn't belong to this Package", animation: ToasterAnimation.FadeIn);
                            }
                        }
                        else
                        {
                            // error
                            Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trRestoreNotComplete"), animation: ToasterAnimation.FadeIn);
                        }
                    }
                }
                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }