コード例 #1
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);
            }
        }
コード例 #2
0
        private async void Btn_save_Click(object sender, RoutedEventArgs e)
        {//save
            try
            {
                HelpClass.StartAwait(grid_main);

                countryPackageDate = new CountryPackageDate();

                if (!chkIfExist())
                {
                    if (HelpClass.validateWindow(requiredControlList, this))
                    {
                        countryPackageDate.countryId  = Convert.ToInt32(cb_country.SelectedValue);
                        countryPackageDate.packageId  = packageID;
                        countryPackageDate.monthCount = Convert.ToInt32(cb_month.SelectedValue);
                        countryPackageDate.price      = decimal.Parse(tb_price.Text);
                        if (Convert.ToInt32(cb_month.SelectedValue) == 0)
                        {
                            countryPackageDate.islimitDate = false;
                        }
                        else
                        {
                            countryPackageDate.islimitDate = true;
                        }
                        countryPackageDate.notes        = tb_notes.Text;
                        countryPackageDate.isActive     = 1;
                        countryPackageDate.createUserId = MainWindow.userLogin.userId;
                        countryPackageDate.updateUserId = MainWindow.userLogin.userId;

                        int s = await countryPackageDateModel.Save(countryPackageDate);

                        if (s <= 0)
                        {
                            Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                        }
                        else
                        {
                            Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopAdd"), animation: ToasterAnimation.FadeIn);

                            Clear();
                            await RefreshCountryPackageDateList();
                            await Search();
                        }
                    }
                }
                else
                {
                    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopAlreadyExist"), animation: ToasterAnimation.FadeIn);
                }
                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }
コード例 #3
0
 private void validate()
 {
     try
     {
         HelpClass.validateWindow(requiredControlList, this);
     }
     catch (Exception ex)
     {
         HelpClass.ExceptionMessage(ex, this);
     }
 }
コード例 #4
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);
            }
        }
コード例 #5
0
        private async void Btn_save_Click(object sender, RoutedEventArgs e)
        {//save
            try
            {
                HelpClass.StartAwait(grid_main);
                if (HelpClass.validateWindow(requiredControlList, this) && HelpClass.IsValidEmailWindow(this))
                {
                    tb_custCode.Text = await HelpClass.generateRandomString(5, "", "Customers", customerID);

                    customer.custCode  = tb_custCode.Text;
                    customer.custname  = tb_custname.Text;
                    customer.lastName  = tb_lastName.Text;
                    customer.countryId = Convert.ToInt32(cb_country.SelectedValue);
                    customer.email     = tb_email.Text;
                    customer.mobile    = cb_areaMobile.Text + "-" + tb_mobile.Text;
                    if (!tb_phone.Text.Equals(""))
                    {
                        customer.phone = cb_areaPhone.Text + "-" + cb_areaPhoneLocal.Text + "-" + tb_phone.Text;
                    }
                    if (!tb_fax.Text.Equals(""))
                    {
                        customer.fax = cb_areaFax.Text + "-" + cb_areaFaxLocal.Text + "-" + tb_fax.Text;
                    }
                    if (cb_custlevel.SelectedValue != null)
                    {
                        customer.custlevel = cb_custlevel.SelectedValue.ToString();
                    }
                    customer.company      = tb_company.Text;
                    customer.address      = tb_address.Text;
                    customer.notes        = tb_notes.Text;
                    customer.isActive     = 1;
                    customer.createUserId = MainWindow.userLogin.userId;
                    customer.updateUserId = MainWindow.userLogin.userId;

                    int s = await customer.Save(customer);

                    if (s <= 0)
                    {
                        Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                    }
                    else
                    {
                        Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopSave"), animation: ToasterAnimation.FadeIn);

                        if (isImgPressed)
                        {
                            int    customerId = s;
                            string b          = await customer.uploadImage(imgFileName,
                                                                           Md5Encription.MD5Hash("Inc-m" + customerId.ToString()), customerId);

                            customer.image = b;
                            isImgPressed   = false;
                        }

                        isOk = true;
                        this.Close();
                    }
                }
                HelpClass.EndAwait(grid_main);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }