Esempio n. 1
0
        /// <summary>
        /// 上传图片
        /// </summary>
        private void UploadUserImage()
        {
            MemoryStream memStream  = new MemoryStream();
            ImageCache   imageCache = new ImageCache();

            //拍照上传
            if (cameraTool != null && cameraTool.BitmapData != null && isChangeImage)
            {
                cameraTool.BitmapData.Save(memStream, ImageFormat.Jpeg);
                imageCache.SaveImageCache(userImageFolder, pictureName, memStream);
                memStream.Dispose();
                memStream.Close();
            }
            else
            //导入上传
            if (open_file.FileName != null && pictureName != "")
            {
                pic_userimg.Image.Save(memStream, ImageFormat.Jpeg);
                imageCache.SaveImageCache(userImageFolder, pictureName, memStream);
                memStream.Dispose();
                memStream.Close();
            }

            if (imageName != "")
            {
                imageCache.DeleteImageCache(userImageFolder, imageName);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 拍照上传图片
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void but_scan_Click(object sender, EventArgs e)
 {
     isChangeImage = true;
     cameraTool    = new Cnas.wns.CnasCameraUC.ControlCameraTools();
     if (cameraTool.ShowDialog() == DialogResult.OK)
     {
         System.Drawing.Image aa = cameraTool.BitmapData.GetThumbnailImage(80, 85, null, IntPtr.Zero);
         pic_userimg.Image = aa;
         ImageCache    imageCache      = new ImageCache();
         CnasRemotCall reCnasRemotCall = new CnasRemotCall();
         string        guid            = reCnasRemotCall.RemotInterface.Get_SerialNumber(1);
         pictureName = string.Format("{0}.jpg", guid);
         imageCache.DeleteImageCache(userImageFolder, pictureName);
     }
 }
Esempio n. 3
0
 private void OnDeleteBtnClick(object sender, EventArgs e)
 {
     if (pictureGrid.CurrentRow != null)
     {
         if (MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("choicedelete2", EnumPromptMessage.warning), "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
         {
             string imageName = pictureGrid.CurrentRow.Cells["imageNameCol"].Value != null ?
                                pictureGrid.CurrentRow.Cells["imageNameCol"].Value.ToString() : string.Empty;
             string imageId = pictureGrid.CurrentRow.Cells["imageIdCol"].Value != null ?
                              pictureGrid.CurrentRow.Cells["imageIdCol"].Value.ToString() : string.Empty;
             if (!string.IsNullOrEmpty(imageName))
             {
                 ImageCache imageCache = new ImageCache();
                 imageCache.DeleteImageCache(_uploadFolder, imageName.Contains(_imageNamePrefix) ? imageName.Substring(_imageNamePrefix.Length) : imageName);
                 SortedList sqlParameters = new SortedList();
                 SortedList imageItem     = new SortedList();
                 sqlParameters.Add(1, imageItem);
                 imageItem.Add(1, imageName);
                 string        sql        = string.IsNullOrEmpty(imageId) ? "HCS_image_delete001" : "HCS_image_delete002";
                 CnasRemotCall remoteCall = new CnasRemotCall();
                 string        testSql    = remoteCall.RemotInterface.CheckUPDataList(sql, sqlParameters);
                 int           result     = remoteCall.RemotInterface.UPDataList(sql, sqlParameters);
                 if (result > 0)
                 {
                     pictureGrid.Rows.Remove(pictureGrid.CurrentRow);
                 }
             }
             else
             {
                 pictureGrid.Rows.Remove(pictureGrid.CurrentRow);
             }
             if (pictureGrid.RowCount == 0)
             {
                 picturePreview.Images.Clear();
                 picturePreview.SelectImage = null;
             }
         }
     }
     else
     {
         MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("removedata", EnumPromptMessage.warning), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 4
0
 private void OnFormClosed(object sender, FormClosedEventArgs e)
 {
     foreach (DataGridViewRow item in pictureGrid.Rows)
     {
         string imageName = item.Cells["imageNameCol"].Value != null ?
                            item.Cells["imageNameCol"].Value.ToString() : string.Empty;
         if (!string.IsNullOrEmpty(imageName))
         {
             ImageCache imageCache = new ImageCache();
             imageCache.DeleteImageCache(_uploadFolder, imageName);
             SortedList sqlParameters = new SortedList();
             SortedList imageItem     = new SortedList();
             sqlParameters.Add(1, imageItem);
             imageItem.Add(1, imageName);
             CnasRemotCall remoteCall = new CnasRemotCall();
             string        testSql    = remoteCall.RemotInterface.CheckUPDataList("HCS_image_delete001", sqlParameters);
             int           result     = remoteCall.RemotInterface.UPDataList("HCS_image_delete001", sqlParameters);
         }
     }
 }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void but_remove_Click(object sender, EventArgs e)
        {
            try
            {
                //判断用户是否有选择行
                if (this.dgv_imageList.SelectedRows.Count > 0)
                {
                    CnasRemotCall reCnasRemotCall = new CnasRemotCall();
                    SortedList    sltmp           = new SortedList();
                    SortedList    sltmp01         = new SortedList();
                    //状态
                    sltmp01.Add(1, 9);
                    //图片ID
                    sltmp01.Add(2, dgv_imageList.SelectedRows[0].Cells["id"].Value.ToString());
                    sltmp.Add(1, sltmp01);

                    DialogResult dialogResult = MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("choicedelete", EnumPromptMessage.warning, new string[] { this.dgv_imageList.SelectedRows[0].Cells["entity_name"].Value.ToString(), "图片" }), "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    //if (MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("choicedelete", EnumPromptMessage.warning, new string[] { dgv_01.SelectedRows[0].Cells["ca_name"].Value.ToString(), "基本包" }), "删除基本包", MessageBoxButtons.YesNo) == DialogResult.No) return;
                    if (dialogResult == System.Windows.Forms.DialogResult.OK)
                    {
                        //  string up = reCnasRemotCall.RemotInterface.CheckUPData(1, "HCS_image-data-del001", sltmp, null);

                        //删除选中行的缓存图片
                        ImageCache imageCache = new ImageCache();
                        imageCache.DeleteImageCache(folderName, dgv_imageList.SelectedRows[0].Cells["data_url"].Value.ToString());
                        //根据ID改变图片的状态,变为不可用
                        int recint = reCnasRemotCall.RemotInterface.UPData(1, "HCS_image-data-del001", sltmp, null);
                        if (recint > -1)
                        {
                            MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("deletesuccessful", EnumPromptMessage.warning, new string[] { "图片" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            DataBaind();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 导入图片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void but_import_Click(object sender, EventArgs e)
        {
            open_file.Multiselect = false;
            open_file.Filter      = "png图片文件|*.png|jpg图片文件|*.jpg";
            if (open_file.ShowDialog() == DialogResult.OK)
            {
                //验证用户是否选择了多张文件
                if (open_file.FileNames.Length > 1)
                {
                    return;
                }

                pic_userimg.Image = new Bitmap(open_file.FileName);

                ImageCache    imageCache      = new ImageCache();
                CnasRemotCall reCnasRemotCall = new CnasRemotCall();

                string guid = reCnasRemotCall.RemotInterface.Get_SerialNumber(1);
                pictureName = string.Format("{0}.jpg", guid);
                imageCache.DeleteImageCache(userImageFolder, pictureName);
            }
        }
        /// <summary>
        /// 窗口取消关闭 时删除所有上传文件记录
        /// </summary>
        private void OnFormClosed()
        {
            //如果后台线程还在处理,则停止
            if (uploadFileWorker.IsBusy)
            {
                uploadFileWorker.CancelAsync();
            }
            if (MessageBox.Show("本次上传的图片将删除..如果要保存则确认.", "信息提示", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }
            SaveFiles = new Dictionary <string, string>();
            string tempCode = _imageMode != 3 ? BatchNum : BarCode;

            foreach (DataGridViewRow item in pictureGrid.Rows)
            {
                string imageName = item.Cells["imageNameCol"].Value != null ?
                                   item.Cells["imageNameCol"].Value.ToString() : string.Empty;
                if (!string.IsNullOrEmpty(imageName) && !_oldFiles.ContainsKey(imageName))
                {
                    ImageCache imageCache = new ImageCache();
                    imageCache.DeleteImageCache(_uploadFolder, imageName);
                    SortedList sqlParameters = new SortedList();
                    SortedList imageItem     = new SortedList();
                    sqlParameters.Add(1, imageItem);
                    imageItem.Add(1, OrderHelper.GetUploadType());  //type
                    imageItem.Add(2, imageName);                    //data_url
                    CnasRemotCall remoteCall = new CnasRemotCall();
                    string        testSql    = remoteCall.RemotInterface.CheckUPDataList("HCS_image_delete003", sqlParameters);
                    int           result     = remoteCall.RemotInterface.UPDataList("HCS_image_delete003", sqlParameters);
                }
                if (_oldFiles.ContainsKey(imageName))
                {
                    SaveFiles.Add(imageName, tempCode);
                }
            }
            Close();
        }
Esempio n. 8
0
        private void DeleteTempImages(string preSelectionPrefix)
        {
            SortedList deleteImage = new SortedList();

            foreach (DataGridViewRow dataRow in pictureGrid.Rows)
            {
                string imageState = Convert.ToString(dataRow.Cells["imageStateCol"].Value);
                string imageName  = Convert.ToString(dataRow.Cells["imageNameCol"].Value);
                if (imageState == "8")
                {
                    deleteImage.Add(deleteImage.Count + 1, imageName);
                }
            }

            if (deleteImage != null && deleteImage.Count > 0)
            {
                System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    CnasRemotCall remoteCall = new CnasRemotCall();
                    for (int i = 0; i < deleteImage.Count; i++)
                    {
                        ImageCache imageCache = new ImageCache();
                        string imageName      = Convert.ToString(deleteImage.GetByIndex(i));
                        if (!string.IsNullOrEmpty(imageName))
                        {
                            imageCache.DeleteImageCache(_uploadFolder, imageName.Contains(preSelectionPrefix) ? imageName.Substring(preSelectionPrefix.Length) : imageName);
                        }
                    }

                    SortedList sqlParameter = new SortedList();
                    sqlParameter.Add(1, deleteImage);
                    string deleteSQL = remoteCall.RemotInterface.CheckUPDataList("HCS_image_delete001", sqlParameter);
                    remoteCall.RemotInterface.UPDataList("HCS_image_delete001", sqlParameter);
                });
            }
        }
 /// <summary>
 /// 删除事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnDeleteBtnClick(object sender, EventArgs e)
 {
     if (pictureGrid.CurrentRow != null)
     {
         if (MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("choicedelete2", EnumPromptMessage.warning), "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
         {
             string imageName = pictureGrid.CurrentRow.Cells["imageNameCol"].Value != null ?
                                pictureGrid.CurrentRow.Cells["imageNameCol"].Value.ToString() : string.Empty;
             if (!string.IsNullOrEmpty(imageName))
             {
                 ImageCache imageCache = new ImageCache();
                 imageCache.DeleteImageCache(_uploadFolder, imageName);
                 SortedList sqlParameters = new SortedList();
                 SortedList imageItem     = new SortedList();
                 sqlParameters.Add(1, imageItem);
                 imageItem.Add(1, OrderHelper.GetUploadType());
                 imageItem.Add(2, imageName);
                 CnasRemotCall remoteCall = new CnasRemotCall();
                 string        testSql    = remoteCall.RemotInterface.CheckUPDataList("HCS_image_delete003", sqlParameters);
                 int           result     = remoteCall.RemotInterface.UPDataList("HCS_image_delete003", sqlParameters);
                 if (result > 0)
                 {
                     pictureGrid.Rows.Remove(pictureGrid.CurrentRow);
                 }
             }
             else
             {
                 pictureGrid.Rows.Remove(pictureGrid.CurrentRow);
             }
         }
     }
     else
     {
         MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("removedata", EnumPromptMessage.warning), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }