Example #1
0
        /// <summary>
        /// 生成单据根据
        /// </summary>
        /// <param name="templeteFile">模板文件</param>
        /// <param name="saveToFile"></param>
        /// <param name="mainDT"></param>
        /// <param name="dtls"></param>
        public void MakeDocByDataSet(string templeteFile, string saveToPath,
                                     string saveToFileName, DataTable mainDT, DataSet dtlsDS)
        {
            string valMain = DBAccess.RunSQLReturnString("SELECT NO FROM SYS_MapData");

            this.HisGEEntity = new GEEntity(valMain);
            this.HisGEEntity.Row.LoadDataTable(mainDT, mainDT.Rows[0]);
            this.AddEn(this.HisGEEntity); //增加一个主表。
            if (dtlsDS != null)
            {
                foreach (DataTable dt in dtlsDS.Tables)
                {
                    string        dtlID = DBAccess.RunSQLReturnString("SELECT NO FROM SYS_MapDtl ");
                    BP.Sys.GEDtls dtls  = new BP.Sys.GEDtls(dtlID);
                    foreach (DataRow dr in dt.Rows)
                    {
                        BP.Sys.GEDtl dtl = dtls.GetNewEntity as BP.Sys.GEDtl;
                        dtl.Row.LoadDataTable(dt, dr);
                        dtls.AddEntity(dtl);
                    }
                    this.AddDtlEns(dtls); //增加一个明晰。
                }
            }

            this.MakeDoc(templeteFile, saveToPath, saveToFileName, "", false);
        }
Example #2
0
        public bool IsChange(GEDtl dtl)
        {
            Attrs attrs = dtl.EnMap.Attrs;

            foreach (Attr attr in attrs)
            {
                if (this.GetValByKey(attr.Key) == dtl.GetValByKey(attr.Key))
                {
                    continue;
                }
                else
                {
                    return(true);
                }
            }
            return(false);
        }
        void btn_Pub_Click(object sender, EventArgs e)
        {
            #region 获得选择的ID
            string ids = "";
            foreach (Control ctl in this.Pub2.Controls)
            {
                if (ctl == null || ctl.ID == null || ctl.ID.Contains("CB_") == false)
                {
                    continue;
                }

                CheckBox cb = ctl as CheckBox;
                if (cb == null)
                {
                    continue;
                }

                if (cb.Checked == false)
                {
                    continue;
                }

                ids += ctl.ID.Replace("CB_", "") + ",";
            }
            if (string.IsNullOrEmpty(ids) == true)
            {
                BP.Sys.PubClass.Alert("您没有选择项目.");
                return;
            }
            this.Alert("成功将:" + ids + "放入了数据表...");
            #endregion 获得选择的ID

            #region 获得数据.
            MapDtl    dtl = new BP.Sys.MapDtl(this.FK_MapDtl);
            string    sql = "";
            DataTable dt  = null;
            try
            {
                sql = dtl.ImpSQLFull.Clone() as string;
                ids = ids.Replace(",", "','");
                sql = sql.Replace("@Keys", ids.Substring(0, ids.Length - 3));
                dt  = BP.DA.DBAccess.RunSQLReturnTable(sql);
                //当ID是int类型是可能抛出异常.
            }
            catch
            {
                sql = dtl.ImpSQLFull.Clone() as string;
                sql = sql.Replace("@Keys", ids.Substring(0, ids.Length - 2));
                dt  = BP.DA.DBAccess.RunSQLReturnTable(sql);
            }
            #endregion 获得数据.

            #region 把数据放入明细表.
            GEDtl gedtl = new BP.Sys.GEDtl(this.FK_MapDtl);
            foreach (DataRow dr in dt.Rows)
            {
                gedtl.RefPK = this.WorkID.ToString();
                gedtl.FID   = this.FID;
                gedtl.Rec   = WebUser.No;
                foreach (DataColumn dc in dt.Columns)
                {
                    //赋值.
                    gedtl.SetValByKey(dc.ColumnName, dr[dc.ColumnName]);
                }
                gedtl.InsertAsOID(BP.DA.DBAccess.GenerOID());
            }
            #endregion 把数据放入明细表.

            Button btn = sender as Button;
            if (btn.ID == "Btn_Pub1")
            {
                this.Alert("放入成功");
            }
            else
            {
                this.WinCloseWithMsg("放入成功");
            }
        }
Example #4
0
        /// <summary>
        /// 从另外的一个实体来copy数据.
        /// </summary>
        /// <param name="en"></param>
        public void CopyFromFrm(GEEntityMyPK en)
        {
            //先求出来旧的OID.
            string oldOID = this.MyPK;

            //复制主表数据.
            this.Copy(en);
            this.Save();
            this.MyPK = 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.MyPK);

                //求对应的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.MyPK.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.MyPK + "'");

                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.MyPK.ToString());
                    foreach (FrmAttachmentDB athDBFrom in athDBsFrom)
                    {
                        athDBFrom.MyPK             = BP.DA.DBAccess.GenerGUID();
                        athDBFrom.FK_FrmAttachment = ath.MyPK;
                        athDBFrom.RefPKVal         = this.MyPK.ToString();
                        athDBFrom.Insert();
                    }
                }
            }
        }