//导出Excel protected void btn_ExportExcel_Click(object sender, EventArgs e) { //用存储过程读出两个表中的所有信息 DataTable dt = DBCallCommon.GetDTUsingSqlText("EXEC PRO_QC_Reject"); //将该表中需要的信息进行转换并存入新Datatable中 DataTable dt_Export = new DataTable(); dt_Export.Columns.Add(new DataColumn("ORDER_ID", typeof(string))); //单号 dt_Export.Columns.Add(new DataColumn("MAIN_DEP", typeof(string))); //主送部门 dt_Export.Columns.Add(new DataColumn("COPY_DEP", typeof(string))); //抄送部门 dt_Export.Columns.Add(new DataColumn("PJ_NAME", typeof(string))); //项目名称 dt_Export.Columns.Add(new DataColumn("TSA_ENGNAME", typeof(string))); //工程名称 dt_Export.Columns.Add(new DataColumn("BJMC", typeof(string))); //部件名称 dt_Export.Columns.Add(new DataColumn("LJMC", typeof(string))); //零件名称 dt_Export.Columns.Add(new DataColumn("REJECT_TYPE", typeof(string))); //不合格类型 dt_Export.Columns.Add(new DataColumn("RANK", typeof(string))); //判定等级 dt_Export.Columns.Add(new DataColumn("QKMS", typeof(string))); //情况描述 dt_Export.Columns.Add(new DataColumn("REASON_TXT", typeof(string))); //产生原因 dt_Export.Columns.Add(new DataColumn("DUTY_PER", typeof(string))); //负责人 dt_Export.Columns.Add(new DataColumn("DUTY_DEP", typeof(string))); //负责部门 dt_Export.Columns.Add(new DataColumn("QFR_NOTE", typeof(string))); //签发人意见 处置建议 dt_Export.Columns.Add(new DataColumn("JSB_RESULT", typeof(string))); //技术部结论(让步、返修……) dt_Export.Columns.Add(new DataColumn("JSB_NOTE", typeof(string))); //技术部意见 dt_Export.Columns.Add(new DataColumn("JSB_PER", typeof(string))); //技术部负责人 dt_Export.Columns.Add(new DataColumn("JSB_TIME", typeof(string))); //技术部审批时间 dt_Export.Columns.Add(new DataColumn("PZR_RESULT", typeof(string))); //批准人结论(同意,不同意) dt_Export.Columns.Add(new DataColumn("PZR_NOTE", typeof(string))); //批准人意见 dt_Export.Columns.Add(new DataColumn("PZR_PER", typeof(string))); //批准人 dt_Export.Columns.Add(new DataColumn("PZR_TIME", typeof(string))); //批准人审批时间 dt_Export.Columns.Add(new DataColumn("YZR_NOTE", typeof(string))); //验证人意见 dt_Export.Columns.Add(new DataColumn("YZR_PER", typeof(string))); //验证人 dt_Export.Columns.Add(new DataColumn("YZR_TIME", typeof(string))); //验证人审批时间 dt_Export.Columns.Add(new DataColumn("INFORM_DEP", typeof(string))); //通知部门 dt_Export.Columns.Add(new DataColumn("INFORM_TIME", typeof(string))); //通知时间 dt_Export.Columns.Add(new DataColumn("BZR", typeof(string))); //编制人 dt_Export.Columns.Add(new DataColumn("QFR_PER", typeof(string))); //签发人 for (int i = 0; i < dt.Rows.Count; i++) { DataRow row = dt_Export.NewRow(); row["ORDER_ID"] = dt.Rows[i]["ORDER_ID"].ToString(); row["MAIN_DEP"] = dt.Rows[i]["MAIN_DEP"].ToString(); row["COPY_DEP"] = dt.Rows[i]["COPY_DEP"].ToString(); row["PJ_NAME"] = dt.Rows[i]["PJ_NAME"].ToString(); row["TSA_ENGNAME"] = dt.Rows[i]["TSA_ENGNAME"].ToString(); row["BJMC"] = dt.Rows[i]["BJMC"].ToString(); row["LJMC"] = dt.Rows[i]["LJMC"].ToString(); row["QKMS"] = dt.Rows[i]["QKMS"].ToString(); row["REASON_TXT"] = dt.Rows[i]["REASON_TXT"].ToString(); row["DUTY_PER"] = dt.Rows[i]["DUTY_PER"].ToString(); row["INFORM_TIME"] = dt.Rows[i]["INFORM_TIME"].ToString(); row["BZR"] = dt.Rows[i]["ST_NAME"].ToString(); //不合格类型 #region string[] type = dt.Rows[i]["Reject_Type"].ToString().Split('|'); string rejecttype = ""; for (int j = 0; j < type.Length; j++) { switch (type[j]) { case "0": rejecttype += "原材料" + ","; break; case "1": rejecttype += "下料" + ","; break; case "2": rejecttype += "铸造" + ","; break; case "3": rejecttype += "锻造" + ","; break; case "4": rejecttype += "铆焊" + ","; break; case "5": rejecttype += "机加" + ","; break; case "6": rejecttype += "组装" + ","; break; case "7": rejecttype += "试车" + ","; break; case "8": rejecttype += "防腐" + ","; break; case "9": rejecttype += "包装" + ","; break; case "10": rejecttype += "探伤" + ","; break; } } rejecttype = rejecttype.Substring(0, rejecttype.Length - 1); row["REJECT_TYPE"] = rejecttype; #endregion //判定等级 #region string rank = dt.Rows[i]["RANK"].ToString(); string rank_txt = ""; switch (rank) { case "0": rank_txt = "轻微不合格"; break; case "1": rank_txt = "一般不合格"; break; case "2": rank_txt = "一般质量事故"; break; case "3": rank_txt = "重大质量事故"; break; } row["RANK"] = rank_txt; #endregion //通知部门 #region string[] inform_dep = dt.Rows[i]["Inform_dep"].ToString().Split('|'); string informdep_txt = ""; for (int k = 0; k < inform_dep.Length; k++) { string informdep = "select DEP_NAME FROM TBDS_DEPINFO WHERE DEP_CODE='" + inform_dep[k] + "'"; DataTable dt_informdep = DBCallCommon.GetDTUsingSqlText(informdep); if (dt_informdep.Rows.Count > 0) { informdep_txt += dt_informdep.Rows[0]["DEP_NAME"].ToString() + ","; } } informdep_txt = informdep_txt.Substring(0, informdep_txt.Length - 1); row["INFORM_DEP"] = informdep_txt; #endregion //责任部门 #region string[] duty_dep = dt.Rows[i]["Duty_dep"].ToString().Split('|'); string dutydep_txt = ""; for (int m = 0; m < duty_dep.Length; m++) { string dutydep = "select DEP_NAME FROM TBDS_DEPINFO WHERE DEP_CODE='" + duty_dep[m] + "'"; DataTable dt_dutydep = DBCallCommon.GetDTUsingSqlText(dutydep); if (dt_dutydep.Rows.Count > 0) { dutydep_txt += dt_dutydep.Rows[0]["DEP_NAME"].ToString() + ","; } } if (dutydep_txt != "") { dutydep_txt = dutydep_txt.Substring(0, dutydep_txt.Length - 1); } row["DUTY_DEP"] = dutydep_txt; #endregion //签发人,签发人意见 row["QFR_NOTE"] = dt.Rows[i]["Per_note1"].ToString(); row["QFR_PER"] = dt.Rows[i]["st_name1"].ToString(); //技术部意见 row["JSB_NOTE"] = dt.Rows[i]["Per_note2"].ToString(); row["JSB_PER"] = dt.Rows[i]["st_name2"].ToString(); row["JSB_TIME"] = dt.Rows[i]["Per_time2"].ToString(); switch (dt.Rows[i]["Per_result2"].ToString()) { case "1": row["JSB_RESULT"] = "报废"; break; case "2": row["JSB_RESULT"] = "返修/返工"; break; case "3": row["JSB_RESULT"] = "降级"; break; case "4": row["JSB_RESULT"] = "让步"; break; } //批准人意见 row["PZR_NOTE"] = dt.Rows[i]["Per_note3"].ToString(); row["PZR_PER"] = dt.Rows[i]["st_name3"].ToString(); row["PZR_TIME"] = dt.Rows[i]["Per_time3"].ToString(); switch (dt.Rows[i]["Per_result3"].ToString()) { case "1": row["PZR_RESULT"] = "同意"; break; case "2": row["PZR_RESULT"] = "不同意"; break; } //验证人意见 row["YZR_NOTE"] = dt.Rows[i]["Per_note4"].ToString(); row["YZR_PER"] = dt.Rows[i]["st_name4"].ToString(); row["YZR_TIME"] = dt.Rows[i]["Per_time4"].ToString(); dt_Export.Rows.Add(row); } QC_Class.ExportDataItem(dt_Export); }
//导出Excel protected void btn_ExportExcel_Click(object sender, EventArgs e) { string sql = "select Order_id,CON_ID,PJ_NAME,TSA_ENGNAME,BJMC,TH,REJECT_TYPE,REJECT_TYPE2,RANK,CZFS,ZRF,Duty_dep,Inform_time,ST_NAME,NUM,STATE,YZ_TIME from View_TBQC_RejectPro_Info_Detail where " + ViewState["sqlText"].ToString(); DataTable dt_Export = DBCallCommon.GetDTUsingSqlText(sql); for (int i = 0; i < dt_Export.Rows.Count; i++) { DataRow row = dt_Export.Rows[i]; //不合格类型1 #region switch (row["REJECT_TYPE"].ToString()) { case "0": row["REJECT_TYPE"] = "采购"; break; case "1": row["REJECT_TYPE"] = "外协"; break; case "2": row["REJECT_TYPE"] = "场内"; break; } #endregion //不合格类型2 #region string[] type = row["Reject_Type2"].ToString().Split('|'); string rejecttype = ""; for (int j = 0; j < type.Length; j++) { switch (type[j]) { case "0": rejecttype += "化学成分" + "/"; break; case "1": rejecttype += "物理性能" + "/"; break; case "2": rejecttype += "毛坯尺寸" + "/"; break; case "3": rejecttype += "钢材尺寸" + "/"; break; case "4": rejecttype += "铸造缺陷" + "/"; break; case "5": rejecttype += "锻造缺陷" + "/"; break; case "6": rejecttype += "制作质量" + "/"; break; case "7": rejecttype += "装配质量" + "/"; break; case "8": rejecttype += "油漆质量" + "/"; break; case "9": rejecttype += "外观质量" + "/"; break; case "10": rejecttype += "硬度问题" + "/"; break; case "11": rejecttype += "其他" + "/"; break; } } rejecttype = rejecttype.Substring(0, rejecttype.Length - 1); row["REJECT_TYPE2"] = rejecttype; #endregion //判定等级 #region string rank = row["RANK"].ToString(); string rank_txt = ""; switch (rank) { case "0": rank_txt = "一般不合格"; break; case "1": rank_txt = "严重不合格"; break; } row["RANK"] = rank_txt; #endregion //处置方式 switch (row["CZFS"].ToString()) { case "1": row["CZFS"] = "让步接收"; break; case "2": row["CZFS"] = "返修"; break; case "3": row["CZFS"] = "报废"; break; } //是否验证 #region 是否验证 state switch (row["STATE"].ToString()) { case "5": row["STATE"] = "是"; break; default: row["STATE"] = "否"; break; } #endregion } QC_Class.ExportDataItem(dt_Export); }