Exemplo n.º 1
0
        private void ProcLoad()
        {
            try
            {
                UpdateWaitMessage(@"创建本地照片处理临时文件夹");
                DressManager.CreateTempDirectory();

                UpdateWaitMessage(@"拉取服务器照片文件到本地");
                IEnumerable <string> thumbs = DressManager.DownloadToTemp(Scene);

                UpdateWaitMessage(@"加载图片");
                Invoke((Action <IEnumerable <string> >)(files =>
                {
                    photoManager.Photos.AddRange(files);
                    photoManager.UpdatePhotos();
                }), thumbs);

                Invoke(new MethodInvoker(CloseWaitFrm));
            }
            catch (Exception ex)
            {
                Invoke(new MethodInvoker(() =>
                {
                    CloseWaitFrm();
                    MessageBoxEx.Info(string.Format(@"加载照片失败!{0}{1}", Environment.NewLine, ex.Message));
                }));
            }
        }
Exemplo n.º 2
0
 private void ProcDelete()
 {
     try
     {
         //UpdateWaitMessage(@"删除数据库记录及对应文件夹");
         IEnumerable <Scene> themes = DressManager.GetScenes((Theme)SelectedObject);
         foreach (Scene theme in themes)
         {
             DressManager.DeleteScene(theme);
         }
         DressManager.DeleteThemeObject((Theme)SelectedObject);
         //Invoke()
         //UpdateWaitMessage(@"加载数据");
         Invoke(new MethodInvoker(OnDeleteComplete));
     }
     catch (Exception ex)
     {
         Invoke(new MethodInvoker(() =>
         {
             //CloseWaitFrm();
             MessageBoxEx.Info(string.Format(@"删除风格失败!{0}{1}", Environment.NewLine, ex.Message));
             //Close(); // 关闭窗口防止发生其他意外
         }));
     }
 }
Exemplo n.º 3
0
 protected virtual void OnDeleteComplete()
 {
     MessageBoxEx.Info(@"删除成功!");
     Objects = Objects.Where(o => o.ID != SelectedObject.ID).ToList();
     if (Objects.Count == 0)
     {
         SelectedObject = null;
     }
 }
Exemplo n.º 4
0
 private bool CanNew()
 {
     if (string.IsNullOrWhiteSpace(DressToNew.BarCode))
     {
         MessageBoxEx.Info(@"请填写礼服条码!");
         txtBarCode.Highlight();
         return(false);
     }
     if (string.IsNullOrWhiteSpace(DressToNew.UseName))
     {
         MessageBoxEx.Info(@"请填写礼服用途!");
         cmbUse.Focus();
         return(false);
     }
     if (string.IsNullOrWhiteSpace(DressToNew.SupplierName))
     {
         MessageBoxEx.Info(@"请填写供应商!");
         cmbSupplier.Focus();
         return(false);
     }
     if (string.IsNullOrWhiteSpace(DressToNew.AreaNo))
     {
         MessageBoxEx.Info(@"请选择礼服区域!");
         btnPickArea.Focus();
         return(false);
     }
     if (string.IsNullOrWhiteSpace(DressToNew.LevelNo))
     {
         MessageBoxEx.Info(@"请选择规格档次!");
         cmbLevel.Focus();
         return(false);
     }
     if (string.IsNullOrWhiteSpace(PhotoFilePath))
     {
         MessageBoxEx.Info(@"请打开一张礼服图片!");
         photoPicker.Focus();
         return(false);
     }
     if (string.IsNullOrWhiteSpace(ServerPath))
     {
         MessageBoxEx.Info(@"请选择服务器路径!");
         cmbServerPath.Focus();
         return(false);
     }
     if (!Directory.Exists(ServerPath))
     {
         MessageBoxEx.Info(@"当前选择的服务器路径不存在或无法访问!");
         cmbServerPath.Focus();
         return(false);
     }
     return(true);
 }
Exemplo n.º 5
0
 public void SaveOperateProcessLog(string process, string logoType, string logoContext)
 {
     try
     {
         string strSql = string.Format(@"INSERT INTO Logo (Process, DepartmentNO, EmployeeNO, [Create], CreateDate, LogoType, LogoContext) 
                                     VALUES ('{0}', '{1}', '{2}', '{3}', GETDATE(), '{4}', '{5}')", process, Information.CurrentUser.EmployeeDepartmentNO, Information.CurrentUser.EmployeeNO, Information.CurrentUser.EmployeeName, logoType, logoContext);
         ExecuteNonQuery(strSql);
     }
     catch (Exception ex)
     {
         MessageBoxEx.Info(string.Format(@"操作日志记录失败!{0}{1}", Environment.NewLine, ex.Message));
     }
 }
Exemplo n.º 6
0
        private void ProcDelete()
        {
            try
            {
                DressManager.DeleteScene((Scene)SelectedObject);

                Invoke(new MethodInvoker(OnDeleteComplete));
            }
            catch (Exception ex)
            {
                Invoke(new MethodInvoker(() =>
                {
                    MessageBoxEx.Info(string.Format(@"删除场景失败!{0}{1}", Environment.NewLine, ex.Message));
                }));
            }
        }
Exemplo n.º 7
0
        private void ProcDeletePhoto()
        {
            try
            {
                IEnumerable <string> thumbFiles = photoManager.SelectedPhotoFilePaths;
                var files = thumbFiles as string[] ?? thumbFiles.ToArray();
                IEnumerable <string> largeFiles = DressManager.GetLarge(files);

                if (files.Any())
                {
                    DressManager.DeleteServerFile(files, Scene);
                    UpdateWaitMessage(@"删除数据库记录及服务器文件");
                    UpdateWaitMessage(@"删除临时文件夹中的文件");
                    FileTool.DeleteFiles(files);
                }
                else
                {
                    Invoke(new MethodInvoker(() =>
                    {
                        CloseWaitFrm();
                        MessageBox.Show(@"没有选中照片!");
                    }));
                    return;
                }
                FileTool.DeleteFiles(largeFiles);

                UpdateWaitMessage(@"加载照片");
                Invoke(new MethodInvoker(() => photoManager.RemoveSelected()));

                Invoke(new MethodInvoker(() =>
                {
                    CloseWaitFrm();
                    MessageBoxEx.Info(@"删除照片成功");
                }));
            }
            catch (Exception ex)
            {
                Invoke(new MethodInvoker(() =>
                {
                    CloseWaitFrm();
                    MessageBoxEx.Info(string.Format(@"删除照片失败!{0}{1}", Environment.NewLine, ex.Message));
                    Close(); // 关闭窗口防止发生其他意外
                }));
            }
        }
Exemplo n.º 8
0
 private void btnChangeArea_Click(object sender, EventArgs e)
 {
     new FrmAreaPicker
     {
         AfterPick = node =>
         {
             try
             {
                 RuleObject area = (RuleObject)node.Tag;
                 DressManager.ChangeArea(Barcode, area, venueName, Information.CurrentUser.EmployeeNO2, Information.CurrentUser.EmployeeDepartmentNO);
                 MessageBoxEx.Info(@"变更成功!");
             }
             catch (Exception ex)
             {
                 MessageBoxEx.Error(ex.Message);
             }
         }
     }.Show();
 }
Exemplo n.º 9
0
        private void ModifyOld()
        {
            string serverPhotoPath = null;

            try
            {
                UpdateWaitMessage(@"上传照片");
                serverPhotoPath = DressManager.UploadDressPhoto(PhotoFilePath, ServerPath);

                UpdateWaitMessage(@"写入数据库");
                DressManager.OldDressModify(DressToNew, serverPhotoPath);

                Invoke((Action)(() =>
                {
                    CloseWaitFrm();
                    MessageBoxEx.Info(@"修改礼服成功!");
                    txtBarCode.Text = string.Empty;
                }));
            }
            catch (Exception ex)
            {
                try
                {
                    // 删除服务器上已经上传的照片
                    if (null != serverPhotoPath)
                    {
                        DressManager.DeleteDressPhoto(serverPhotoPath);
                    }

                    Invoke((Action)(() =>
                    {
                        CloseWaitFrm();
                        MessageBoxEx.Error(string.Format(@"修改礼服失败!{0}{1}", Environment.NewLine, ex.Message));
                    }));
                }
                catch
                {
                    // 防止二次报错
                }
            }
        }
Exemplo n.º 10
0
 private void 屏蔽ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvDressesShow.CurrentRow != null && dgvDressesShow.CurrentRow.Cells["DressStatus"].Value.ToString() == @"屏蔽")
         {
             MessageBox.Show(@"该礼服已屏蔽!");
             return;
         }
         if (dgvDressesShow.CurrentRow != null)
         {
             DressManager.EliminateDress(dgvDressesShow.CurrentRow.Cells["DressBarCode"].Value.ToString(), @"屏蔽");
             MessageBoxEx.Info(@"屏蔽成功!");
             dgvDressesShow.CurrentRow.Cells["DressStatus"].Value = @"屏蔽";
         }
     }
     catch (Exception ex)
     {
         MessageBoxEx.Error(ex.Message);
     }
 }
Exemplo n.º 11
0
        private void ProcAddPhoto(object objFiles)
        {
            IEnumerable <string> originalFiles    = (IEnumerable <string>)objFiles;
            IEnumerable <string> files            = null;
            IEnumerable <string> thumbFiles       = null;
            IEnumerable <string> largeFiles       = null;
            IEnumerable <string> SHA1Files        = null;
            IEnumerable <string> serverFiles      = null;
            IEnumerable <string> serverThumbFiles = null;
            IEnumerable <string> serverLargeFiles = null;
            IEnumerable <string> serverSHA1Files  = null;

            try
            {
                UpdateWaitMessage(@"将原图迁移至临时处理文件夹");
                files = DressManager.CopyPhotoToTemp(originalFiles);

                UpdateWaitMessage(@"生成缩略图");
                thumbFiles = DressManager.GenerateThumb(files);

                UpdateWaitMessage(@"生成大图");
                largeFiles = DressManager.GenerateLarge(files);

                UpdateWaitMessage(@"生成SHA1校验码文件");
                SHA1Files = DressManager.GenerateSHA1(files);

                UpdateWaitMessage(@"上传照片到服务器");
                serverFiles      = DressManager.UploadToServer(files, Scene, ServerPath);
                serverThumbFiles = DressManager.UploadToServer(thumbFiles, Scene, ServerPath);
                serverLargeFiles = DressManager.UploadToServer(largeFiles, Scene, ServerPath);
                serverSHA1Files  = DressManager.UploadToServer(SHA1Files, Scene, ServerPath);

                UpdateWaitMessage(@"写入数据库");
                ErpService.DressManagement.NewScenePhoto(serverFiles, Scene);

                UpdateWaitMessage(@"加载照片");
                Invoke((Action <IEnumerable <string> >)(fs => photoManager.AddPhotos(fs)), thumbFiles);

                Invoke(new MethodInvoker(() =>
                {
                    CloseWaitFrm();
                    MessageBoxEx.Info(@"添加照片成功");
                }));
            }
            catch (Exception ex)
            {
                // 删除所有产生的文件
                FileTool.DeleteFiles(files);
                FileTool.DeleteFiles(thumbFiles);
                FileTool.DeleteFiles(largeFiles);
                FileTool.DeleteFiles(SHA1Files);
                FileTool.DeleteFiles(serverFiles);
                FileTool.DeleteFiles(serverThumbFiles);
                FileTool.DeleteFiles(serverLargeFiles);
                FileTool.DeleteFiles(serverSHA1Files);

                Invoke(new MethodInvoker(() =>
                {
                    CloseWaitFrm();
                    MessageBoxEx.Info(string.Format(@"添加照片失败!{0}{1}", Environment.NewLine, ex.Message));
                }));
            }
        }
Exemplo n.º 12
0
 protected virtual void OnSaveComplete()
 {
     MessageBoxEx.Info(@"添加成功!");
     Close();
 }
Exemplo n.º 13
0
 protected virtual void OnSaveComplete()
 {
     MessageBoxEx.Info(@"修改信息成功!");
     RefreshData();
 }