//保存或提交时的JS代码(判断是否必填项),动态架构 Written by xf 20110515 public string CheckfmMainInput() { string ls_mid = ""; if (this.Request.QueryString["mid"] != null) { ls_mid = this.Request.QueryString["mid"].ToString(); if (ls_mid.Contains(",")) ls_mid = ls_mid.Substring(0, ls_mid.IndexOf(",")); } string ls_tableid = ""; if (this.Request.QueryString["tableid"] != null) { ls_tableid = this.Request.QueryString["tableid"].ToString(); if (ls_tableid.Contains(",")) ls_tableid = ls_tableid.Substring(0, ls_tableid.IndexOf(",")); } string ls_return = ""; //如果是“可修改所有文档的权限人员”,则可以修改所有的字段,不需要提示是否必填了。 HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global(); if (Hyoa_global.isHaveRole("Role9995", Session["hyuid"].ToString())) { } else { HyoaClass.Hyoa_flowfield Hyoa_flowfield = new HyoaClass.Hyoa_flowfield(); //根据模块ID和表单ID得到对应的配置字段 DataTable dt_gettablecolumns = Hyoa_flowfield.GetflowfieldsbyMudelidAndTableid(ls_mid, ls_tableid); if (dt_gettablecolumns.Rows.Count > 0) { //判断是否必填 for (int i = 0; i < dt_gettablecolumns.Rows.Count; i++) { if (dt_gettablecolumns.Rows[i]["hy_required"].ToString() == "是") { if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "文本" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "多行文本" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "文本加按钮" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "多行文本加按钮" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "日期" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "口令") ls_return += "try{if(fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".value==\"\"){alert(\"" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "不能为空!\");fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".focus();return false;}}catch(err){}"; if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "数值") ls_return += "try{if(fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".value==\"\"){alert(\"" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "不能为空!\");fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".focus();return false;}if(isNaN(fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".value)){alert(\"" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "必须为数值!\");fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".focus();return false}}catch(err){}"; if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "对话框列表") ls_return += "try{if(fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".selectedIndex==0){alert(\"请选择" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "!\");fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".focus();return false;}}catch(err){}"; //if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "复选框") // ls_return += "try{var ls_select=\"\";var obj1=document.getElementsById(\"" + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "\");for(var i = 0; i < obj1.length; i++){if(obj1[i].checked){if(ls_select==\"\"){ls_select = obj1[i].value;}else{ls_select=ls_select+\"#\"+obj1[i].value;}}}if(ls_select==\"\"){alert('请选择" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "!');return false;}}catch(err){}"; //if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "单选框") // ls_return += "try{var ls_select=\"\";var obj1=document.getElementsById(\"" + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "\");for(var i = 0; i < obj1.length; i++){if(obj1[i].checked){if(ls_select==\"\"){ls_select = obj1[i].value;}else{ls_select=ls_select+\"#\"+obj1[i].value;}}}if(ls_select==\"\"){alert('请选择" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "!');return false;}}catch(err){}"; } //哪个字段是待办事宜提醒的字段 edited by xf 20140625 if (dt_gettablecolumns.Rows[i]["hy_ifdbsybt"].ToString() == "是") { ls_return += "try{var d=document.getElementById('" + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "');if(d==null||typeof(d.value)=='undefined'){}else{document.getElementById('hy_bt').value=d.value;}}catch(err){}"; } } } } return ls_return; }
//保存或提交时的JS代码(判断是否必填项),动态架构 Written by xf 20110515 public string CheckfmMainInput() { string ls_mid = ""; if (this.Request.QueryString["mid"] != null) { ls_mid = this.Request.QueryString["mid"].ToString(); if (ls_mid.Contains(",")) ls_mid = ls_mid.Substring(0, ls_mid.IndexOf(",")); } string ls_tableid = ""; if (this.Request.QueryString["tableid"] != null) { ls_tableid = this.Request.QueryString["tableid"].ToString(); if (ls_tableid.Contains(",")) ls_tableid = ls_tableid.Substring(0, ls_tableid.IndexOf(",")); } string ls_return = ""; HyoaClass.Hyoa_flowfield Hyoa_flowfield = new HyoaClass.Hyoa_flowfield(); //根据模块ID和表单ID得到对应的配置字段 DataTable dt_gettablecolumns = Hyoa_flowfield.GetflowfieldsbyMudelidAndTableid(ls_mid, ls_tableid); if (dt_gettablecolumns.Rows.Count > 0) { //判断是否必填 for (int i = 0; i < dt_gettablecolumns.Rows.Count; i++) { if (dt_gettablecolumns.Rows[i]["hy_required"].ToString() == "是") { if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "文本" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "多行文本" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "文本加按钮" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "多行文本加按钮" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "日期" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "口令") ls_return += "try{if(fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.value==\"\"){alert(\"" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "不能为空!\");fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.focus();return false;}}catch(err){}"; if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "数值") ls_return += "try{if(fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.value==\"\"){alert(\"" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "不能为空!\");fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.focus();return false;}if(isNaN(fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.value)){alert(\"" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "必须为数值!\");fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.focus();return false}}catch(err){}"; if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "对话框列表") ls_return += "try{if(fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.selectedIndex==0){alert(\"请选择" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "!\");fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.focus();return false;}}catch(err){}"; if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "复选框") ls_return += "try{var ls_select=\"\";var obj1=document.getElementsByName(\"" + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1\");for(var i = 0; i < obj1.length; i++){if(obj1[i].checked){if(ls_select==\"\"){ls_select = obj1[i].value;}else{ls_select=ls_select+\"#\"+obj1[i].value;}}}if(ls_select==\"\"){alert('请选择" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "!');return false;}}catch(err){}"; if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "单选框") ls_return += "try{var ls_select=\"\";var obj1=document.getElementsByName(\"" + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1\");for(var i = 0; i < obj1.length; i++){if(obj1[i].checked){if(ls_select==\"\"){ls_select = obj1[i].value;}else{ls_select=ls_select+\"#\"+obj1[i].value;}}}if(ls_select==\"\"){alert('请选择" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "!');return false;}}catch(err){}"; } } } return ls_return; }
protected void Page_Load(object sender, EventArgs e) { string ls_mudelid=""; string ls_colname=""; string ls_colid=""; string ls_colname2=""; string ls_colid2=""; string ls_colname3=""; string ls_colid3=""; string ls_tableid = ""; if (this.Request.QueryString["mudelid"] != null) { ls_mudelid = this.Request.QueryString["mudelid"].ToString(); } if (this.Request.QueryString["tableid"] != null) { ls_tableid = this.Request.QueryString["tableid"].ToString(); } //模块对应的域 HyoaClass.Hyoa_flowfield Hyoa_flowfield = new HyoaClass.Hyoa_flowfield(); DataTable dt4 = Hyoa_flowfield.GetflowfieldsbyMudelidAndTableid(ls_mudelid, ls_tableid); if (dt4.Rows.Count > 0) { for (int i = 0; i < dt4.Rows.Count; i++) { if (ls_colname == "") { ls_colname = dt4.Rows[i]["hy_fieldname"].ToString(); ls_colid = dt4.Rows[i]["hy_fieldid"].ToString(); } else { ls_colname = ls_colname + "+" + dt4.Rows[i]["hy_fieldname"].ToString(); ls_colid = ls_colid + "+" + dt4.Rows[i]["hy_fieldid"].ToString(); } } } dt4.Clear(); string lsid = ""; //HyoaClass.Hyoa_listconfig Hyoa_listconfig = new HyoaClass.Hyoa_listconfig(); //dt4 = Hyoa_listconfig.GetlistconfigsbyMudelidAndTableid(ls_mudelid,ls_tableid); HyoaClass.DAO db = new HyoaClass.DAO(); string sql = "select *from hyt_searchconfig where hy_mudelid='" + ls_mudelid + "' and hy_tableid='" + ls_tableid + "'"; dt4 = db.GetDataTable(sql); if (dt4.Rows.Count > 0) { ls_colname2 = dt4.Rows[0]["hy_columnshow"].ToString(); ls_colid2 = dt4.Rows[0]["hy_columnshowid"].ToString(); lsid = dt4.Rows[0]["ID"].ToString(); ls_colname3 = dt4.Rows[0]["hy_xszd"].ToString(); ls_colid3 = dt4.Rows[0]["hy_xszdid"].ToString(); } dt4.Clear(); //HyoaClass.Hyoa_listsearchfield Hyoa_listsearchfield = new HyoaClass.Hyoa_listsearchfield(); //dt4 = Hyoa_listsearchfield.GetlistsearchfieldsbyMudelidAndListid(ls_mudelid,lsid); //if (dt4.Rows.Count > 0) //{ // for (int k = 0; k < dt4.Rows.Count; k++) // { // if (ls_colname3 == "") // { // ls_colname3 = dt4.Rows[k]["hy_field"].ToString(); // ls_colid3 = dt4.Rows[k]["hy_fieldid"].ToString(); // } // else // { // ls_colname3 = ls_colname3 + "+" + dt4.Rows[k]["hy_field"].ToString(); // ls_colid3 = ls_colid3 + "+" + dt4.Rows[k]["hy_fieldid"].ToString(); // } // } //} //HyoaClass.Hyoa_listsearchfield Hyoa_listsearchfield = new HyoaClass.Hyoa_listsearchfield(); //this.Response.Write(ls_colname + "*" + ls_colid + "#" + ls_colname2 + "*" + ls_colid2); this.Response.Write(ls_colname + "*" + ls_colid + "#" + ls_colname2 + "*" + ls_colid2 + "#" + ls_colname3 + "*" + ls_colid3); //return ; }
//保存或提交时的JS代码(赋值),动态架构 Written by xf 20110714 public string ReplaceMainInput() { string ls_mid = ""; if (this.Request.QueryString["mid"] != null) { ls_mid = this.Request.QueryString["mid"].ToString(); if (ls_mid.Contains(",")) ls_mid = ls_mid.Substring(0, ls_mid.IndexOf(",")); } string ls_tableid = ""; if (this.Request.QueryString["tableid"] != null) { ls_tableid = this.Request.QueryString["tableid"].ToString(); if (ls_tableid.Contains(",")) ls_tableid = ls_tableid.Substring(0, ls_tableid.IndexOf(",")); } string ls_return = ""; HyoaClass.Hyoa_flowfield Hyoa_flowfield = new HyoaClass.Hyoa_flowfield(); //根据模块ID和表单ID得到对应的配置字段 DataTable dt_gettablecolumns = Hyoa_flowfield.GetflowfieldsbyMudelidAndTableid(ls_mid, ls_tableid); if (dt_gettablecolumns.Rows.Count > 0) { //赋值代码 for (int i = 0; i < dt_gettablecolumns.Rows.Count; i++) { if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "文本" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "文本加按钮" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "日期" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "口令") ls_return += "try{fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".value = fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.value;}catch(err){}"; if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "多行文本" || dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "多行文本加按钮") ls_return += "try{fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".value = RtftoTxt(fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.value);}catch(err){}"; if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "数值") ls_return += "try{fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".value = fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.value;}catch(err){}"; if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "对话框列表") ls_return += "try{fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".value = fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.options[fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1.selectedIndex].value;}catch(err){}"; if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "复选框") ls_return += "try{var ls_select=\"\";var ls_flag=\"0\";var obj1=document.getElementsByName(\"" + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1\");for(var i = 0; i < obj1.length; i++){ls_flag=\"1\";if(obj1[i].checked){if(ls_select==\"\"){ls_select = obj1[i].value;}else{ls_select=ls_select+\"#\"+obj1[i].value;}}}if(ls_flag==\"1\"){fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".value=ls_select;}}catch(err){}"; if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "单选框") ls_return += "try{var ls_select=\"\";var ls_flag=\"0\";var obj1=document.getElementsByName(\"" + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + "_1\");for(var i = 0; i < obj1.length; i++){ls_flag=\"1\";if(obj1[i].checked){if(ls_select==\"\"){ls_select = obj1[i].value;}else{ls_select=ls_select+\"#\"+obj1[i].value;}}}if(ls_flag==\"1\"){fm." + dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString() + ".value=ls_select;}}catch(err){}"; } } return ls_return; }
//得到表单的HTML pi_flag 0:不赋值 1:需赋值 Written by xf 20110515 //docid:旧文档使用时,文档ID //ifhavarole:是否有权限 0:lable输出 1:input输出 //ifflowdoc:是否流程表单 0:非流程 1:流程 //curtacheid:当前环节ID,用于判断字段是否在当前环节有权限 public DataTable GetDataTableFieldHtml(string hy_mudelid, string hy_tableid, string pi_flag, string ifsearch, string docid, string ifhavarole, string ifflowdoc, string curtacheid) { //加载表单 HyoaClass.Hyoa_flowfield Hyoa_flowfield = new HyoaClass.Hyoa_flowfield(); //根据模块ID和表单ID得到对应的配置字段 DataTable dt_gettablecolumns = Hyoa_flowfield.GetflowfieldsbyMudelidAndTableid(hy_mudelid, hy_tableid); string ls_html = ""; Int32 li_tdnums = 0; //TDS数(colspan的值相加) DataTable tempTable = new DataTable(); DataColumn col = new DataColumn("displaycol", typeof(String)); //定义新的一列 add tempTable.Columns.Add(col); //追加一列 add if (dt_gettablecolumns.Rows.Count > 0) { //先从配置表中将配置的列数取出,如果配置表中找不到,则默认为4列,并且设置相应的宽度start HyoaClass.Hyoa_detail Hyoa_detail = new HyoaClass.Hyoa_detail(); int li_col = 4;//一行显示几列 string ls_leftwidth = "15";//左侧列宽 string ls_rightwidth = "35";//右侧列宽 DataTable detaildt = Hyoa_detail.Getdetail(hy_tableid); if (detaildt.Rows.Count > 0) { li_col = int.Parse(detaildt.Rows[0]["hy_colnum"].ToString()); if (detaildt.Rows[0]["hy_colnum"].ToString() == "6") { ls_leftwidth = "10"; ls_rightwidth = "23"; } else { if (detaildt.Rows[0]["hy_colnum"].ToString() == "8") { ls_leftwidth = "5"; ls_rightwidth = "7"; } else { if (detaildt.Rows[0]["hy_colnum"].ToString() == "10") { ls_leftwidth = "4"; ls_rightwidth = "6"; } } } } //先从配置表中将配置的列数取出,如果配置表中找不到,则默认为4列,并且设置相应的宽度end //开始加载字段信息到DT中,用于前台显示 for (int i = 0; i < dt_gettablecolumns.Rows.Count; i++) { if (i == 0) { ls_html += "<TR height=\"30\">"; } //输出字段说明列(文字说明除外) if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() != "说明文字") { //20120724 //如果是隐藏字段,则隐藏(增加display) added by xf 20120217 if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是") ls_html += "<TD width=\"" + ls_leftwidth + "%\" align=\"center\" class=\"Tdcellleft\">" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "</TD>"; else ls_html += "<div style=\"display:none\">" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "</div>"; //ls_html += "<TD width=\"" + ls_leftwidth + "%\" align=\"center\" class=\"Tdcellleft\">" + dt_gettablecolumns.Rows[i]["hy_fieldname"].ToString() + "</TD>"; } //得到当前字段的值 HyoaClass.Hyoa_flowmain Hyoa_flowmain = new HyoaClass.Hyoa_flowmain(); DataTable dt_flowmain = Hyoa_flowmain.Getflowmain(docid); string field_docvalue = " "; if (dt_flowmain.Rows.Count > 0) { if (dt_gettablecolumns.Rows[i]["hy_defaultvalue"].ToString() == "yyyy-mm-dd") { field_docvalue = System.DateTime.Parse(dt_flowmain.Rows[0][dt_gettablecolumns.Rows[i]["hy_sqlfield"].ToString()].ToString()).ToShortDateString() + field_docvalue; } else { //如果SQL为数值的字段部分,则需要截取小数点后边两位 if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "数值") { if (dt_flowmain.Rows[0][dt_gettablecolumns.Rows[i]["hy_sqlfield"].ToString()].ToString().Contains(".") == true) field_docvalue = float.Parse(dt_flowmain.Rows[0][dt_gettablecolumns.Rows[i]["hy_sqlfield"].ToString()].ToString()).ToString("F2") + field_docvalue; else field_docvalue = dt_flowmain.Rows[0][dt_gettablecolumns.Rows[i]["hy_sqlfield"].ToString()].ToString() + field_docvalue; } else { field_docvalue = dt_flowmain.Rows[0][dt_gettablecolumns.Rows[i]["hy_sqlfield"].ToString()].ToString() + field_docvalue; } } } //输出字段列 //this.Response.Write("<script>alert('" + ifhavarole + "');</script>"); if (ifhavarole == "0") //无权限(当前表单来讲) { //附件组件的值需要特定读取(附件需要特殊处理) Added by xf 20110607 if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "附件组件") { field_docvalue = ""; //根据docid得到目前已上传的附件信息 HyoaClass.Hyoa_user Hyoa_user = new HyoaClass.Hyoa_user(); HyoaClass.Hyoa_fileatt Hyoa_fileatt = new HyoaClass.Hyoa_fileatt(); DataTable dt_fileatt = Hyoa_fileatt.GetfileattByFatherid(docid); if (dt_fileatt.Rows.Count > 0) { for (var ii = 0; ii < dt_fileatt.Rows.Count; ii++) { string ls_name = ""; DataTable dt_user = Hyoa_user.Getuser(dt_fileatt.Rows[ii]["hy_userid"].ToString()); if (dt_user.Rows.Count > 0) { ls_name = dt_user.Rows[0]["hy_username"].ToString(); } field_docvalue += (ii + 1).ToString() + "、<a href=\"" + dt_fileatt.Rows[ii]["hy_filepath"].ToString() + "\" target=_blank>" + dt_fileatt.Rows[ii]["hy_filename"].ToString() + " " + ls_name + " [" + dt_fileatt.Rows[ii]["hy_djsj"].ToString() + "]" + "</a><br />"; } } if (field_docvalue == "") field_docvalue = " "; } //痕迹保留组件的值需要读取(需要特殊处理) Added by xf 20110705 if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "痕迹保留") { field_docvalue = ""; field_docvalue += "<input type=button id=\"btn_zwxg\" value='正 文' class=btn3 onclick=\"window.open('ntko/readoffice.aspx?newofficetype=1&fatherid=" + docid + "&tacheByhj=1&jsxd=1','newwindow','height=768,width=1024,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=yes,location=no, status=no');\" "; if (field_docvalue == "") field_docvalue = " "; } //ztmztmztmstart //this.Response.Write("<script>alert('" + field_docvalue + "');</script>"); if (field_docvalue.Length > 7) { if (field_docvalue.Substring(0, 8) == "1900-1-1") { field_docvalue = " "; } } //ztmztmztmend if (dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() == "1") { //如果是隐藏字段,则隐藏(增加display) added by xf 20120217 if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是") ls_html += "<TD width=\"" + ls_rightwidth + "%\" height=\"30px\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\">" + field_docvalue + "</TD>"; else ls_html += "<div style=\"display:none\">" + field_docvalue + "</div>"; //ls_html += "<TD width=\"" + ls_rightwidth + "%\" height=\"30px\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\">" + field_docvalue + "</TD>"; } else { //如果是隐藏字段,则隐藏(增加display) added by xf 20120217 if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是") ls_html += "<TD width=\"" + ls_rightwidth + "%\" height=\"30px\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\" colspan=" + dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() + ">" + field_docvalue + "</TD>"; else ls_html += "<div style=\"display:none\">" + field_docvalue + "</div>"; //ls_html += "<TD width=\"" + ls_rightwidth + "%\" height=\"30px\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\" colspan=" + dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() + ">" + field_docvalue + "</TD>"; } } else { //有权限(当前表单来讲)时,判断当前流程+当前环节对于这个字段是否有权限操作 string ls_ifhavarole = "0"; //默认没有权限(当前字段来讲)---该功能仅对于流程模块起作用 //非流程直接就有权限了 //this.Response.Write("<script>alert('" + ifflowdoc + "');</script>"); if (ifflowdoc == "0") { ls_ifhavarole = "1"; } else { //判断当前字段是否有权限 HyoaClass.Hyoa_flowtachefield Hyoa_flowtachefield = new HyoaClass.Hyoa_flowtachefield(); ls_ifhavarole = Hyoa_flowtachefield.IfHaveRolebyflowidandtacheidandfieldid(dt_gettablecolumns.Rows[i]["hy_flowid"].ToString(), curtacheid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString()); } if (dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() == "1") { //如果是隐藏字段,则隐藏(增加display) added by xf 20120217 if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是") ls_html += "<TD width=\"" + ls_rightwidth + "%\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</TD>"; else ls_html += "<div style=\"display:none\">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</div>"; //ls_html += "<TD width=\"" + ls_rightwidth + "%\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</TD>"; } else { //如果是隐藏字段,则隐藏(增加display) added by xf 20120217 if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是") ls_html += "<TD width=\"" + ls_rightwidth + "%\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\" colspan=" + dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() + ">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</TD>"; else ls_html += "<div style=\"display:none\">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</div>"; //ls_html += "<TD width=\"" + ls_rightwidth + "%\" align=" + dt_gettablecolumns.Rows[i]["hy_align"].ToString() + " class=\"Tdcellright\" colspan=" + dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString() + ">" + GetFieldHtml(hy_mudelid, dt_gettablecolumns.Rows[i]["hy_fieldid"].ToString(), pi_flag, hy_tableid, ifsearch, docid, ls_ifhavarole) + "</TD>"; } } //开始colspan值累加,如果是隐藏字段,不计算在内 if (dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是") { if (dt_gettablecolumns.Rows[i]["hy_fieldtype"].ToString() == "说明文字") li_tdnums += System.Int32.Parse(dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString()); else li_tdnums += System.Int32.Parse(dt_gettablecolumns.Rows[i]["hy_tdnums"].ToString()) + 1; } //this.lbtest.Text += "," + li_tdnums; if (li_tdnums % li_col == 0 && dt_gettablecolumns.Rows[i]["hy_ifhiddle"].ToString() != "是") { ls_html += "</tr>"; DataRow dr = tempTable.NewRow(); dr["displaycol"] = ls_html; //将新值赋给相应的列 add tempTable.Rows.Add(dr); ls_html = ""; if (i != (dt_gettablecolumns.Rows.Count - 1)) ls_html += "<tr>"; } //先从配置表中将配置的列数取出,如果配置表中找不到,则默认为4列end } } return tempTable; }
private void DataPlay() { //是否启用 this.ddlifsearch.Items.Insert(0, "是"); this.ddlifsearch.Items.Insert(1, "否"); this.ddlifflowdoc.Items.Insert(0, "是"); this.ddlifflowdoc.Items.Insert(1, "否"); this.ddlifshowsearch.Items.Insert(0, "是"); this.ddlifshowsearch.Items.Insert(1, "否"); //模块编号 //加载模块信息 HyoaClass.Hyoa_mudel Hyoa_mudel = new HyoaClass.Hyoa_mudel(); DataTable dtmudel = Hyoa_mudel.Getmudels(); if (dtmudel.Rows.Count > 0) { this.ddlmudelid.DataSource = dtmudel; this.ddlmudelid.DataTextField = "hy_mudelname"; this.ddlmudelid.DataValueField = "hy_mudelid"; this.ddlmudelid.DataBind(); this.ddlmudelid.Items.Insert(0, new ListItem("请选择", "请选择")); this.ddlmudelid.SelectedIndex = 0; } if (this.Request.QueryString["op"] != null) { this.txtop.Value = this.Request.QueryString["op"].ToString(); //新增还是修改 //判断当前用户是否有保存的权限 HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global(); if (Hyoa_global.isHaveRole("Role9999", this.Session["hyuid"].ToString())) { this.btn_submit.Visible = true; //保存 } else { this.btn_submit.Visible = false; //保存 } //旧文档 HyoaClass.Hyoa_listconfig Hyoa_listconfig = new HyoaClass.Hyoa_listconfig(); if (this.Request.QueryString["op"] == "modify") { if (this.Request.QueryString["id"] != null) { //根据id得到信息 this.txtdocid.Value = this.Request.QueryString["id"].ToString(); DataTable dt = Hyoa_listconfig.Getlistconfig(this.txtdocid.Value); if (dt.Rows.Count > 0) { this.txtsort.Text = dt.Rows[0]["hy_sort"].ToString(); if (dt.Rows[0]["hy_ifsearch"].ToString() == "是") { this.ddlifsearch.SelectedIndex = 0; } else { this.ddlifsearch.SelectedIndex = 1; } if (dt.Rows[0]["hy_ifshowsearch"].ToString() != "否") { this.ddlifshowsearch.SelectedIndex = 0; } else { this.ddlifshowsearch.SelectedIndex = 1; } this.ddlmudelid.SelectedValue = dt.Rows[0]["hy_mudelid"].ToString(); if (dt.Rows[0]["hy_ifflowdoc"].ToString() == "是") { this.ddlifflowdoc.SelectedIndex = 0; } else { this.ddlifflowdoc.SelectedIndex = 1; } this.txthy_listname.Text = dt.Rows[0]["hy_listname"].ToString(); this.txtwidth.Text = dt.Rows[0]["hy_width"].ToString(); //加载所有列信息 HyoaClass.Hyoa_flowfield Hyoa_flowfield = new HyoaClass.Hyoa_flowfield(); DataTable dtflowfield; //dtflowfield = Hyoa_flowfield.Getflowfields(); dtflowfield = Hyoa_flowfield.GetflowfieldsbyMudelidAndTableid(dt.Rows[0]["hy_mudelid"].ToString(), dt.Rows[0]["hy_tableid"].ToString()); if (dtflowfield.Rows.Count > 0) { this.ddlcolumnshow.DataSource = dtflowfield; this.ddlcolumnshow.DataTextField = "hy_fieldname"; this.ddlcolumnshow.DataValueField = "hy_fieldid"; this.ddlcolumnshow.DataBind(); this.ddlcolumnshow.SelectedIndex = 0; } dtflowfield.Clear(); //将列都列出来 string[] lv_columnshowselect; string[] lv_columnshowselectid; lv_columnshowselect = dt.Rows[0]["hy_columnshow"].ToString().Split(','); lv_columnshowselectid = dt.Rows[0]["hy_columnshowid"].ToString().Split(','); for (int j = 0; j < lv_columnshowselect.Length; j++) { this.ddlcolumnshowselect.Items.Insert(j, new ListItem(lv_columnshowselect[j], lv_columnshowselectid[j])); } //根据模块信息得到对应的选择表单值 if (dt.Rows[0]["hy_tableid"] != "" && dt.Rows[0]["hy_tableid"] != null) { this.ddltableid.Items.Clear(); //根据模块ID得到表单ID HyoaClass.Hyoa_tableconfig Hyoa_tableconfig = new HyoaClass.Hyoa_tableconfig(); DataTable dtgettableid = Hyoa_tableconfig.GetTablesbymudelid(dt.Rows[0]["hy_mudelid"].ToString()); if (dtgettableid.Rows.Count > 0) { for (var i = 0; i < dtgettableid.Rows.Count; i++) { this.ddltableid.Items.Insert(i, new ListItem(dtgettableid.Rows[i]["hy_name"].ToString(), dtgettableid.Rows[i]["ID"].ToString())); } this.ddltableid.Items.Insert(0, new ListItem("--请选择--", "")); this.ddltableid.Attributes.Add("onchange ", "mudelidonchang() "); //定位 this.ddltableid.SelectedValue = dt.Rows[0]["hy_tableid"].ToString(); } } //排序的字段 //根据模块ID+表单ID+字段ID得到字段中文名 DataTable dt_flowfield = Hyoa_flowfield.GetSQLfieldBymudelidAndFieldidAndTableid(dt.Rows[0]["hy_mudelid"].ToString(), dt.Rows[0]["hy_sortfield1"].ToString(), dt.Rows[0]["hy_tableid"].ToString()); if (dt_flowfield.Rows.Count > 0) { this.searchsort1.Items.Insert(0, new ListItem(dt_flowfield.Rows[0]["hy_fieldname"].ToString(), dt.Rows[0]["hy_sortfield1"].ToString())); } this.ddlsorttype1.SelectedValue = dt.Rows[0]["hy_sorttype1"].ToString(); dt_flowfield.Clear(); dt_flowfield = Hyoa_flowfield.GetSQLfieldBymudelidAndFieldidAndTableid(dt.Rows[0]["hy_mudelid"].ToString(), dt.Rows[0]["hy_sortfield2"].ToString(), dt.Rows[0]["hy_tableid"].ToString()); if (dt_flowfield.Rows.Count > 0) { this.searchsort2.Items.Insert(0, new ListItem(dt_flowfield.Rows[0]["hy_fieldname"].ToString(), dt.Rows[0]["hy_sortfield2"].ToString())); } this.ddlsorttype2.SelectedValue = dt.Rows[0]["hy_sorttype2"].ToString(); dt_flowfield.Clear(); dt_flowfield = Hyoa_flowfield.GetSQLfieldBymudelidAndFieldidAndTableid(dt.Rows[0]["hy_mudelid"].ToString(), dt.Rows[0]["hy_sortfield3"].ToString(), dt.Rows[0]["hy_tableid"].ToString()); if (dt_flowfield.Rows.Count > 0) { this.searchsort3.Items.Insert(0, new ListItem(dt_flowfield.Rows[0]["hy_fieldname"].ToString(), dt.Rows[0]["hy_sortfield3"].ToString())); } this.ddlsorttype3.SelectedValue = dt.Rows[0]["hy_sorttype3"].ToString(); dt_flowfield.Clear(); //分类的字段 this.txthy_field_fl1.Text = dt.Rows[0]["hy_sql_fl1"].ToString(); if (dt.Rows[0]["hy_fieldid_fl1"].ToString() != "") { this.flfield1.Items.Insert(0, new ListItem(dt.Rows[0]["hy_fieldname_fl1"].ToString(), dt.Rows[0]["hy_fieldid_fl1"].ToString())); } this.txthy_field_fl2.Text = dt.Rows[0]["hy_sql_fl2"].ToString(); if (dt.Rows[0]["hy_fieldid_fl2"].ToString() != "") { this.flfield2.Items.Insert(0, new ListItem(dt.Rows[0]["hy_fieldname_fl2"].ToString(), dt.Rows[0]["hy_fieldid_fl2"].ToString())); } this.txthy_field_fl3.Text = dt.Rows[0]["hy_sql_fl3"].ToString(); if (dt.Rows[0]["hy_fieldid_fl3"].ToString() != "") { this.flfield3.Items.Insert(0, new ListItem(dt.Rows[0]["hy_fieldname_fl3"].ToString(), dt.Rows[0]["hy_fieldid_fl3"].ToString())); } } dt.Clear(); HyoaClass.Hyoa_listsearchfield Hyoa_listsearchfield = new HyoaClass.Hyoa_listsearchfield(); DataTable dt5 = Hyoa_listsearchfield.Getlistsearchfieldsbylistid(this.txtdocid.Value); if (dt5.Rows.Count > 0) { for (int m = 0; m < dt5.Rows.Count; m++) { this.searchselect.Items.Insert(m, new ListItem(dt5.Rows[m]["hy_field"].ToString(), dt5.Rows[m]["hy_fieldid"].ToString())); } } } } else { //自动获取最大排序号,然后+2 DataTable dt_maxsort = Hyoa_listconfig.GetMaxlistconfigsort(); if (dt_maxsort.Rows.Count > 0) txtsort.Text = (int.Parse(dt_maxsort.Rows[0]["hy_sort"].ToString()) + 2).ToString(); else txtsort.Text = "1"; } } }
/// <summary> /// 将Web控件导出 /// </summary> /// <param name="source">控件实例</param> /// <param name="type">类型:Excel或Word</param> public void ExpertControl(string ls_ids, DocumentType type) { //设置Http的头信息,编码格式 if (type == DocumentType.Excel) { //Excel Response.AppendHeader("Content-Disposition", "attachment;filename=result.xls"); Response.ContentType = "application/ms-excel"; } else if (type == DocumentType.Word) { //Word Response.AppendHeader("Content-Disposition", "attachment;filename=result.doc"); Response.ContentType = "application/ms-word97"; } Response.Charset = "Default"; Response.ContentEncoding = System.Text.Encoding.Default; //关闭控件的视图状态 //source.Page.EnableViewState = false; //初始化HtmlWriter //System.IO.StringWriter writer = new System.IO.StringWriter(); //System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(writer); //source.RenderControl(htmlWriter); string ls_mid = ""; if (this.Request.QueryString["mid"] != null) { ls_mid = this.Request.QueryString["mid"].ToString(); } string ls_tableid = ""; if (this.Request.QueryString["tableid"] != null) { ls_tableid = this.Request.QueryString["tableid"].ToString(); } //根据模块ID+表单ID得到对应的域 HyoaClass.Hyoa_flowfield Hyoa_flowfield = new HyoaClass.Hyoa_flowfield(); DataTable dt_flowfield = Hyoa_flowfield.GetflowfieldsbyMudelidAndTableid(ls_mid, ls_tableid); string[] lv_left = new string[dt_flowfield.Rows.Count]; double[] lv_tatal = new double[dt_flowfield.Rows.Count]; string[] lv_right = new string[dt_flowfield.Rows.Count]; for (int i = 0; i < dt_flowfield.Rows.Count; i++) { if (dt_flowfield.Rows[i]["hy_sqlfield"].ToString().Contains("hy_field")) { if (dt_flowfield.Rows[i]["hy_fieldname"].ToString().IndexOf('(') >= 0 && dt_flowfield.Rows[i]["hy_fieldname"].ToString().IndexOf(')') >= 0) { lv_left[i] = dt_flowfield.Rows[i]["hy_fieldname"].ToString().Substring(0, dt_flowfield.Rows[i]["hy_fieldname"].ToString().LastIndexOf('(')); lv_tatal[i] = 0; lv_right[i] = dt_flowfield.Rows[i]["hy_fieldname"].ToString().Substring(dt_flowfield.Rows[i]["hy_fieldname"].ToString().LastIndexOf('(') + 1, dt_flowfield.Rows[i]["hy_fieldname"].ToString().Length - dt_flowfield.Rows[i]["hy_fieldname"].ToString().LastIndexOf('(') - 2); } else { lv_left[i] = dt_flowfield.Rows[i]["hy_fieldname"].ToString(); lv_tatal[i] = 0; lv_right[i] = ""; } } } //得到数据 HyoaClass.Hyoa_flowmain Hyoa_flowmain = new HyoaClass.Hyoa_flowmain(); string[] lv_ids = ls_ids.Split(','); for (var i = 0; i < lv_ids.Length; i++) { if (lv_ids[i] != "") { DataTable dt = Hyoa_flowmain.Getflowmain(lv_ids[i]); if (dt.Rows.Count > 0) { if (dt_flowfield.Rows.Count > 0) { for (var j = 0; j < dt_flowfield.Rows.Count; j++) { if (dt_flowfield.Rows[j]["hy_sqlfield"].ToString().Contains("hy_field")) { if (dt.Rows[0][dt_flowfield.Rows[j]["hy_sqlfield"].ToString()].ToString() == "") lv_tatal[j] = lv_tatal[j]; else lv_tatal[j] = lv_tatal[j] + double.Parse(dt.Rows[0][dt_flowfield.Rows[j]["hy_sqlfield"].ToString()].ToString()); //if (j < dt_flowfield.Rows.Count - 1) //{ // Response.Write(dt_flowfield.Rows[j]["hy_fieldname"].ToString() + ":"); // Response.Write(dt.Rows[0][dt_flowfield.Rows[j]["hy_sqlfield"].ToString()].ToString() + ","); //} } } //Response.Write("\n"); //Response.Write("\n"); } } } } Int32 li_xh = 1; //第一次"其中不合格"不让换行 string ls_flag = "0"; Response.Write(li_xh.ToString() + "."); for (var i = 0; i < lv_tatal.Length; i++) { if (lv_left[i] != null) { //如果是其中受理进出境保税区货物的时候,加“。”换行 if (lv_left[i].ToString() == "检疫查验船舶") { Response.Write("。"); Response.Write("\n"); Response.Write("\n"); li_xh += 1; Response.Write(li_xh.ToString() + "."); } else { if (lv_left[i].ToString() == "查验进境废物原料") { Response.Write("。"); Response.Write("\n"); Response.Write("\n"); li_xh += 1; Response.Write(li_xh.ToString() + "."); } else { if (lv_left[i].ToString() == "规费收入(不包含国航数据)") { Response.Write("。"); Response.Write("\n"); Response.Write("\n"); li_xh += 1; Response.Write(li_xh.ToString() + "."); } else { if (lv_left[i].ToString() == "行政处罚") { Response.Write("。"); Response.Write("\n"); Response.Write("\n"); li_xh += 1; Response.Write(li_xh.ToString() + "."); } else { if (lv_left[i].ToString() == "罚没") { Response.Write("。"); } else { //Response.Write(i.ToString()); if (i != 4) { Response.Write(","); } } } } } } Response.Write(lv_left[i].ToString()); Response.Write(lv_tatal[i].ToString()); Response.Write(lv_right[i].ToString()); } } Response.Write("。"); Response.End(); }
//fy20130801 导入功能 protected void btnDRToSQL_Click(object sender, EventArgs e) { HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global(); HyoaClass.Hyoa_flowfield Hyoa_flowfield = new HyoaClass.Hyoa_flowfield(); //链接SQL数据库 if (FileUpload1.HasFile == false) //HasFile用来检查FileUpload是否有指定文件 { Response.Write("<script>alert('请您选择Excel文件')</script> "); return; //当无文件时,返回 } string IsXls = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower(); //System.IO.Path.GetExtension获得文件的扩展名 if (IsXls != ".xls" && IsXls != ".xlsx") { Response.Write("<script>alert('只可以选择Excel文件')</script>"); return; //当选择的不是Excel文件时,返回 } //根据年份判断在该路径下是否存在以当年年份文件夹 否则将建立以该年份的文件夹 string ls_ny = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString(); //HttpContext.Current.Server.MapPath(相对路径):把相对路径转为服务器上的绝对路径。File.Exists(绝对路径):检查是否存在绝对路径指向的文件或目录。 if (!Directory.Exists(HttpContext.Current.Server.MapPath("~\\upload\\") + "/" + ls_ny)) { //System.IO.Directory.CreateDirectory(文件夹绝对路径):建立绝对路径文件夹。 System.IO.Directory.CreateDirectory(@HttpContext.Current.Server.MapPath("~\\upload\\") + "/" + ls_ny); } string filename = DateTime.Now.ToString("hhMMss") + FileUpload1.FileName; //重新为文件命名,获取Execle文件名 DateTime日期函数 // 保存文件到路径,用Server.MapPath()取当前文件的绝对目录.在asp.net里""必须用"\"代替 string savePath = Server.MapPath(("~\\upload/" + ls_ny + "\\") + filename);//Server.MapPath 获得虚拟服务器相对路径 FileUpload1.SaveAs(savePath); //SaveAs 将上传的文件内容保存在服务器上 DataSet ds = ExecleDs(savePath, filename); //调用自定义方法 DataRow[] dr = ds.Tables[0].Select(); //定义一个DataRow数组 int rowsnum = ds.Tables[0].Rows.Count; int i_into = 0; if (rowsnum == 0) { Response.Write("<script>alert('Excel表为空表,无数据!')</script>"); //当Excel表为空时,对用户进行提示 } else { String ls_zbdocid = ""; //总表的文档id,用于记录到子表中的关联字段中 int li_excelcolumnnum=0; for (int i = 0; i < dr.Length; i++) { try { String sql = ""; String insertstr_left = ""; String insertstr_right = ""; if (dr[i][0].ToString() != "") { //总表 ls_zbdocid = Hyoa_global.GetRandom(); DataTable dt_field = Hyoa_flowfield.GetflowfieldsbyMudelidAndTableid(mudelid.Text, tableid.Text); if (dt_field.Rows.Count > 0) { insertstr_left = "insert into hyc_" + tableid.Text + " (DOCID,hy_mudelid,hy_tableid,hy_djrid,hy_djrname,hy_djrbmid,hy_djrbmname,hy_djsj"; insertstr_right = "'" + ls_zbdocid + "','" + mudelid.Text + "','" + tableid.Text + "','" + Session["hyuid"].ToString() + "','" + Session["hyuname"].ToString() + "','" + Session["hydeptid"].ToString() + "','" + Session["hydeptname"].ToString() + "','" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'"; li_excelcolumnnum = 0; int jj = 0; for (int j = 0; j < dt_field.Rows.Count; j++) { String field_type = dt_field.Rows[j]["hy_fieldtype"].ToString(); if (field_type == "文本" || field_type == "多行文本" || field_type == "文本加按钮" || field_type == "多行文本加按钮" || field_type == "日期" || field_type == "数值" || field_type == "对话框列表" || field_type == "复选框" || field_type == "单选框" || field_type == "口令" || field_type == "编辑器") { insertstr_left += ",hyc_" + dt_field.Rows[j]["hy_fieldid"].ToString(); if (j == 0) { insertstr_right += ",'" + Session["hyuname"].ToString() + "'"; //登记人 } else { if (j == 1) { insertstr_right += ",'" + System.DateTime.Now.ToString("yyyy-MM-dd") + "'"; //登记时间 } else { if (j == 2) { insertstr_right += ",'" + Session["hydeptname"].ToString() + "'"; //登记部门 } else { insertstr_right += ",'" + dr[i][jj].ToString() + "'"; li_excelcolumnnum += 1; jj += 1; } } } } } } } else { //子表 DataTable dt_field = Hyoa_flowfield.GetflowfieldsbyMudelidAndTableid("Mudeljgyjzxtz_kzgz", "Tableykzgz"); if (dt_field.Rows.Count > 0) { insertstr_left = "insert into hyc_Tableykzgz (DOCID,hy_mudelid,hy_tableid,hy_djrid,hy_djrname,hy_djrbmid,hy_djrbmname,hy_djsj,hy_motherid"; insertstr_right = "'" + Hyoa_global.GetRandom() + "','Mudeljgyjzxtz_kzgz','Tableykzgz','" + Session["hyuid"].ToString() + "','" + Session["hyuname"].ToString() + "','" + Session["hydeptid"].ToString() + "','" + Session["hydeptname"].ToString() + "','" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + ls_zbdocid + "'"; for (int j = 0; j < dt_field.Rows.Count; j++) { String field_type = dt_field.Rows[j]["hy_fieldtype"].ToString(); if (field_type == "文本" || field_type == "多行文本" || field_type == "文本加按钮" || field_type == "多行文本加按钮" || field_type == "日期" || field_type == "数值" || field_type == "对话框列表" || field_type == "复选框" || field_type == "单选框" || field_type == "口令" || field_type == "编辑器") { insertstr_left += ",hyc_" + dt_field.Rows[j]["hy_fieldid"].ToString(); insertstr_right += ",'" + dr[i][li_excelcolumnnum+j].ToString() + "'"; } } } } sql = insertstr_left + ") values (" + insertstr_right + ")"; //Response.Write(sql + "<br />"); Hyoa_global.ExcuteSQL(sql); i_into = i_into + 1; } catch { } finally { } } //返回页面 Response.Write("<script>alert('已成功导入" + i_into.ToString() + "条记录!');window.location='import_jgyjzx.aspx?mid="+mudelid.Text+"&tableid="+tableid.Text+"&listid=&rnd="+Hyoa_global.GetRandom()+"'</script>"); } }