コード例 #1
0
        public GEEntity GenerGEMainEntity(string mainPK)
        {
            GEEntity en = new GEEntity(this.FK_MapData, mainPK);

            return(en);
        }
コード例 #2
0
        public void PrintDoc(BillTemplate en)
        {
            Node nd = new Node(this.FK_Node);
            Work wk = nd.HisWork;

            wk.OID = this.WorkID;
            wk.Retrieve();
            string msg  = "";
            string file = DataType.CurrentYear + "_" + WebUser.FK_Dept + "_" + en.No + "_" + this.WorkID + ".doc";

            BP.Pub.RTFEngine rtf = new BP.Pub.RTFEngine();
            //        Works works;
            string[] paths;
            string   path;

            try
            {
                #region 生成单据
                rtf.HisEns.Clear();
                rtf.EnsDataDtls.Clear();
                rtf.AddEn(wk);
                rtf.ensStrs += ".ND" + wk.NodeID;
                ArrayList al = wk.GetDtlsDatasOfArrayList();
                foreach (Entities ens in al)
                {
                    rtf.AddDtlEns(ens);
                }

                BP.Sys.GEEntity ge = new BP.Sys.GEEntity("ND" + int.Parse(nd.FK_Flow) + "Rpt");
                ge.Copy(wk);
                rtf.HisGEEntity = ge;

                paths = file.Split('_');
                path  = paths[0] + "/" + paths[1] + "/" + paths[2] + "/";

                path = BP.WF.Glo.FlowFileBill + DataType.CurrentYear + "\\" + WebUser.FK_Dept + "\\" + en.No + "\\";
                if (System.IO.Directory.Exists(path) == false)
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                // rtf.ensStrs = ".ND";
                rtf.MakeDoc(en.Url + ".rtf",
                            path, file, en.ReplaceVal, false);
                #endregion

                #region 转化成pdf.
                if (en.HisBillFileType == BillFileType.PDF)
                {
                    string rtfPath = path + file;
                    string pdfPath = rtfPath.Replace(".doc", ".pdf");
                    try
                    {
                        BP.WF.Glo.Rtf2PDF(rtfPath, pdfPath);

                        file = file.Replace(".doc", ".pdf");
                        System.IO.File.Delete(rtfPath);

                        file = file.Replace(".doc", ".pdf");
                        //System.IO.File.Delete(rtfPath);
                    }
                    catch (Exception ex)
                    {
                        msg += ex.Message;
                    }
                }
                #endregion

                string url = BP.WF.Glo.CCFlowAppPath + "DataUser/Bill/" + DataType.CurrentYear + "/" + WebUser.FK_Dept + "/" + en.No + "/" + file;
                this.Response.Redirect(url, false);
                //         BP.Sys.PubClass.OpenWordDocV2( path+file, en.Name);
            }
            catch (Exception ex)
            {
                BP.WF.DTS.InitBillDir dir = new BP.WF.DTS.InitBillDir();
                dir.Do();
                path = BP.WF.Glo.FlowFileBill + DataType.CurrentYear + "\\" + WebUser.FK_Dept + "\\" + en.No + "\\";
                string msgErr = "@生成单据失败,请让管理员检查目录设置 [" + BP.WF.Glo.FlowFileBill + "]。@Err:" + ex.Message + " @File=" + file + " @Path:" + path;
                throw new Exception(msgErr + "@其它信息:" + ex.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// 从另外的一个实体来copy数据.
        /// </summary>
        /// <param name="en"></param>
        public void CopyFromFrm(GEEntity en)
        {
            //先求出来旧的OID.
            Int64 oldOID = this.OID;

            //复制主表数据.
            this.Copy(en);
            this.Save();
            this.OID = oldOID;

            //复制从表数据.
            MapDtls dtls = new MapDtls(this.FK_MapData);

            //被copy的明细集合.
            MapDtls dtlsFrom = new MapDtls(en.FK_MapData);

            if (dtls.Count != dtls.Count)
            {
                throw new Exception("@复制的两个表单从表不一致...");
            }

            //序号.
            int i = 0;

            foreach (MapDtl dtl in dtls)
            {
                //删除旧的数据.
                BP.DA.DBAccess.RunSQL("DELETE FROM " + dtl.PTable + " WHERE RefPK=" + this.OID);

                //求对应的Idx的,从表配置.
                MapDtl dtlFrom    = dtlsFrom[i] as MapDtl;
                GEDtls ensDtlFrom = new GEDtls(dtlFrom.No);
                ensDtlFrom.Retrieve(GEDtlAttr.RefPK, oldOID);

                //创建一个实体.
                GEDtl dtlEnBlank = new GEDtl(dtl.No);

                // 遍历数据,执行copy.
                foreach (GEDtl enDtlFrom in ensDtlFrom)
                {
                    dtlEnBlank.Copy(enDtlFrom);
                    dtlEnBlank.RefPK = this.OID.ToString();
                    dtlEnBlank.SaveAsNew();
                }
                i++;
            }

            //复制附件数据.
            FrmAttachments aths     = new FrmAttachments(this.FK_MapData);
            FrmAttachments athsFrom = new FrmAttachments(en.FK_MapData);

            foreach (FrmAttachment ath in aths)
            {
                //删除数据,防止copy重复
                DBAccess.RunSQL("DELETE FROM Sys_FrmAttachmentDB WHERE FK_MapData='" + this.FK_MapData + "' AND RefPKVal='" + this.OID + "'");

                foreach (FrmAttachment athFrom in athsFrom)
                {
                    if (athFrom.NoOfObj != ath.NoOfObj)
                    {
                        continue;
                    }

                    FrmAttachmentDBs athDBsFrom = new FrmAttachmentDBs();
                    athDBsFrom.Retrieve(FrmAttachmentDBAttr.FK_FrmAttachment, athFrom.MyPK, FrmAttachmentDBAttr.RefPKVal, en.OID.ToString());
                    foreach (FrmAttachmentDB athDBFrom in athDBsFrom)
                    {
                        athDBFrom.MyPK             = BP.DA.DBAccess.GenerGUID();
                        athDBFrom.FK_FrmAttachment = ath.MyPK;
                        athDBFrom.RefPKVal         = this.OID.ToString();
                        athDBFrom.Insert();
                    }
                }
            }
        }