/// <summary>
        /// 集中管理-作废订单
        /// </summary>
        public bool UpdateOrdersCancellation(string username, string strordernum, string reason)
        {
            bool   b   = true;
            string str = SelectOrderbarcodeByBill(strordernum);

            if (str == null && str == "")
            {
                Hashtable ht = new Hashtable();
                ht["cancelby"] = username;
                ht["ordernum"] = strordernum;
                ht["reason"]   = reason;
                try
                {
                    if (this.update("Order.Cancellation", ht) < 0)
                    {
                        b = false;
                    }
                }
                catch (Exception)
                {
                    b = false;
                }
            }
            else
            {
                SortedList SQLlist = new SortedList(new MySort());
                Hashtable  ht      = new Hashtable();
                ht["cancelby"] = username;
                ht["ordernum"] = strordernum;
                ht["reason"]   = reason;
                try
                {
                    SQLlist.Add(new Hashtable()
                    {
                        { "UPDATE", "Order.Cancellation" }
                    }, ht);
                    var      library = new BillheadService();
                    string[] order   = strordernum.TrimEnd(',').Split(',');
                    for (int j = 0; j < order.Count(); j++)
                    {
                        Orders orders = new ProRegisterService().SelectOrderInfo(order[j]);
                        if (orders.Ordersource == "0") //这里只修改个人体检账单
                        {
                            List <Billdetail> billdetail = new BilldetailService().GetBilldetailByOrderNum(order[j]);
                            if (billdetail.Count > 0)
                            {
                                for (int m = 0; m < billdetail.Count; m++)
                                {
                                    if (billdetail[m].Billheadid != null)
                                    {
                                        Hashtable htnew = new Hashtable();
                                        htnew.Add("status", (int)daan.service.common.ParamStatus.BillheadStatus.Invalid);
                                        htnew.Add("billheadid", billdetail[m].Billheadid);
                                        SQLlist.Add(new Hashtable()
                                        {
                                            { "UPDATE", "Bill.UpdateBillheadRefundment" }
                                        }, htnew);
                                    }
                                }
                            }
                            // outorderNum[0] = order[j];
                        }
                    }
                    if (library.ExecuteSqlTran(SQLlist))
                    {
                        b = true;
                    }
                }
                catch (Exception)
                {
                    b = false;
                }
            }
            return(b);
        }
Пример #2
0
        /// <summary>
        /// 从报告上传社区扫描程序目录下获取已生成的PDF文件,转移至等创建的待压缩目录下
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDownload_Click(object sender, EventArgs e)
        {
            List <string> ordernums = new List <string>(); //存放身份证_体检号_姓名的PDF命名
            List <string> idnumbers = new List <string>(); //存放体检号_姓名的PDF命名
            DataTable     dt        = new DataTable();
            //StringBuilder strExists = new StringBuilder();//不存在的文件清单
            string pdfFile = ConfigurationManager.AppSettings["PdfFile"].ToString();//获取需要下载的报告路径,此路径为报告上传社区扫描程序的路径

            #region >>>>获取选中行的订单号并判断是否已完成总检和财务审核
            foreach (int row in gdOrders.SelectedRowIndexArray)
            {
                Orders order = new ProRegisterService().SelectOrderInfo(gdOrders.DataKeys[row][0].ToString());
                if (order.Status == "25" || order.Status == "30")
                {
                    if (IsNeedFinanceAudit && gdOrders.DataKeys[row][5].ToString() == "1")
                    {
                        if (gdOrders.DataKeys[row][3] == null)
                        {
                            idnumbers.Add("");
                        }
                        else
                        {
                            idnumbers.Add(string.Format("{0}_{1}_{2}.pdf", gdOrders.DataKeys[row][3].ToString(), gdOrders.DataKeys[row][0].ToString(), gdOrders.DataKeys[row][2].ToString()));
                        }
                        ordernums.Add(string.Format("{0}_{1}.pdf", gdOrders.DataKeys[row][0].ToString(), gdOrders.DataKeys[row][2].ToString()));
                    }
                }
            }
            if (ordernums.Count() <= 0)
            {
                MessageBoxShow("请至少选择一项状态为完成总检或报告已打印且财务已审核的记录!");
                return;
            }
            #endregion

            #region >>>>  检查目录是否存在,如不存在则创建,存在则删除该文件夹所有文件并重新创建

            string foldername = string.Format("{0}_{1}", Userinfo.userName, DateTime.Now.ToString("yyyyMMddHHmmssfff")); //存放PDF待转移压缩目标文件夹的名字
            string fullpath   = string.Format("{0}{1}\\", Server.MapPath("../../upload/Pdffile/"), foldername);          //完整文件夹名

            FileInfo fileInfo = new FileInfo(fullpath);
            if (fileInfo.Directory.Exists == false)
            {
                //如果目录不存在,则创建该目录
                try { fileInfo.Directory.Create(); }
                catch (Exception ex)
                {
                    MessageBoxShow("创建文件夹出错,错误信息:" + ex.Message);
                    return;
                }
            }
            else
            {
                //删除整个文件夹之后创建文件夹
                try { WebUtils.DeleteFolder(fullpath); fileInfo.Directory.Create(); }
                catch (Exception ex)
                {
                    MessageBoxShow("创建文件夹出错,错误信息:" + ex.Message);
                    return;
                }
            }
            #endregion

            #region >>>>  复制报告到指定文件夹
            for (int i = 0; i < ordernums.Count; i++)
            {
                string fileIdNumberName = idnumbers[i].ToString();
                string fileOrderNumName = ordernums[i].ToString();
                try
                {
                    //复制pdf报告,先验证身份证命名的文件是否存在,不存在则按体检号命名,都不存在时提示用户
                    if (File.Exists(pdfFile + fileIdNumberName))
                    {
                        File.Copy(pdfFile + fileIdNumberName, fullpath + fileIdNumberName, true);
                    }
                    else
                    {
                        if (File.Exists(pdfFile + fileOrderNumName))
                        {
                            File.Copy(pdfFile + fileOrderNumName, fullpath + fileOrderNumName, true);
                        }
                        //else
                        //{
                        //    strExists.AppendFormat("{0},", fileOrderNumName);
                        //}
                    }
                }
                catch (Exception)
                {
                    MessageBoxShow(pdfFile + fileOrderNumName + "*" + fullpath + fileOrderNumName + "报告可能不存在,请选择总检完的报告!");
                    return;
                }
            }
            #endregion

            //if (strExists.ToString().TrimStart(',').TrimEnd(',').Length > 0)
            //{
            //    MessageBoxShow(string.Format("以下报告不存在,请用PDF虚拟打印机单个下载:{0}", strExists.ToString()));
            //}


            #region >>>>  压缩 供用户下载
            string workpath = fullpath;
            string path     = fullpath;

            string rarfullname = string.Format("{0}.rar", foldername);//存放文件的文件夹名字
            if (File.Exists(workpath + rarfullname))
            {
                File.Delete(workpath + rarfullname);
            }
            String           the_rar;
            RegistryKey      the_Reg;
            Object           the_Obj;
            String           the_Info;
            ProcessStartInfo the_StartInfo;
            Process          the_Process;
            the_Reg = Registry.ClassesRoot.OpenSubKey("WinRAR\\Shell\\Open\\Command");
            the_Obj = the_Reg.GetValue("");
            the_rar = the_Obj.ToString();
            the_Reg.Close();
            the_rar                        = the_rar.Substring(1, the_rar.Length - 7);
            the_Info                       = " a -ep " + rarfullname + "  " + path;//压缩命令可参见rar帮助文档
            the_StartInfo                  = new ProcessStartInfo();
            the_StartInfo.FileName         = the_rar;
            the_StartInfo.Arguments        = the_Info;
            the_StartInfo.WindowStyle      = ProcessWindowStyle.Hidden;
            the_StartInfo.WorkingDirectory = workpath;//获取或设置要启动的进程的初始目录。


            the_Process           = new Process();
            the_Process.StartInfo = the_StartInfo;
            the_Process.Start();
            the_Process.WaitForExit(100000);
            the_Process.Close();



            if (!File.Exists(workpath + rarfullname))
            {
                MessageBoxShow("报告压缩文件不存在");
                return;
            }
            else
            {
                Response.Redirect(string.Format("../../upload/Pdffile/{0}/{1}.rar", foldername, foldername));
            }
            #endregion
        }