JX8011btnSJFXB

using Salien.OfficeEx;
using Salien.Utility;
using Salien.Utility.SUWF;
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace JX8011btnSJFXB
{
    public class JX8011btnSJFXB : ISuwfBus
    {
        private SlnSuwfPage _page;

        public void Initial(SlnSuwfPage page)
        {
            this._page = page;
            this.BindButtonEvent("btnSJFXB");
        }

        private void BindButtonEvent(string strBtnName)
        {
            Control control = this._page.FindControl(strBtnName);
            bool flag = control != null;
            if (flag)
            {
                Button button = (Button)control;
                button.Click += new EventHandler(this.BtnSJFXB_Click);
            }
        }

        protected void BtnSJFXB_Click(object sender, EventArgs e)
        {
            string pk = this._page.GetRowDataPrimaryKeys();
            bool flag = pk == "" || pk.IndexOf(',') > 0;
            if (flag)
            {
                this._page.ShowMessage(SlnString.ScriptAlertMessage("请选择网格1行"));
            }
            else
            {
                HttpContext current = HttpContext.Current;
                string text = "select XNXQ,to_char(YWRQ,'yyyy-mm-dd') as KSRQ,KCMC,BJMC, XKRS,KCDM from JX8011_RWD_TB Where id in (" + pk + ")";
                SortedList valueListBySql = SlnDataAccess.GetValueListBySql(text);
                string text2 = valueListBySql["XNXQ"].ToString();
                string text3 = valueListBySql["KSRQ"].ToString();
                string text4 = valueListBySql["KCMC"].ToString();
                string text5 = valueListBySql["BJMC"].ToString();
                string text6 = valueListBySql["XKRS"].ToString();
                string text7 = valueListBySql["KCDM"].ToString();
                string text8 = current.Server.MapPath("~/TestWeb/试卷分析表.doc");
                WordUtility wordUtility = new WordUtility();
                wordUtility.CreateNewDocument(text8);
                wordUtility.InsertValue("xnxq", text2);
                wordUtility.InsertValue("ksrq", text3);
                wordUtility.InsertValue("kcmc", text4);
                wordUtility.InsertValue("bjmc", text5);
              
                wordUtility.InsertValue("kcdm", text7);
                text = $@"SELECT QJ,PJZ,YXRS,LHRS,ZDRS,JGRS,BJGRS,RS,
 round(BJGRS/RS*100,2)|| '%' as BJGBL,
 round(JGRS/RS*100,2) || '%' as JGBL,
 Round(ZDRS/RS*100,2) || '%' as ZDBL,
                     round(LHRS/RS*100,2) || '%' as LHBL,
                     round(YXRS/RS*100,2) || '%' as YXBL,round( (YXRS+LHRS)/RS*100,2) || '%' as YXLHBL
 From (select max(zp)-min(zp) as QJ,round(avg(zp)) as PJZ, sum(decode(zpcj, 5, 1, 0)) as YXRS
                    ,sum(decode(zpcj, 4, 1, 0)) as LHRS
                    ,sum(decode(zpcj, 3, 1, 0)) as ZDRS,sum(decode(zpcj, 2, 1, 0)) as JGRS,
                    sum(decode(zpcj, 1, 1, 0)) as BJGRS,
                    sum(decode(zpcj, null, 0, 1)) as RS                 
                    from ( with temp as (select  round(qmcj * 0.6 + pscj * 0.4) zp from JX8010_CJDJB_TB 
                    where  qmcj is not null and pscj is not null and rwdid in ({pk}))
  select zp, case when zp > 89 then 5 when zp> 79 and zp<90 then 4 when zp> 69 and zp<80 then 3
  when zp> 59 and zp<70 then 2  else 1 end as zpcj  from temp))";
                valueListBySql = SlnDataAccess.GetValueListBySql(text);
                wordUtility.InsertValue("yxbl", valueListBySql["YXBL"].ToString());
                wordUtility.InsertValue("lhbl", valueListBySql["LHBL"].ToString());
                wordUtility.InsertValue("zdbl", valueListBySql["ZDBL"].ToString());
                wordUtility.InsertValue("jgbl", valueListBySql["JGBL"].ToString());
                wordUtility.InsertValue("bjgbl", valueListBySql["BJGBL"].ToString());
                wordUtility.InsertValue("yxlhbl", valueListBySql["YXLHBL"].ToString());
                ///   round(YXRS / RS * 100, 2) || '%' as YXBL
                wordUtility.InsertValue("xkrs", valueListBySql["RS"].ToString());
                wordUtility.InsertValue("yxrs", valueListBySql["YXRS"].ToString());
                wordUtility.InsertValue("lhrs", valueListBySql["LHRS"].ToString());
                wordUtility.InsertValue("zdrs", valueListBySql["ZDRS"].ToString());
                wordUtility.InsertValue("jgrs", valueListBySql["JGRS"].ToString());
                wordUtility.InsertValue("bjgrs", valueListBySql["BJGRS"].ToString());

                wordUtility.InsertValue("pjz", valueListBySql["PJZ"].ToString());
                wordUtility.InsertValue("qj", valueListBySql["QJ"].ToString());

                string str = string.Concat(new string[]
                {
                    DateTime.Now.Year.ToString(),
                    DateTime.Now.Month.ToString().PadLeft(2, '0'),
                    DateTime.Now.Day.ToString().PadLeft(2, '0'),
                    DateTime.Now.Hour.ToString().PadLeft(2, '0'),
                    DateTime.Now.Minute.ToString().PadLeft(2, '0'),
                    DateTime.Now.Second.ToString().PadLeft(2, '0')
                });
                wordUtility.SaveDocument(current.Server.MapPath("~/TestWeb/" + str + "试卷分析表.doc"));

               string sql = "INSERT INTO JX80113_WJGL_TB(ID,djlx,ZDRQ,ZDRID,RWDID,WJFJ)VALUES(seqJX80113_WJGL.NEXTVAL,2,sysdate,@ZDRID, @RWDID, @WJFJ)";
                sql = sql.Replace("@ZDRID", this._page.GetValueByName("sys_userid")).Replace("@RWDID", pk).Replace("@WJFJ", ConvertFunction.ObjToSqlChar(str + "试卷分析表.doc", "s"));
               
                string msg = SlnDataAccess.ExecuteSQL(sql);

                if (msg == "")
                {
                    _page.ClientScript.RegisterClientScriptBlock(base.GetType(), "Alert", SlnString.ScriptAlertMessage("生成成功"));
                    string strPageName = "commpage.aspx?PU=80113&RWDID=" + pk;
                    _page.ClientScript.RegisterStartupScript(base.GetType(), "ScriptWindowOpenNew", ScriptWindowOpenNew(strPageName, "", 1000, 800, 1, 1, 0, 0, 0, 0));
                }
                else
                {
                    this._page.ClientScript.RegisterClientScriptBlock(base.GetType(), "Alert", SlnString.ScriptAlertMessage("生成失败|" + msg));
                }

            }
        }

        public  string ScriptWindowOpenNew(string strPageName, string strPageTitle, int intWidth, int intHeight, int intResizable, int intScrollBars, int intToolBar, int intMenuBar, int intFullScreen, int intStatus)
        {          
            string str = "";
            str += "<script language='javascript'>\n";
            str += "openWin(\"" + strPageName + "\", \"" + strPageTitle + "\");\n";
            str += "</script>\n";
            return str;
        }
    }
}

 

posted @ 2025-07-14 08:00  知行一体2  阅读(7)  评论(0)    收藏  举报