void InitializeShellMonitor()
        {
            NotifyWindow nw = new NotifyWindow(this);
            uint cookie = 0;
            try
            {
                NativeMethods.SHChangeNotifyEntry what;
                what.pIdl = IntPtr.Zero;
                what.Recursively = true;

                // We are only interested in Shell events. We let VS handle the real filesystem changes

                // TortoiseSVN has to notify the shell for all his updates, and we just listen to what TortoiseSVN sends us :)

                cookie = NativeMethods.SHChangeNotifyRegister(nw.Handle, 0x0002 | 0x8000, NativeMethods.SHCNE.SHCNE_ALLEVENTS, 0xDEDE, 1, ref what);
            }
            catch(Exception e)
            {
                GC.KeepAlive(e);
                if (nw != null)
                {
                    nw.Dispose();
                    nw = null;
                }
            }
            finally
            {
                _notifyWindow = nw;
                _notifyCookie = cookie;
            }
        }
 public void ShowMessage(string message, Action callback = null, string title = null)
 {
     var c = SynchronizationContext.Current;
     var tid = Thread.CurrentThread.ManagedThreadId;
     NotifyWindow notify = new NotifyWindow(message,title);
     if (callback != null)
     {
         notify.TextClicked += (_, __) => callback.Invoke();
     }
     //notify.WaitTime = 6000;
     notify.Notify();
 }
        public bool Init()
        {
            logger.Debug("WTSSessionManager::Init()");

            if (nativeWindow == null)
            {
                nativeWindow = new NotifyWindow(this);
                nativeWindow.CreateWindow();
            }

            var hWnd = nativeWindow.Handle;

            return(RegisterNotification(hWnd));
        }
        public void Close()
        {
            logger.Debug("WTSSessionManager::Close()");

            if (nativeWindow != null)
            {
                var hWnd   = nativeWindow.Handle;
                var result = UnregisterNotification(hWnd);

                nativeWindow.DestroyWindow();

                nativeWindow = null;
            }
        }
Example #5
0
 void OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         using (Stream sf = (Stream)saveFileDialog.OpenFile())
         {
             e.Result.CopyTo(sf);
             sf.Flush();
             sf.Close();
             DownLoading = Visibility.Collapsed;
             NotifyWindow notifyWindow = new NotifyWindow("下载完成", "下载完成!");
             notifyWindow.Show();
         }
     }
 }
        public bool Init(Guid classGuid)
        {
            logger.Debug("UsbDeviceManager::Init()");

            if (nativeWindow == null)
            {
                nativeWindow = new NotifyWindow(this);
                nativeWindow.CreateWindow();
            }

            var hWnd = nativeWindow.Handle;

            var handle = RegisterNotification(hWnd, classGuid);

            return(handle != IntPtr.Zero);
        }
Example #7
0
        private void SubOperation_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            if (submitOperation.HasError)
            {
                submitOperation.MarkErrorAsHandled();
                NotifyWindow notifyWindow = new NotifyWindow("错误", "上传失败 " + submitOperation.Error);
                notifyWindow.Show();
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("上传成功", "上传成功!");
                notifyWindow.Show();
            }
        }
        private void OnOpenFileCommand()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == true)
            {
                String fileName = ofd.File.Name;

                if (fileName.Contains("\"") ||
                    fileName.Contains("#") ||
                    fileName.Contains("%") ||
                    fileName.Contains("&") ||
                    fileName.Contains("\'") ||
                    fileName.Contains("~") ||
                    fileName.Contains("|") ||
                    fileName.Contains(">") ||
                    fileName.Contains("<") ||
                    fileName.Contains("[") ||
                    fileName.Contains("]") ||
                    fileName.Contains("^") ||
                    fileName.Contains("{") ||
                    fileName.Contains("}"))
                {
                    NotifyWindow notificationWindow = new NotifyWindow("错误", "文件名包含 \"#%&\'~|><[]^{} 等非法字符!");
                    notificationWindow.Show();
                    return;
                }

                foreach (ProjectFilesEntity projectFilesEntity in ProjectFilesEntityList)
                {
                    if (projectFilesEntity.fileName == fileName && !projectFilesEntity.FileDelete)
                    {
                        NotifyWindow notificationWindow = new NotifyWindow("错误", "已上传相同的文件!");
                        notificationWindow.Show();
                        return;
                    }
                }
                ProjectFilesEntity.FileName = fileName;
                UserFile                     = new FileUploader.UserFile();
                UserFile.FileName            = fileName;
                UserFile.FolderName          = ProjectFilesEntity.ManufactureNumber;
                UserFile.FileStream          = ofd.File.OpenRead();
                ProjectFilesEntity.FileBytes = UserFile.FileStream.Length;
                (OnUpdate as DelegateCommand).RaiseCanExecuteChanged();
            }
        }
        void submitOperation_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            if (submitOperation.HasError)
            {
                submitOperation.MarkErrorAsHandled();
                NotifyWindow notifyWindow = new NotifyWindow("错误", "删除失败");
                notifyWindow.Show();
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("删除成功", "删除成功!");
                notifyWindow.Show();
                LoadData();
            }
        }
        void submitOperation_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            if (submitOperation.HasError)
            {
                submitOperation.MarkErrorAsHandled();
                NotifyWindow notifyWindow = new NotifyWindow("错误", "保存失败");
                notifyWindow.Show();
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("保存成功", "保存成功!");
                notifyWindow.Show();
            }
            BusyIndicator.IsBusy = false;
        }
Example #11
0
        private void onOpenStandBookFile()
        {
            OpenFileDialog oFile = new OpenFileDialog();

            // .xls filter specified to select only .xls file.
            oFile.Filter = "Excel (*.xls)|*.xls";

            if (oFile.ShowDialog() == true)
            {
                HasShowTemp = Visibility.Collapsed;
                try
                {
                    FileStream fs             = oFile.File.OpenRead();
                    Workbook   book           = Workbook.Open(fs);
                    bool       lIsSuccessRead = ReadSheet(book.Worksheets[0]);
                    if (lIsSuccessRead)
                    {
                        fs.Close();
                        HasShowTemp = Visibility.Visible;
                        CanInput    = CheckVaild();
                        if (CanInput)
                        {
                            String fileName = oFile.File.Name;
                            UserFile = new UserFile();
                            DateTime lDateTime = DateTime.Now;
                            UserFile.FileName   = lDateTime.ToString("yyyyMMdd_HHmmss_") + fileName;
                            UserFile.FileFolder = currentTaxPayerEntity.TaxPayerId.ToString();
                            UserFile.FileStream = oFile.File.OpenRead();

                            taxPayerDocumentEntity = new TaxPayerDocumentEntity();
                            taxPayerDocumentEntity.TaxPayerDocumentBytes = UserFile.FileStream.Length;
                        }

                        UpdateChanged("StandBookEntity");
                    }
                }
                catch (Exception ex)
                {
                    NotifyWindow lNotifyWindow = new NotifyWindow("打开文件出错", "请检查文件是否被其他程序打开或者文件中是否有自定义数据类型,请与模板比对!");
                    lNotifyWindow.Show();
                }
                UpdateChanged("HasShowTemp");
            }
        }
Example #12
0
        void DeleteSubmitOperation_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            if (!submitOperation.HasError)
            {
                NotifyWindow notifyWindow = new NotifyWindow("删除", "删除成功");
                notifyWindow.Show();
                using (planOutlineFilesView.DeferRefresh())
                {
                    planOutlineFilesView.MoveToFirstPage();
                }
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("删除", "删除失败:" + submitOperation.Error.Message);
                notifyWindow.Show();
            }
        }
Example #13
0
 void OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         using (Stream sf = (Stream)saveFileDialog.OpenFile())
         {
             e.Result.CopyTo(sf);
             sf.Flush();
             sf.Close();
             NotifyWindow notifyWindow = new NotifyWindow("下载完成", "下载完成!");
             notifyWindow.Show();
         }
     }
     else
     {
         NotifyWindow notifyWindow = new NotifyWindow("下载错误", e.Error.Message);
         notifyWindow.Show();
     }
 }
Example #14
0
        void ModifyPassword_Completed(object sender, EventArgs e)
        {
            IsBusy = false;
            var lValue = (System.ServiceModel.DomainServices.Client.InvokeOperation <bool>)sender;

            if (lValue.Value)
            {
                App app = Application.Current as App;
                app.MainPageViewModel.User.Password = Cryptography.MD5.GetMd5String(ModifyPasswordEntity.NewPassword);
                ChildWindow.DialogResult            = true;
                NotifyWindow notifyWindow = new NotifyWindow("修改成功", "密码修改成功");
                notifyWindow.Show();
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("修改失败", "密码修改失败");
                notifyWindow.Show();
            }
        }
Example #15
0
        private void MultiFileDrop(object sender, DragEventArgs e)
        {
            if (e.Data != null)
            {
                MergeImagesViewModel lMerImgesViewModel = this.DataContext as MergeImagesViewModel;

                if (!lMerImgesViewModel.canUpdateFile())
                {
                    NotifyWindow notificationWindow = new NotifyWindow("错误", "请选择文件类型!");
                    notificationWindow.Show();
                    return;
                }

                var files = e.Data.GetData(DataFormats.FileDrop) as FileInfo[];

                foreach (var file in files)
                {
                    string fileName = file.Name;

                    if (fileName.Contains("\"") ||
                        fileName.Contains("#") ||
                        fileName.Contains("%") ||
                        fileName.Contains("&") ||
                        fileName.Contains("\'") ||
                        fileName.Contains("~") ||
                        fileName.Contains("|") ||
                        fileName.Contains(">") ||
                        fileName.Contains("<") ||
                        fileName.Contains("[") ||
                        fileName.Contains("]") ||
                        fileName.Contains("^") ||
                        fileName.Contains("{") ||
                        fileName.Contains("}"))
                    {
                        NotifyWindow notificationWindow = new NotifyWindow("错误", "文件名包含 \"#%&\'~|><[]^{} 等非法字符!");
                        notificationWindow.Show();
                        continue;
                    }

                    lMerImgesViewModel.AddFile(file);
                }
            }
        }
        void subOperation_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            if (submitOperation.HasError)
            {
                submitOperation.MarkErrorAsHandled();
                NotifyWindow notifyWindow = new NotifyWindow("错误", "保存失败");
                notifyWindow.Show();
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("保存成功", "保存成功!");
                notifyWindow.Show();
            }

            (OnSave as DelegateCommand).RaiseCanExecuteChanged();
            IsBusy = false;
        }
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            IsBusy = false;
            if (loginOperation.LoginSuccess)
            {
                ProductManager.Web.User lUser = loginOperation.User.Identity as ProductManager.Web.User;
                if (lUser.IsFreeze)
                {
                    NotifyWindow notifyWindow = new NotifyWindow("用户已冻结", "用户已冻结!");
                    notifyWindow.Show();
                    return;
                }

                App app = Application.Current as App;
                app.UserInfo = new UserInfo();

                app.UserInfo.UserName       = lUser.UserName;
                app.UserInfo.UserAction     = lUser.RightDictionary;
                app.UserInfo.UserDepartment = lUser.Department;
                app.UserInfo.UserID         = lUser.UserID;
                app.UserInfo.DepartmentID   = lUser.DepartmentID;
                app.UserInfo.UserPassword   = lUser.Password;
                app.UserInfo.IsManager      = lUser.IsManager;

                if (app.UserInfo.UserPassword == Cryptography.MD5.GetMd5String("123456"))
                {
                    ModifyPasswrodWindow modifyPasswordWindow = new ModifyPasswrodWindow();
                    modifyPasswordWindow.Closed += modifyWindowClosed;
                    modifyPasswordWindow.Show();
                }
                else
                {
                    app.LogonUser(app.UserInfo.UserID, app.UserInfo.UserName);
                    FinishLogon(null);
                }
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("用户名或密码错误", "用户名或密码错误");
                notifyWindow.Show();
            }
        }
        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                using (Stream sf = (Stream)TempSaveFileDialog.OpenFile())
                {
                    e.Result.CopyTo(sf);
                    sf.Flush();

                    NotifyWindow notificationWindow = new NotifyWindow("下载完成", "下载模板文件 " + "申报表_模板" + " 完成");
                    notificationWindow.Show();
                }
            }
            else
            {
                NotifyWindow notificationWindow = new NotifyWindow("下载失败", "下载模板文件 " + "申报表_模板" + " 失败");
                notificationWindow.Show();
            }
            //throw new NotImplementedException();
        }
Example #19
0
        private void onOpenFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == true)
            {
                String fileName = ofd.File.Name;

                if (fileName.Contains("\"") ||
                    fileName.Contains("#") ||
                    fileName.Contains("%") ||
                    fileName.Contains("&") ||
                    fileName.Contains("\'") ||
                    fileName.Contains("~") ||
                    fileName.Contains("|") ||
                    fileName.Contains(">") ||
                    fileName.Contains("<") ||
                    fileName.Contains("[") ||
                    fileName.Contains("]") ||
                    fileName.Contains("^") ||
                    fileName.Contains("{") ||
                    fileName.Contains("}"))
                {
                    NotifyWindow notificationWindow = new NotifyWindow("错误", "文件名包含 \"#%&\'~|><[]^{} 等非法字符!");
                    notificationWindow.Show();
                    return;
                }


                FileName               = fileName;
                UserFile               = new UserFile();
                UserFile.FileName      = fileName;
                UserFile.FileFolder    = taxPayerEntity.TaxPayerId.ToString();
                UserFile.FileStream    = ofd.File.OpenRead();
                taxPayerDocumentEntity = new TaxPayerDocumentEntity();
                taxPayerDocumentEntity.TaxPayerDocumentBytes = UserFile.FileStream.Length;
                //ProjectFilesEntity.FileBytes = UserFile.FileStream.Length;
                (OnUpdate as DelegateCommand).RaiseCanExecuteChanged();
                UpdateChanged("UserFile");
            }
        }
Example #20
0
        private void OnModifyPasswordCommand()
        {
            if (ModifyPasswordEntity.Validate())
            {
                IsBusy = true;

                DocumentManager.Web.OperationDomainContext operationDomainContext = new DocumentManager.Web.OperationDomainContext();

                App app = Application.Current as App;

                if (app.MainPageViewModel.User.Password == Cryptography.MD5.GetMd5String(ModifyPasswordEntity.NewPassword))
                {
                    NotifyWindow notifyWindow = new NotifyWindow("密码验证", "请输入新密码");
                    notifyWindow.Show();
                    IsBusy = false;
                    return;
                }
                InvokeOperation <bool> lModifyPassword = operationDomainContext.ModifyPassword(app.MainPageViewModel.User.UserID, Cryptography.MD5.GetMd5String(ModifyPasswordEntity.NewPassword));
                lModifyPassword.Completed += ModifyPassword_Completed;
            }
        }
        private void SubOperation_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            if (submitOperation.HasError)
            {
                submitOperation.MarkErrorAsHandled();
                NotifyWindow notifyWindow = new NotifyWindow("错误", "删除失败 " + submitOperation.Error);
                notifyWindow.Show();
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("删除成功", "删除成功!");
                notifyWindow.Show();
            }

            using (this.standBookView.DeferRefresh())
            {
                this.standBookView.MoveToFirstPage();
            }
        }
        void SubOperation_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            if (submitOperation.HasError)
            {
                submitOperation.MarkErrorAsHandled();
                NotifyWindow notifyWindow = new NotifyWindow("错误", "保存失败");
                notifyWindow.Show();
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("保存成功", "保存成功!");
                notifyWindow.Show();
                using (taxPayerDocumentView.DeferRefresh())
                {
                    taxPayerDocumentView.MoveToFirstPage();
                }
            }
            FinishLoadings(null, null);
        }
        private void onOK()
        {
            if (SelectSearchCondition == null && IsFirst == false)
            {
                NotifyWindow notifyWindow = new NotifyWindow("错误", "请选择条件!");
                notifyWindow.Show();
                return;
            }

            if (SelectTaxPayerField == null)
            {
                NotifyWindow notifyWindow = new NotifyWindow("错误", "请选择字段!");
                notifyWindow.Show();
                return;
            }

            if (SelectSearchOperator == null)
            {
                NotifyWindow notifyWindow = new NotifyWindow("错误", "请选择操作!");
                notifyWindow.Show();
                return;
            }

            if (ValueStr == null && VisibilityStr == Visibility.Visible)
            {
                NotifyWindow notifyWindow = new NotifyWindow("错误", "请设置值!");
                notifyWindow.Show();
                return;
            }

            if (ValueInt == -1 && visibilityType == Visibility.Visible)
            {
                NotifyWindow notifyWindow = new NotifyWindow("错误", "请设置值!");
                notifyWindow.Show();
                return;
            }

            childWindow.DialogResult = true;
        }
        void SubOperationAddProject_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            if (submitOperation.HasError)
            {
                submitOperation.MarkErrorAsHandled();
                NotifyWindow notifyWindow = new NotifyWindow("错误", "保存失败");
                notifyWindow.Show();
                if (addTaxPayerEntity != null)
                {
                    TaxPayerList.Remove(addTaxPayerEntity);
                    addTaxPayerEntity = null;
                }
                IsBusy = false;
            }
            else
            {
                addTaxPayerEntity.Update();
                AutoLinkDocumentFiles(addTaxPayerEntity, SelectTaxPayerEntity);
            }
        }
Example #25
0
        void submitOperation_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            ProductManagersViewModel.IsBusy = false;
            if (submitOperation.HasError)
            {
                if (!isUserProject)
                {
                    submitOperation.MarkErrorAsHandled();
                    NotifyWindow notifyWindow = new NotifyWindow("错误", "取消自选失败!");
                    notifyWindow.Show();
                }
                else
                {
                    submitOperation.MarkErrorAsHandled();
                    NotifyWindow notifyWindow = new NotifyWindow("错误", "添加自选失败!");
                    notifyWindow.Show();
                }
            }
            else
            {
                if (!isUserProject)
                {
                    NotifyWindow notifyWindow = new NotifyWindow("成功", "取消自选成功!");
                    notifyWindow.Show();

                    //isUserProject = false;
                    UserProjectEntityDictionary.Remove(manufactureNumber);
                }
                else
                {
                    NotifyWindow notifyWindow = new NotifyWindow("成功", "添加自选成功!");
                    notifyWindow.Show();
                    //isUserProject = true;
                    UserProjectEntityDictionary.Add(manufactureNumber, UserProjectEntity);
                }
            }
        }
Example #26
0
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            IsBusy = false;
            App app = Application.Current as App;


            if (loginOperation.LoginSuccess)
            {
                DocumentManager.Web.User lUser = loginOperation.User.Identity as DocumentManager.Web.User;

                if (lUser.ExpireDay == -1100)
                {
                    NotifyWindow notifyWindow = new NotifyWindow("注册错误", "注册信息丢失, 请与 管理员 联系");
                    notifyWindow.Show();
                    return;
                }
                else if (lUser.ExpireDay < 0)
                {
                    NotifyWindow notifyWindow = new NotifyWindow("应用程序已经过期", "应用程序已经过期" + lUser.ExpireDay.ToString() + "天, 请与 管理员 联系");
                    notifyWindow.Show();
                    return;
                }
                else if (lUser.ExpireDay < 30)
                {
                    NotifyWindow notifyWindow = new NotifyWindow("过期", "还有" + lUser.ExpireDay + "天, 应用程序即将过期,请与 管理员 联系");
                    notifyWindow.Show();
                }

                app.MainPageViewModel.User = lUser;
                app.SuccessLogon();
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("用户名或密码错误", "用户名或密码错误");
                notifyWindow.Show();
                return;
            }
        }
        private void UserFile_FinishUpdate(object sender, EventArgs e)
        {
            ProjectFilesEntity.FileUpdateTime = DateTime.Now;
            if (SelectFileTypeEntity != null)
            {
                ProjectFilesEntity.FileTypeName = SelectFileTypeEntity.FileTypeName;
            }
            else
            {
                foreach (FileTypeEntity fileTypeEntity in FileTypeEntityList)
                {
                    if (ProjectFilesEntity.FileTypeID == fileTypeEntity.FileTypeID)
                    {
                        ProjectFilesEntity.FileTypeName = fileTypeEntity.FileTypeName;
                    }
                }
            }
            NotifyWindow notificationWindow = new NotifyWindow("上传文件", "上传文件完成!");

            notificationWindow.Show();
            IsBusy = false;
            this.childWindow.DialogResult = true;
        }
        void SubOperation_Completed(object sender, EventArgs e)
        {
            SubmitOperation submitOperation = sender as SubmitOperation;

            if (submitOperation.HasError)
            {
                submitOperation.MarkErrorAsHandled();
                NotifyWindow notifyWindow = new NotifyWindow("错误", "保存失败");
                notifyWindow.Show();
                if (addTaxPayerEntity != null)
                {
                    TaxPayerList.Remove(addTaxPayerEntity);
                    addTaxPayerEntity = null;
                }
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("保存成功", "保存成功!");
                notifyWindow.Show();
                addTaxPayerEntity = null;
                LoadData();
            }
            IsBusy = false;
        }
Example #29
0
//         void loadOperationProject_Completed(object sender, EventArgs e)
//         {
//             ProjectList.Clear();
//             LoadOperation loadOperation = sender as LoadOperation;
//             foreach (ProductManager.Web.Model.project project in loadOperation.Entities)
//             {
//                 ProjectEntity projectEntity = new ProjectEntity();
//                 projectEntity.Project = project;
//                 projectEntity.Update();
//                 ProjectList.Add(projectEntity);
//             }
//
//             UpdateChanged("ProjectList");
//             IsBusy = false;
//         }

        private LoadOperation <ProductManager.Web.Model.project> LoadProjectEntities()
        {
            if (!isFilter)
            {
                this.IsBusy = true;
                EntityQuery <ProductManager.Web.Model.project> lQuery = this.planManagerDomainContext.GetProjectQuery();
                return(this.planManagerDomainContext.Load(lQuery.SortAndPageBy(this.projectView)));
            }
            else
            {
                this.IsBusy = true;
                EntityQuery <ProductManager.Web.Model.project> lQuery = this.planManagerDomainContext.GetProjectQuery();
                if (selectFilerList == "生产令号")
                {
                    if (!String.IsNullOrEmpty(filterContent))
                    {
                        lQuery = lQuery.Where(e => e.manufacture_number.Contains(filterContent));
                    }
                }
                if (selectFilerList == "项目名称")
                {
                    if (!String.IsNullOrEmpty(filterContent))
                    {
                        lQuery = lQuery.Where(e => e.project_name.Contains(filterContent));
                    }
                }
                if (selectFilerList == "备注")
                {
                    if (!String.IsNullOrEmpty(filterContent))
                    {
                        lQuery = lQuery.Where(e => e.remark.Contains(filterContent));
                    }
                }
                if (selectFilerList == "年份")
                {
                    if (!String.IsNullOrEmpty(filterContent))
                    {
                        try
                        {
                            int year = Convert.ToInt32(filterContent);
                            lQuery = lQuery.Where(e => e.year_number == year);
                        }
                        catch (System.Exception ex)
                        {
                            NotifyWindow notifyWindow = new NotifyWindow("错误", "输入年份不合法");
                            notifyWindow.Show();
                        }
                    }
                }

                if (selectFilerList == "记录时间")
                {
                    if (!String.IsNullOrEmpty(filterContent))
                    {
                        try
                        {
                            DateTime remarkDate = Convert.ToDateTime(filterContent);
                            lQuery = lQuery.Where(e => e.record_date.Value.Year == remarkDate.Year && e.record_date.Value.Month == remarkDate.Month && e.record_date.Value.Day == remarkDate.Day);
                        }
                        catch (System.Exception ex)
                        {
                            NotifyWindow notifyWindow = new NotifyWindow("错误", "记录时间不合法 (YYYY-MM-DD)");
                            notifyWindow.Show();
                        }
                    }
                }
                return(this.planManagerDomainContext.Load(lQuery.SortAndPageBy(this.projectView)));
            }
        }
Example #30
0
        private void OnImportCommand()
        {
            OpenFileDialog lOpenFile = new OpenFileDialog();

            lOpenFile.Filter = "Excel (*.xls)|*.xls";
            Dictionary <String, int> lHeaderDictionary = new Dictionary <String, int>();

            if (lOpenFile.ShowDialog() == true)
            {
                ImportantPartEntityList.Clear();

                try
                {
                    FileStream fs   = lOpenFile.File.OpenRead();
                    Workbook   book = Workbook.Open(fs);

                    foreach (KeyValuePair <int, Row> rowPair in book.Worksheets[0].Cells.Rows)
                    {
                        if (rowPair.Key == 0)
                        {
                            try
                            {
                                foreach (KeyValuePair <int, Cell> cellPair in rowPair.Value)
                                {
                                    lHeaderDictionary.Add(cellPair.Value.StringValue, cellPair.Key);
                                }
                            }
                            catch (System.Exception ex)
                            {
                                Message.ErrorMessage("表头重复或超出范围!");
                                break;
                            }
                            continue;
                        }

                        ImportantPartEntity lImportantPartEntity = new ImportantPartEntity();
                        lImportantPartEntity.ImportantPart = new ProductManager.Web.Model.important_part();
                        //lImportantPartEntity.ManufactureNumber = ProjectEntity.ManufactureNumber;


                        int lManufactureNumberColumn = -1;
                        {
                            Cell cell = Cell.EmptyCell;
                            if (lHeaderDictionary.TryGetValue("生产令号", out lManufactureNumberColumn) &&
                                -1 != lManufactureNumberColumn &&
                                Cell.EmptyCell != (cell = rowPair.Value.GetCell(lManufactureNumberColumn)))
                            {
                                lImportantPartEntity.ManufactureNumber = cell.StringValue;

                                ProjectEntity projectEntityTemp;
                                if (!ProjectEntityDictionary.TryGetValue(lImportantPartEntity.ManufactureNumber, out projectEntityTemp))
                                {
                                    NotifyWindow lNotifyWindow = new NotifyWindow("错误", "第 " + rowPair.Key.ToString() + "行 系统中没有生产令号:" + lImportantPartEntity.ManufactureNumber);
                                    lNotifyWindow.Show();
                                    return;
                                }
                            }
                            else
                            {
                                NotifyWindow lNotifyWindow = new NotifyWindow("错误", "第 " + rowPair.Key.ToString() + "行 系统中没有生产令号:" + lImportantPartEntity.ManufactureNumber);
                                lNotifyWindow.Show();
                                return;
                            }
                        }

                        int lImportPartNameColumn = -1;
                        {
                            Cell cell = Cell.EmptyCell;
                            if (lHeaderDictionary.TryGetValue("主要部件名称", out lImportPartNameColumn) &&
                                -1 != lManufactureNumberColumn &&
                                Cell.EmptyCell != (cell = rowPair.Value.GetCell(lImportPartNameColumn)))
                            {
                                lImportantPartEntity.ImportantPartName = cell.StringValue;
                            }
                        }

                        int lProjectNameColumn = -1;
                        {
                            Cell cell = Cell.EmptyCell;
                            if (lHeaderDictionary.TryGetValue("厂家", out lProjectNameColumn) &&
                                -1 != lProjectNameColumn &&
                                Cell.EmptyCell != (cell = rowPair.Value.GetCell(lProjectNameColumn)))
                            {
                                lImportantPartEntity.ImportantPartManufacturers = cell.StringValue;
                            }
                        }

                        int lModelNumberColumn = -1;
                        {
                            Cell cell = Cell.EmptyCell;
                            if (lHeaderDictionary.TryGetValue("到货时间", out lModelNumberColumn) &&
                                -1 != lModelNumberColumn &&
                                Cell.EmptyCell != (cell = rowPair.Value.GetCell(lModelNumberColumn)))
                            {
                                lImportantPartEntity.AriveTime = cell.DateTimeValue;
                            }
                        }

                        //备注
                        int lRemarkColumn = -1;
                        {
                            Cell cell = Cell.EmptyCell;
                            if (lHeaderDictionary.TryGetValue("备注", out lRemarkColumn) &&
                                -1 != lRemarkColumn &&
                                Cell.EmptyCell != (cell = rowPair.Value.GetCell(lRemarkColumn)))
                            {
                                lImportantPartEntity.Note = cell.StringValue;
                            }
                        }

                        App app = Application.Current as App;
                        lImportantPartEntity.AriveUserId          = app.UserInfo.UserID;
                        lImportantPartEntity.AriveInputTime       = DateTime.Now;
                        lImportantPartEntity.UserEntityDictionary = DictionaryUser;
                        lImportantPartEntity.DUpdate();

                        ImportantPartEntityList.Add(lImportantPartEntity);

                        //ProductContext.projects.Add(lProjectEntity.Project);
                    }
                }
                catch (System.Exception ex)
                {
                    Message.ErrorMessage(ex.Message);
                }
            }
        }
 //Notify icon la ilgili fonksiyonlar
 public void openModifyWindow()
 {
     if (running)
     {
         int s = (int)m_obj_MediaPosition.Duration;
         int h = s / 3600;
         int m = (s - (h * 3600)) / 60;
         s = s - (h * 3600 + m * 60);
         string time = String.Format("{0:D2}:{1:D2}:{2:D2}", h, m, s);
         string[] fullfilename = listoffilenames.Items[fileIndex].ToString().Split('\\');
         NotifyWindow notify = new NotifyWindow("Circass Media Player", fullfilename[fullfilename.Length - 1].ToString() + "\n Time ::" + time);
         notify.TitleClicked += new System.EventHandler(titleClick);
         notify.TextClicked += new System.EventHandler(textClick);
         notify.SetDimensions(130, 100);
         notify.Notify();
     }
 }
Example #32
0
        private bool ReadSheet(Worksheet aSheet)
        {
            foreach (KeyValuePair <int, Row> rowPair in aSheet.Cells.Rows)
            {
                if (rowPair.Key == 0) // 第一行 流水号检查 受理流水号
                {
                    Cell   lCell  = rowPair.Value.GetCell(0);
                    string lValue = lCell.Value.ToString().Trim();
                    if (lValue != "税务机关代开普通发票申请表")
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "打开的不是 '税务机关代开普通发票申请表' 或者 数据不在第一个工作表里。");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 1) // 第二行 流水号检查 受理流水号
                {
                    try
                    {
                        Cell   lCell  = rowPair.Value.GetCell(0);
                        string lValue = lCell.Value.ToString();
                        StandBookEntity.StandBookID = lValue.Substring(lValue.IndexOf(':') + 1).Trim();
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第二行 '受理流水号' 出错!请检查输入文件。");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 2) // 第三行 合同项目名称 合同总金额 本次拨款金额
                {
                    try
                    {
                        Cell   lCellName       = rowPair.Value.GetCell(0);
                        Cell   lCellTotolMoney = rowPair.Value.GetCell(2);
                        Cell   lCellThisMoney  = rowPair.Value.GetCell(4);
                        string lValueName      = lCellName.Value.ToString();
                        StandBookEntity.ProjectName = lValueName.Substring(lValueName.IndexOf(':') + 1).Trim();
                        string lValueTotolMoney = lCellTotolMoney.Value.ToString();
                        lValueTotolMoney           = lValueTotolMoney.Substring(lValueTotolMoney.IndexOf(':') + 1).Trim();
                        StandBookEntity.TotalMoney = Convert.ToDecimal(lValueTotolMoney);
                        string lValueThisMoney = lCellThisMoney.Value.ToString();
                        lValueThisMoney = lValueThisMoney.Substring(lValueThisMoney.IndexOf(':') + 1).Trim();
                        StandBookEntity.ThisPartMoney = Convert.ToDecimal(lValueThisMoney);
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第三行 '合同项目名称 合同总金额 本次拨款金额' 出错!请检查输入文件。");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 3) // 第四行 综合税率 合同总应缴税额
                {
                    try
                    {
                        Cell   lCellTotalRate  = rowPair.Value.GetCell(1);
                        string lValueTotalRate = lCellTotalRate.Value.ToString();
                        StandBookEntity.TotalTaxRate = Convert.ToDecimal(lValueTotalRate);
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第四行 '综合税率 合同总应缴税额' 出错!请检查输入文件。");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 4) // 第五行 申请单位
                {
                    try
                    {
                        Cell   lCellCpName  = rowPair.Value.GetCell(1);
                        string lValueCpName = lCellCpName.Value.ToString().Trim();
                        StandBookEntity.TaxPayerName = lValueCpName;
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第五行 '申请单位' 出错!请检查输入文件。");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 7) // 第八行 经济性质
                {
                    try
                    {
                        Cell   lCellEconomicNature  = rowPair.Value.GetCell(1);
                        string lValueEconomicNature = lCellEconomicNature.Value.ToString().Trim();
                        StandBookEntity.EconomicNature = lValueEconomicNature;

                        Cell   lCellPhoneNumber  = rowPair.Value.GetCell(3);
                        string lValuePhoneNumber = lCellPhoneNumber.Value.ToString().Trim();
                        StandBookEntity.PhoneNumber = lValuePhoneNumber;
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第八行 '经济性质' '联系电话' 出错!请检查输入文件。");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 8) // 第九行 付款单位
                {
                    try
                    {
                        Cell   lCellPlayCpName = rowPair.Value.GetCell(1);
                        string lValueCpName    = lCellPlayCpName.Value.ToString().Trim();
                        StandBookEntity.CapitalConstruction = lValueCpName;
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第九行 '付款单位' 出错!请检查输入文件。");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 13) // 第十四行 有无外管证
                {
                    try
                    {
                        Cell   lCellHasVerify  = rowPair.Value.GetCell(0);
                        string lValueHasVerify = lCellHasVerify.Value.ToString().Trim();
                        lValueHasVerify = lValueHasVerify.Substring(lValueHasVerify.IndexOf(':') + 1).Trim();
                        if (lValueHasVerify == "有")
                        {
                            StandBookEntity.HasOutVerify = true;
                        }
                        else if (lValueHasVerify == "无")
                        {
                            StandBookEntity.HasOutVerify = false;
                        }
                        else
                        {
                            NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第十四行 '有无外管证' 出错!请在':'后输入'有'或'无'。");
                            lNotifyWindow.Show();
                            return(false);
                        }
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第十三行 '有无外管证' 出错!请检查输入文件。");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 20) // 第二十一行 法人代表
                {
                    try
                    {
                        Cell   lCellJridicalPerson  = rowPair.Value.GetCell(3);
                        string lValueJridicalPerson = lCellJridicalPerson.Value.ToString().Trim();
                        lValueJridicalPerson = lValueJridicalPerson.Substring(lValueJridicalPerson.IndexOf(':') + 1).Trim();
                        StandBookEntity.TaxPayerPersonName = lValueJridicalPerson;
                        if (lValueJridicalPerson == string.Empty)
                        {
                            NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第二十一行 '法人代表' 出错!请在D列输入'法人姓名:XXX'。");
                            lNotifyWindow.Show();
                            return(false);
                        }
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第二十行 '法人代表' 出错!请在D列输入'法人姓名:XXX'。");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 21) // 第二十二行 日期
                {
                    try
                    {
                        Cell   lCellDataTime  = rowPair.Value.GetCell(0);
                        string lValueDataTime = lCellDataTime.Value.ToString().Trim();
                        lValueDataTime          = lValueDataTime.Substring(lValueDataTime.IndexOf(':') + 1).Trim();
                        StandBookEntity.PayTime = Convert.ToDateTime(lValueDataTime);
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第二十二行 '日期' 出错!请在A列输入'日期:yyyy年mm月dd日'。");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 25 ||          // 第二十六行 税
                    rowPair.Key == 26 ||          // 第二十七行 税
                    rowPair.Key == 27 ||          // 第二十八行 税
                    rowPair.Key == 28 ||          // 第二十九行 税
                    rowPair.Key == 29 ||          // 第三十行 税
                    rowPair.Key == 30             // 第三十一行 税
                    )
                {
                    string lValueTaxType;
                    string lValueTax;
                    string lValueTaxItem = "";
                    string lValueTaxRate;
                    int    lKeyRow = rowPair.Key + 1;
                    try
                    {
                        Cell lCellTaxType = rowPair.Value.GetCell(0);
                        lValueTaxType = lCellTaxType.Value.ToString().Trim();

                        Cell lCellTaxItem = rowPair.Value.GetCell(1);
                        if (lCellTaxItem.Value != null)
                        {
                            lValueTaxItem = lCellTaxItem.Value.ToString().Trim();
                        }

                        Cell lCellTaxRate = rowPair.Value.GetCell(4);
                        lValueTaxRate = lCellTaxRate.Value.ToString().Trim();

                        Cell lCellTax = rowPair.Value.GetCell(5);
                        lValueTax = lCellTax.Value.ToString().Trim();
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第" + lKeyRow + "行 出错!");
                        lNotifyWindow.Show();
                        return(false);
                    }

                    bool lHasCorrectTaxType = false;
                    if (lValueTaxType != string.Empty)
                    {
                        if (lValueTaxType == "增值税")
                        {
                            lHasCorrectTaxType = true;
                            try
                            {
                                decimal lTax     = Convert.ToDecimal(lValueTax);
                                decimal lTaxRate = Convert.ToDecimal(lValueTaxRate);
                                StandBookEntity.HasAddValueTax  = true;
                                StandBookEntity.AddValueTax     = lTax;
                                StandBookEntity.AddValueTaxRate = lTaxRate;
                                StandBookEntity.AddValueTaxItem = lValueTaxItem;
                            }
                            catch (Exception e)
                            {
                                NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第" + lKeyRow + "行 '营业税' 出错!");
                                lNotifyWindow.Show();
                                return(false);
                            }
                        }

                        if (lValueTaxType == "营业税")
                        {
                            lHasCorrectTaxType = true;
                            try
                            {
                                decimal lTax     = Convert.ToDecimal(lValueTax);
                                decimal lTaxRate = Convert.ToDecimal(lValueTaxRate);
                                StandBookEntity.HasBusinessTax  = true;
                                StandBookEntity.BusinessTax     = lTax;
                                StandBookEntity.BusinessTaxRate = lTaxRate;
                                StandBookEntity.BusinessTaxItem = lValueTaxItem;
                            }
                            catch (Exception e)
                            {
                                NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第" + lKeyRow + "行 '营业税' 出错!");
                                lNotifyWindow.Show();
                                return(false);
                            }
                        }

                        if (lValueTaxType == "教育费附加")
                        {
                            lHasCorrectTaxType = true;
                            try
                            {
                                decimal lTax     = Convert.ToDecimal(lValueTax);
                                decimal lTaxRate = Convert.ToDecimal(lValueTaxRate);
                                StandBookEntity.HasEducationalSurtax     = true;
                                StandBookEntity.EducationalSurtaxTax     = lTax;
                                StandBookEntity.EducationalSurtaxTaxRate = lTaxRate;
                                StandBookEntity.EducationalSurtaxTaxItem = lValueTaxItem;
                            }
                            catch (Exception e)
                            {
                                NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第" + lKeyRow + "行 '教育费附加' 出错!");
                                lNotifyWindow.Show();
                                return(false);
                            }
                        }

                        if (lValueTaxType == "城建税")
                        {
                            lHasCorrectTaxType = true;
                            try
                            {
                                decimal lTax     = Convert.ToDecimal(lValueTax);
                                decimal lTaxRate = Convert.ToDecimal(lValueTaxRate);
                                StandBookEntity.HasUrbanTax  = true;
                                StandBookEntity.UrbanTax     = lTax;
                                StandBookEntity.UrbanTaxRate = lTaxRate;
                                StandBookEntity.UrbanTaxItem = lValueTaxItem;
                            }
                            catch (Exception e)
                            {
                                NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第" + lKeyRow + "行 '城建税' 出错!");
                                lNotifyWindow.Show();
                                return(false);
                            }
                        }

                        if (lValueTaxType == "地方教育附加")
                        {
                            lHasCorrectTaxType = true;
                            try
                            {
                                decimal lTax     = Convert.ToDecimal(lValueTax);
                                decimal lTaxRate = Convert.ToDecimal(lValueTaxRate);
                                StandBookEntity.HasLocalEducationalSurtax     = true;
                                StandBookEntity.LocalEducationalSurtaxTax     = lTax;
                                StandBookEntity.LocalEducationalSurtaxTaxRate = lTaxRate;
                                StandBookEntity.LocalEducationalSurtaxTaxItem = lValueTaxItem;
                            }
                            catch (Exception e)
                            {
                                NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第" + lKeyRow + "行 '城建税' 出错!");
                                lNotifyWindow.Show();
                                return(false);
                            }
                        }

                        if (lValueTaxType == "印花税")
                        {
                            lHasCorrectTaxType = true;
                            try
                            {
                                decimal lTax     = Convert.ToDecimal(lValueTax);
                                decimal lTaxRate = Convert.ToDecimal(lValueTaxRate);
                                StandBookEntity.HasStampTax  = true;
                                StandBookEntity.StampTax     = lTax;
                                StandBookEntity.StampTaxRate = lTaxRate;
                                StandBookEntity.StampTaxItem = lValueTaxItem;
                            }
                            catch (Exception e)
                            {
                                NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第" + lKeyRow + "行 '印花税' 出错!");
                                lNotifyWindow.Show();
                                return(false);
                            }
                        }

                        if (lValueTaxType == "企业所得税" || lValueTaxType == "个人所得税")
                        {
                            lHasCorrectTaxType = true;
                            try
                            {
                                decimal lTax     = Convert.ToDecimal(lValueTax);
                                decimal lTaxRate = Convert.ToDecimal(lValueTaxRate);
                                StandBookEntity.HasIncomeTax  = true;
                                StandBookEntity.IncomeTax     = lTax;
                                StandBookEntity.IncomeTaxRate = lTaxRate;
                                StandBookEntity.IncomeTaxItem = lValueTaxItem;
                            }
                            catch (Exception e)
                            {
                                NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第" + lKeyRow + "行 '企业所得税(个人所得税)' 出错!");
                                lNotifyWindow.Show();
                                return(false);
                            }
                        }

                        if (!lHasCorrectTaxType)
                        {
                            NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第" + lKeyRow + "行 应納税种 不符合规范!");
                            lNotifyWindow.Show();
                            return(false);
                        }
                    }
                }

                if (rowPair.Key == 32) // 第三十三行 备注
                {
                    try
                    {
                        Cell lCellNote = rowPair.Value.GetCell(1);
                        if (lCellNote.Value != null)
                        {
                            string lValueCellNote = lCellNote.Value.ToString().Trim();
                            StandBookEntity.Note = lValueCellNote;
                        }
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第三十三行 '备注' 出错!");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 33) // 第三十四行 完税凭证字别 完税证号码
                {
                    try
                    {
                        //Cell lCellFinishID = rowPair.Value.GetCell(1);
                        //string lValueFinishID = lCellFinishID.Value.ToString().Trim();

                        Cell lCellFinishNumber = rowPair.Value.GetCell(4);
                        if (lCellFinishNumber.Value != null)
                        {
                            string lValueFinishNumber = lCellFinishNumber.Value.ToString().Trim();
                            StandBookEntity.TaxReceiptNumber = lValueFinishNumber;
                        }
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第三十四行 '完税凭证字别 完税证号码' 出错!");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }

                if (rowPair.Key == 34) // 第三十五行 完税凭证字别 发票号码
                {
                    try
                    {
                        //Cell lCellFinishID = rowPair.Value.GetCell(1);
                        //string lValueFinishID = lCellFinishID.Value.ToString().Trim();

                        Cell lCellInvoiceNumber = rowPair.Value.GetCell(4);
                        if (lCellInvoiceNumber.Value != null)
                        {
                            string lValueInvoiceNumber = lCellInvoiceNumber.Value.ToString().Trim();
                            StandBookEntity.InvoiceNumber = lValueInvoiceNumber;
                        }
                    }
                    catch (Exception e)
                    {
                        NotifyWindow lNotifyWindow = new NotifyWindow("读取错误", "读取第三十五行 '完税凭证字别 发票号码' 出错!");
                        lNotifyWindow.Show();
                        return(false);
                    }
                }
            }
            return(true);
        }
Example #33
0
        private void onCreatePDFFile()
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                NotifyWindow notifyWindow = new NotifyWindow("错误", "请先输入生成PDF文件名称!");
                notifyWindow.Show();
                return;
            }

            if (ImagesList.Count == 0)
            {
                NotifyWindow notifyWindow = new NotifyWindow("错误", "请先添加文件!");
                notifyWindow.Show();
                return;
            }

            pdfDocument doc      = new pdfDocument(fileName, "", false);
            bool        getIamge = false;

            foreach (AddImageEntity imageEntity in ImagesList)
            {
                try
                {
                    WriteableBitmap bitmap;
                    using (FileStream fs = new FileStream(imageEntity.FilePath, FileMode.Open))
                    {
                        BitmapImage bi = new BitmapImage();
                        bi.SetSource(fs);
                        bitmap = new WriteableBitmap(bi);
                    }

                    if (null != bitmap)
                    {
                        pdfPage page = doc.addPage((int)bitmap.PixelHeight, (int)bitmap.PixelWidth);
                        page.addImage(bitmap, 0, 0);
                        getIamge             = true;
                        createPDFFileSuccess = true;
                    }
                    else
                    {
                        createPDFFileSuccess = false;
                    }
                }
                catch
                {
                    createPDFFileSuccess = false;

                    NotifyWindow notifyWindow = new NotifyWindow("错误", string.Format("打开图片文件{0}失败,请检查文件!!!", imageEntity.FilePath));
                    notifyWindow.Show();
                }
            }

            if (getIamge)
            {
                tempPDFFile = System.IO.Path.GetTempFileName();

                using (FileStream fs = new FileStream(tempPDFFile, FileMode.Create))
                {
                    doc.createPDF(fs);
                }


                UserFile            = new UserFile();
                UserFile.FileName   = fileName;
                UserFile.FileFolder = taxPayerEntity.TaxPayerId.ToString();
                UserFile.FileStream = (new FileInfo(tempPDFFile)).OpenRead();

                taxPayerDocumentEntity = new TaxPayerDocumentEntity();
                taxPayerDocumentEntity.TaxPayerDocumentBytes = UserFile.FileStream.Length;

                (OnUpdate as DelegateCommand).RaiseCanExecuteChanged();

                UpdateChanged("UserFile");
            }
        }