void btn_Imp_Click(object sender, EventArgs e) { MapDtl dtl = new MapDtl(this.FK_MapDtl); Button btn = sender as Button; if (btn.ID.Contains("ImpClear")) { /*如果是清空方式导入。*/ BP.DA.DBAccess.RunSQL("DELETE FROM " + dtl.PTable + " WHERE RefPK='" + this.WorkID + "'"); } Node nd = new Node(dtl.FK_MapData); MapData md = new MapData(dtl.FK_MapData); string starter = "SELECT Rec FROM " + md.PTable + " WHERE OID=" + this.WorkID; starter = BP.DA.DBAccess.RunSQLReturnString(starter); GEDtls geDtls = new GEDtls(this.FK_MapDtl); geDtls.Retrieve(GEDtlAttr.Rec, starter, "IsPass", "0"); string strs = ""; foreach (GEDtl item in geDtls) { if (this.Pub1.GetCBByID("CB_" + item.OID).Checked == false) { continue; } strs += ",'" + item.OID + "'"; } if (strs == "") { this.Alert("请选择要执行的数据。"); return; } strs = strs.Substring(1); BP.DA.DBAccess.RunSQL("UPDATE " + dtl.PTable + " SET RefPK='" + this.WorkID + "',BatchID=0,Check_Note='',Check_RDT='" + BP.DA.DataType.CurrentDataTime + "', Checker='',IsPass=1 WHERE OID IN (" + strs + ")"); this.WinClose(); }
void btn_DelUnPass_Click(object sender, EventArgs e) { MapDtl dtl = new MapDtl(this.FK_MapDtl); Node nd = new Node(dtl.FK_MapData); MapData md = new MapData(dtl.FK_MapData); string starter = "SELECT Rec FROM " + md.PTable + " WHERE OID=" + this.WorkID; starter = BP.DA.DBAccess.RunSQLReturnString(starter); GEDtls geDtls = new GEDtls(this.FK_MapDtl); geDtls.Retrieve(GEDtlAttr.Rec, starter, "IsPass", "0"); foreach (GEDtl item in geDtls) { if (this.Pub1.GetCBByID("CB_" + item.OID).Checked == false) { continue; } item.Delete(); } this.Response.Redirect(this.Request.RawUrl, true); }
public void PrintBill() { BP.WF.Node nd = new BP.WF.Node(this.FK_Node); string path = ApplicationPath + "\\DataUser\\CyclostyleFile\\FlowFrm\\" + nd.FK_Flow + "\\" + nd.NodeID + "\\"; if (System.IO.Directory.Exists(path) == false) { this.Pub1.AddMsgOfWarning("获取模版错误", "模版文件没有找到。" + path); return; } string[] fls = System.IO.Directory.GetFiles(path); string file = fls[int.Parse(this.BillIdx)]; file = file.Replace(ApplicationPath + @"DataUser\CyclostyleFile", ""); FileInfo finfo = new FileInfo(file); string tempName = finfo.Name.Split('.')[0]; string tempNameChinese = finfo.Name.Split('.')[1]; string toPath = ApplicationPath + @"DataUser\Bill\FlowFrm\" + DateTime.Now.ToString("yyyyMMdd") + "\\"; if (System.IO.Directory.Exists(toPath) == false) { System.IO.Directory.CreateDirectory(toPath); } // string billFile = toPath + "\\" + tempName + "." + this.FID + ".doc"; string billFile = toPath + "\\" + Server.UrlDecode(tempNameChinese) + "." + this.WorkID + ".doc"; BP.Pub.RTFEngine engine = new BP.Pub.RTFEngine(); if (tempName.ToLower() == "all") { /* 说明要从所有的流程表单上取数据.*/ FrmNodes fns = new FrmNodes(this.FK_Flow, this.FK_Node); foreach (FrmNode fn in fns) { GEEntity ge = new GEEntity(fn.FK_Frm, this.WorkID); engine.AddEn(ge); MapDtls mdtls = new MapDtls(fn.FK_Frm); foreach (MapDtl dtl in mdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } } // 增加主表. GEEntity myge = new GEEntity("ND" + nd.NodeID, this.WorkID); engine.AddEn(myge); MapDtls mymdtls = new MapDtls("ND" + nd.NodeID); foreach (MapDtl dtl in mymdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } // engine.MakeDoc(file, toPath, tempName + "." + this.WorkID + ".doc", null, false); engine.MakeDoc(file, toPath, Server.UrlDecode(tempNameChinese) + "." + this.WorkID + ".doc", null, false); } else { // 增加主表. GEEntity myge = new GEEntity(tempName, this.WorkID); engine.HisGEEntity = myge; engine.AddEn(myge); MapDtls mymdtls = new MapDtls(tempName); foreach (MapDtl dtl in mymdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } //engine.MakeDoc(file, toPath, tempName + "." + this.FID + ".doc", null, false); engine.MakeDoc(file, toPath, Server.UrlDecode(tempNameChinese) + "." + this.WorkID + ".doc", null, false); } #region 保存单据,以方便查询. Bill bill = new Bill(); bill.MyPK = this.FID + "_" + this.WorkID + "_" + this.FK_Node + "_" + this.BillIdx; bill.WorkID = this.WorkID; bill.FK_Node = this.FK_Node; bill.FK_Dept = WebUser.FK_Dept; bill.FK_Emp = WebUser.No; bill.Url = "/DataUser/Bill/FlowFrm/" + DateTime.Now.ToString("yyyyMMdd") + "/" + Server.UrlDecode(tempNameChinese) + "." + this.WorkID + ".doc"; bill.FullPath = toPath + file; bill.RDT = DataType.CurrentDataTime; bill.FK_NY = DataType.CurrentYearMonth; bill.FK_Flow = this.FK_Flow; if (this.WorkID != 0) { GenerWorkFlow gwf = new GenerWorkFlow(); gwf.WorkID = this.WorkID; if (gwf.RetrieveFromDBSources() == 1) { bill.Emps = gwf.Emps; bill.FK_Starter = gwf.Starter; bill.StartDT = gwf.RDT; bill.Title = gwf.Title; bill.FK_Dept = gwf.FK_Dept; } } try { bill.Insert(); } catch { bill.Update(); } #endregion BP.Sys.PubClass.OpenWordDocV2(billFile, tempNameChinese + ".doc"); }
private void BindExpImp() { MapDtl dtl = new MapDtl(this.FK_MapDtl); if (this.Request.QueryString["Flag"] == "ExpTemplete") { string file = this.Request.PhysicalApplicationPath + @"\DataUser\DtlTemplete\" + this.FK_MapDtl + ".xls"; if (System.IO.File.Exists(file) == false) { this.WinCloseWithMsg("设计错误:流程设计人员没有把该导入的从表模版放入" + file); return; } BP.Sys.PubClass.OpenExcel(file, dtl.Name + ".xls"); this.WinClose(); } if (this.Request.QueryString["Flag"] == "ExpTemplete") { string file = this.Request.PhysicalApplicationPath + @"\DataUser\DtlTemplete\" + this.FK_MapDtl + ".xls"; if (System.IO.File.Exists(file) == false) { this.WinCloseWithMsg("设计错误:流程设计人员没有把该导入的从表模版放入" + file); return; } BP.Sys.PubClass.OpenExcel(file, dtl.Name + ".xls"); this.WinClose(); return; } if (this.Request.QueryString["Flag"] == "ExpData") { GEDtls dtls = new GEDtls(this.FK_MapDtl); dtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); this.ExportDGToExcelV2(dtls, dtl.No + ".xls"); this.WinClose(); return; } if (dtl.IsExp) { this.Pub1.AddFieldSet("数据导出"); this.Pub1.Add("点下面的连接进行本从表的导出,您可以根据列的需要增减列。"); string urlExp = "DtlOpt.aspx?DoType=" + this.DoType + "&WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_MapDtl=" + this.FK_MapDtl + "&Flag=ExpData"; this.Pub1.Add("<a href='" + urlExp + "' target=_blank ><img src='../Img/FileType/xls.gif' border=0 /><b>导出数据</b></a>"); this.Pub1.AddFieldSetEnd(); } if (dtl.IsImp) { this.Pub1.AddFieldSet("通过Excel导入:" + dtl.Name); this.Pub1.Add("下载数据模版:利用数据模板导出一个数据模板,您可以在此基础上进行数据编辑,把编辑好的信息<br>在通过下面的功能导入进来,以提高工作效率。"); string url = "DtlOpt.aspx?DoType=" + this.DoType + "&WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_MapDtl=" + this.FK_MapDtl + "&Flag=ExpTemplete"; this.Pub1.Add("<a href='" + url + "' target=_blank ><img src='../Img/FileType/xls.gif' border=0 />数据模版</a>"); this.Pub1.Add("<br>"); this.Pub1.Add("格式数据文件:"); System.Web.UI.WebControls.FileUpload fu = new System.Web.UI.WebControls.FileUpload(); fu.ID = "fup"; this.Pub1.Add(fu); BP.Web.Controls.DDL ddl = new BP.Web.Controls.DDL(); ddl.Items.Add(new ListItem("选择导入方式", "all")); ddl.Items.Add(new ListItem("清空方式", "0")); ddl.Items.Add(new ListItem("追加方式", "1")); ddl.ID = "DDL_ImpWay"; this.Pub1.Add(ddl); Button btn = new Button(); btn.Text = "导入"; btn.CssClass = "Btn"; btn.ID = "Btn_" + dtl.No; btn.Click += new EventHandler(btn_Click); this.Pub1.Add(btn); this.Pub1.AddFieldSetEnd(); } if (dtl.IsEnableSelectImp) { this.Pub1.AddFieldSet("从数据源导入:" + dtl.Name); this.Pub1.Add("进入列表,选择一个或者多个记录,然后点确定按钮,执行导入。"); string url = "DtlOpSelectItems.aspx?DoType=" + this.DoType + "&WorkID=" + this.WorkID + "&FID=" + this.FID + "&FK_MapDtl=" + this.FK_MapDtl + "&Flag=ExpTemplete"; this.Pub1.Add("<a href='" + url + "' target=_self ><img src='../Img/Table.gif' border=0 /><b>进入....</b></a>"); this.Pub1.AddFieldSetEnd(); } }
private void BindUnPass() { MapDtl dtl = new MapDtl(this.FK_MapDtl); Node nd = new Node(dtl.FK_MapData); MapData md = new MapData(dtl.FK_MapData); string starter = "SELECT Rec FROM " + md.PTable + " WHERE OID=" + this.WorkID; starter = BP.DA.DBAccess.RunSQLReturnString(starter); GEDtls geDtls = new GEDtls(dtl.No); geDtls.Retrieve(GEDtlAttr.Rec, starter, "IsPass", "0"); MapAttrs attrs = new MapAttrs(dtl.No); this.Pub1.AddTable(); this.Pub1.AddTR(); this.Pub1.AddTDTitle("IDX"); if (geDtls.Count > 0) { string str1 = "<INPUT id='checkedAll' onclick='selectAll()' type='checkbox' name='checkedAll'>"; this.Pub1.AddTDTitle(str1); } else { this.Pub1.AddTDTitle(); } string spField = ",Checker,Check_RDT,Check_Note,"; foreach (MapAttr attr in attrs) { if (attr.UIVisible == false && spField.Contains("," + attr.KeyOfEn + ",") == false) { continue; } this.Pub1.AddTDTitle(attr.Name); } this.Pub1.AddTREnd(); int idx = 0; foreach (GEDtl item in geDtls) { idx++; this.Pub1.AddTR(); this.Pub1.AddTDIdx(idx); CheckBox cb = new CheckBox(); cb.ID = "CB_" + item.OID; this.Pub1.AddTD(cb); foreach (MapAttr attr in attrs) { if (attr.UIVisible == false && spField.Contains("," + attr.KeyOfEn + ",") == false) { continue; } if (attr.MyDataType == BP.DA.DataType.AppBoolean) { this.Pub1.AddTD(item.GetValBoolStrByKey(attr.KeyOfEn)); continue; } switch (attr.UIContralType) { case UIContralType.DDL: this.Pub1.AddTD(item.GetValRefTextByKey(attr.KeyOfEn)); continue; default: this.Pub1.AddTD(item.GetValStrByKey(attr.KeyOfEn)); continue; } } this.Pub1.AddTREnd(); } this.Pub1.AddTableEndWithHR(); if (geDtls.Count == 0) { return; } if (nd.IsStartNode == false) { return; } Button btn = new Button(); btn.ID = "Btn_Delete"; btn.CssClass = "Btn"; btn.Text = "批量删除"; btn.Attributes["onclick"] = " return confirm('您确定要执行吗?');"; btn.Click += new EventHandler(btn_DelUnPass_Click); this.Pub1.Add(btn); btn = new Button(); btn.ID = "Btn_Imp"; btn.CssClass = "Btn"; btn.Text = "导入并重新编辑(追加方式)"; btn.Click += new EventHandler(btn_Imp_Click); this.Pub1.Add(btn); btn = new Button(); btn.ID = "Btn_ImpClear"; btn.CssClass = "Btn"; btn.Text = "导入并重新编辑(清空方式)"; btn.Click += new EventHandler(btn_Imp_Click); this.Pub1.Add(btn); }
public void PrintBill() { BP.WF.Node nd = new BP.WF.Node(this.FK_Node); string path = ApplicationPath + "\\DataUser\\CyclostyleFile\\FlowFrm\\" + nd.FK_Flow + "\\" + nd.NodeID + "\\"; if (System.IO.Directory.Exists(path) == false) { } string[] fls = System.IO.Directory.GetFiles(path); string file = fls[int.Parse(this.BillIdx)]; file = file.Replace(ApplicationPath + @"DataUser\CyclostyleFile", ""); FileInfo finfo = new FileInfo(file); string tempName = finfo.Name.Split('.')[0]; string tempNameChinese = finfo.Name.Split('.')[1]; string toPath = ApplicationPath + @"DataUser\Bill\FlowFrm\" + DateTime.Now.ToString("yyyyMMdd") + "\\"; if (System.IO.Directory.Exists(toPath) == false) { System.IO.Directory.CreateDirectory(toPath); } string billFile = toPath + "\\" + tempName + "." + this.FID + ".doc"; BP.Rpt.RTF.RTFEngine engine = new BP.Rpt.RTF.RTFEngine(); if (tempName.ToLower() == "all") { FrmNodes fns = new FrmNodes(this.FK_Node); foreach (FrmNode fn in fns) { GEEntity ge = new GEEntity(fn.FK_Frm, this.WorkID); engine.AddEn(ge); MapDtls mdtls = new MapDtls(tempName); foreach (MapDtl dtl in mdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } } // 增加主表. GEEntity myge = new GEEntity("ND" + nd.NodeID, this.WorkID); engine.AddEn(myge); MapDtls mymdtls = new MapDtls("ND" + nd.NodeID); foreach (MapDtl dtl in mymdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } engine.MakeDoc(file, toPath, tempName + "." + this.WorkID + ".doc", null, false); } else { // 增加主表. GEEntity myge = new GEEntity(tempName, this.FID); engine.HisGEEntity = myge; engine.AddEn(myge); MapDtls mymdtls = new MapDtls(tempName); foreach (MapDtl dtl in mymdtls) { GEDtls enDtls = dtl.HisGEDtl.GetNewEntities as GEDtls; enDtls.Retrieve(GEDtlAttr.RefPK, this.WorkID); engine.EnsDataDtls.Add(enDtls); } engine.MakeDoc(file, toPath, tempName + "." + this.FID + ".doc", null, false); } BP.PubClass.OpenWordDocV2(billFile, tempNameChinese + ".doc"); }
private string GetDataByType(string fk_flow, string fk_node, string workID, string getType) { FrmNodes fns = new FrmNodes(fk_flow, int.Parse(fk_node)); string result = "{"; if (getType != "MainPage") { foreach (FrmNode fn in fns) { MapDtls mdtls = new MapDtls(fn.FK_Frm); foreach (MapDtl dtl in mdtls) { if (dtl.PTable.Equals(getType)) { GEDtls ens = new GEDtls(dtl.No); ens.Retrieve(GEDtlAttr.RefPK, workID); result += "\"" + dtl.PTable + "\":" + JsonConvert.SerializeObject(ens.ToDataTableField()) + "}"; break; } } } } else { foreach (FrmNode fn in fns) { GEEntity ge = new GEEntity(fn.FK_Frm, workID); string tempJson = JsonConvert.SerializeObject(ge.Row); tempJson = tempJson.TrimStart('{'); tempJson = tempJson.TrimEnd('}'); result += tempJson + ","; } result = result.TrimEnd(',') + "}"; } //foreach (FrmNode fn in fns) //{ // if (fn.FK_Frm == name) // { // GEEntity ge = new GEEntity(fn.FK_Frm, workID); // if (getType == "MainPage") // { // result = JsonConvert.SerializeObject(ge.Row); // } // else // { // result = JsonConvert.SerializeObject(ge.Row); // result = result.Substring(0, result.Length - 1); // MapDtls mdtls = new MapDtls(fn.FK_Frm); // foreach (MapDtl dtl in mdtls) // { // if (dtl.PTable.Equals(getType)) // { // GEDtls ens = new GEDtls(dtl.No); // ens.Retrieve(GEDtlAttr.RefPK, workID); // result += ",\"" + dtl.PTable + "\":" + // JsonConvert.SerializeObject(ens.ToDataTableField()) + "}"; // break; // } // } // } // break; // } //} return(result); }
//保存从表数据 public string Dtl_SaveRow() { #region 查询出来从表数据. GEDtls dtls = new GEDtls(this.EnsName); GEDtl dtl = dtls.GetNewEntity as GEDtl; dtls.Retrieve("RefPK", this.GetRequestVal("RefPKVal")); Map map = dtl.EnMap; foreach (Entity item in dtls) { string pkval = item.GetValStringByKey(dtl.PK); foreach (Attr attr in map.Attrs) { if (attr.IsRefAttr == true) { continue; } if (attr.MyDataType == DataType.AppDateTime || attr.MyDataType == DataType.AppDate) { if (attr.UIIsReadonly == true) { continue; } string val = this.GetValFromFrmByKey("TB_" + attr.Key + "_" + pkval, null); item.SetValByKey(attr.Key, val); continue; } if (attr.UIContralType == UIContralType.TB && attr.UIIsReadonly == false) { string val = this.GetValFromFrmByKey("TB_" + attr.Key + "_" + pkval, null); item.SetValByKey(attr.Key, val); continue; } if (attr.UIContralType == UIContralType.DDL && attr.UIIsReadonly == true) { string val = this.GetValFromFrmByKey("DDL_" + attr.Key + "_" + pkval); item.SetValByKey(attr.Key, val); continue; } if (attr.UIContralType == UIContralType.CheckBok && attr.UIIsReadonly == true) { string val = this.GetValFromFrmByKey("CB_" + attr.Key + "_" + pkval, "-1"); if (val == "-1") { item.SetValByKey(attr.Key, 0); } else { item.SetValByKey(attr.Key, 1); } continue; } } item.Update(); //执行更新. } #endregion 查询出来从表数据. #region 保存新加行. string keyVal = ""; foreach (Attr attr in map.Attrs) { if (attr.MyDataType == DataType.AppDateTime || attr.MyDataType == DataType.AppDate) { if (attr.UIIsReadonly == true) { continue; } keyVal = this.GetValFromFrmByKey("TB_" + attr.Key + "_0", null); dtl.SetValByKey(attr.Key, keyVal); continue; } if (attr.UIContralType == UIContralType.TB && attr.UIIsReadonly == false) { keyVal = this.GetValFromFrmByKey("TB_" + attr.Key + "_0"); if (attr.IsNum && keyVal == "") { keyVal = "0"; } dtl.SetValByKey(attr.Key, keyVal); continue; } if (attr.UIContralType == UIContralType.DDL && attr.UIIsReadonly == true) { keyVal = this.GetValFromFrmByKey("DDL_" + attr.Key + "_0"); dtl.SetValByKey(attr.Key, keyVal); continue; } if (attr.UIContralType == UIContralType.CheckBok && attr.UIIsReadonly == true) { keyVal = this.GetValFromFrmByKey("CB_" + attr.Key + "_0", "-1"); if (keyVal == "-1") { dtl.SetValByKey(attr.Key, 0); } else { dtl.SetValByKey(attr.Key, 1); } continue; } } dtl.SetValByKey("RefPK", this.GetRequestVal("RefPKVal")); dtl.PKVal = "0"; dtl.Insert(); #endregion 保存新加行. return("保存成功."); }