Example #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            var dataNbr = txtDataNbr.Text.Trim();

            if (string.IsNullOrEmpty(dataNbr))
            {
                MessageBox.Show("请输入单号!", "提示");
                return;
            }

            var result = JObject.Parse(Common.HttpPost(Common.GetApiUrl("GetImageListByDataNbr"), string.Format("dataNbr={0}", dataNbr)));

            if (!Convert.ToBoolean(result["success"].ToString()))
            {
                MessageBox.Show(result["info"].ToString(), "提示");
                return;
            }
            var data = JArray.Parse(result["data"].ToString());

            if (data.Count == 0)
            {
                MessageBox.Show("当前单号下没有查到影像!", "提示");
                return;
            }
            var path = "images/uploadimages/" + dataNbr + "/";

            if (Directory.Exists(path))
            {
                MessageBox.Show("当前单号已打开!", "提示");
                return;
            }

            Directory.CreateDirectory(path);
            var node = new TreeNode();

            node.Text = dataNbr;
            node.Tag  = "UploadDocNode";
            foreach (JObject item in data)
            {
                var img      = Image.FromStream(WebRequest.Create(Common.GetApiUrl("Priview") + "/" + item["ImageID"].ToString()).GetResponse().GetResponseStream());
                var filePath = Path.Combine(path, item["ImageName"].ToString());
                using (var bitMap = new Bitmap(img))
                {
                    bitMap.Save(filePath);
                    img.Dispose();
                }
                var remark = item["Remark"].ToString();
                if (!string.IsNullOrEmpty(remark))
                {
                    File.WriteAllText(filePath.Replace(".jpg", ".txt"), remark);
                }
                var childNode = new TreeNode();
                childNode.Text = item["ImageName"].ToString().Split('.')[0];
                childNode.Tag  = filePath;
                node.Nodes.Add(childNode);
            }
            treeView.Nodes.Add(node);
            TreeViewExtension.HideCheckBox(treeView, node);
            this.Close();
        }
Example #2
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try {
         if (e.RowIndex != -1)
         {
             if (e.ColumnIndex == 4)
             {
                 var dataItem = (Message)dataGridView1.Rows[e.RowIndex].DataBoundItem;
                 if (dataItem.bRead == false)
                 {
                     //更新消息状态
                     Common.HttpPost(Common.GetApiUrl("UpdateMessageStatus"), string.Format("msgID={0}", dataItem.ID));
                     if (eventrefresh != null)
                     {
                         eventrefresh();
                     }
                 }
                 frmViewMessage frm = new frmViewMessage();
                 frm.message = dataItem;
                 frm.ShowDialog();
             }
             if (e.ColumnIndex == 5)
             {
                 var dataItem = (Message)dataGridView1.Rows[e.RowIndex].DataBoundItem;
                 if (dataItem.bRead == false)
                 {
                     //更新消息状态
                     Common.HttpPost(Common.GetApiUrl("UpdateMessageStatus"), string.Format("msgID={0}", dataItem.ID));
                     if (eventrefresh != null)
                     {
                         eventrefresh();
                     }
                 }
                 var dataNbr = dataItem.DataNbr;
                 var result  = JObject.Parse(Common.HttpPost(Common.GetApiUrl("GetImageListByDataNbr"), string.Format("dataNbr={0}", dataNbr)));
                 if (!Convert.ToBoolean(result["success"].ToString()))
                 {
                     MessageBox.Show(result["info"].ToString(), "提示");
                     return;
                 }
                 var data = JArray.Parse(result["data"].ToString());
                 if (data.Count == 0)
                 {
                     MessageBox.Show("当前单号下没有查到影像!", "提示");
                     return;
                 }
                 var path = "images/uploadimages/" + dataNbr + "/";
                 if (Directory.Exists(path))
                 {
                     MessageBox.Show("当前单号已打开!", "提示");
                     return;
                 }
                 Directory.CreateDirectory(path);
                 var node = new TreeNode();
                 node.Text = dataNbr;
                 node.Tag  = "UploadDocNode";
                 foreach (JObject item in data)
                 {
                     var img      = Image.FromStream(WebRequest.Create(Common.GetApiUrl("Priview") + "/" + item["ImageID"].ToString() + "?datanbr=" + item["DataNbr"].ToString()).GetResponse().GetResponseStream());
                     var filePath = Path.Combine(path, item["ImageName"].ToString());
                     using (var bitMap = new Bitmap(img))
                     {
                         //下载时转换成JPG格式的图片
                         var eps = new EncoderParameters(1);
                         var ep  = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 85L);
                         eps.Param[0] = ep;
                         var jpsEncodeer = GetEncoder(ImageFormat.Jpeg);
                         bitMap.Save(filePath, jpsEncodeer, eps);
                         ep.Dispose();
                         eps.Dispose();
                         img.Dispose();
                     }
                     var remark = item["Remark"].ToString();
                     if (!string.IsNullOrEmpty(remark))
                     {
                         File.WriteAllText(filePath.Replace(".jpg", ".txt"), remark);
                     }
                     var childNode = new TreeNode();
                     childNode.Text = item["ImageName"].ToString().Split('.')[0];
                     childNode.Tag  = filePath;
                     node.Nodes.Add(childNode);
                 }
                 teee.Nodes.Add(node);
                 TreeViewExtension.HideCheckBox(teee, node);
                 this.Close();
             }
         }
     }
     catch (Exception) {
     }
 }
Example #3
0
        /// <summary>
        /// 添加分组
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnok_Click(object sender, EventArgs e)
        {
            string name = this.txtGroupName.Text.Trim();

            if (name == "0000000000")
            {
                MessageBox.Show("系统设置'0000000000'无法添加!", "提示");
                return;
            }
            if (string.IsNullOrEmpty(name))
            {
                if (_kind == "AddGroup")
                {
                    MessageBox.Show("请输入分组名称!", "提示");
                }
                else
                {
                    MessageBox.Show("请输入单据号!", "提示");
                }
                return;
            }
            var uploadDataNbrs = CheckUploadImage(string.Join(",", name));

            if (_kind != "AddGroup")
            {
                if (string.IsNullOrEmpty(uploadDataNbrs))
                {
                    MessageBox.Show(string.Format("单据号" + name + "不存在财务系统中!", uploadDataNbrs), "提示");
                    return;
                }
            }

            if (!string.IsNullOrEmpty(name))
            {
                TreeNode      node      = new TreeNode();
                List <string> groupName = new List <string>();
                foreach (TreeNode n in tree.Nodes)
                {
                    if (n.Tag != null)
                    {
                        groupName.Add(n.Text);
                    }
                }
                if (!groupName.Contains(name))
                {
                    node.Text = name;
                    node.Tag  = this._kind == "AddGroup" ? "DocNode" : "SupplementDocNode";
                    tree.Nodes.Add(node);
                    TreeViewExtension.HideCheckBox(tree, node);
                    var    dirName = this._kind == "AddGroup" ? "" : "supplementimages";
                    string path    = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "images\\" + dirName + "\\" + node.Text);
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    if (eventgroup != null)
                    {
                        eventgroup(name, node);
                    }
                    this.Close();
                }
                else
                {
                    if (_kind == "AddGroup")
                    {
                        MessageBox.Show("该分组名称已存在!", "提示");
                    }
                    else
                    {
                        MessageBox.Show("该单据号已存在!", "提示");
                    }
                }
            }
        }