コード例 #1
0
        public static DataSet RunSPReturnDataSet(string spName, Paras p)
        {
            IDbConnection  conn = DBAccess.GetAppCenterDBConn;
            IDbDataAdapter ada  = DBAccess.GetAppCenterDBAdapter;

            try
            {
                IDbCommand cmd = DBAccess.GetAppCenterDBCommand;
                cmd.CommandText = spName;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = conn;
                if (ada != null)
                {
                    ada.SelectCommand = cmd;
                }

                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                DataSet oratb = new DataSet();
                ada.Fill(oratb);
                return(oratb);
            }
            catch (Exception ex)
            {
                throw new Exception("SQLs=" + spName + " Exception=" + ex.Message);
            }
            finally
            {
                (ada as System.Data.Common.DbDataAdapter).Dispose();
                conn.Close();
            }
        }
コード例 #2
0
        public static int RunSP(string spName, Paras paras)
        {
            switch (DBAccess.AppCenterDBType)
            {
            case DBType.MSSQL:
                SqlConnection conn = new SqlConnection(SystemConfig.AppCenterDSN);
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                return(DBProcedure.RunSP(spName, paras, conn));

                break;

            case DBType.Informix:
                IfxConnection conn1 = new IfxConnection(SystemConfig.AppCenterDSN);
                if (conn1.State != ConnectionState.Open)
                {
                    conn1.Open();
                }
                return(DBProcedure.RunSP(spName, paras, conn1));

                break;

            default:
                throw new Exception("尚未处理。");
                break;
            }
        }
コード例 #3
0
        public static DataTable RunSPReturnDataTable(string spName, Paras paras, OracleConnection conn)
        {
            OracleCommand salesCMD = new OracleCommand(spName, conn);

            salesCMD.CommandType = CommandType.StoredProcedure;

            /// 加上他们的para
            foreach (Para para in paras)
            {
                OracleParameter myParm = salesCMD.Parameters.AddWithValue(para.ParaName, para.DAType);
                myParm.Value = para.val;
            }

            //selectCMD.CommandTimeout =60;
            OracleDataAdapter sda = new OracleDataAdapter(salesCMD);

            //SqlDataAdapter sda = new SqlDataAdapter(salesCMD);
            if (conn.State == System.Data.ConnectionState.Closed)
            {
                conn.Open();
            }
            DataTable dt = new DataTable();

            sda.Fill(dt);
            sda.Dispose();
            return(dt);
        }
コード例 #4
0
        public static DataTable RunSPReturnDataTable(string spName, Paras paras, IfxConnection conn)
        {
            try
            {
                IfxCommand salesCMD = new IfxCommand(spName, conn);
                salesCMD.CommandType = CommandType.StoredProcedure;

                /// 加上他们的餐数
                foreach (Para para in paras)
                {
                    IfxParameter myParm = salesCMD.Parameters.Add(para.ParaName, para.DAType);
                    myParm.Value = para.val;
                }

                //selectCMD.CommandTimeout =60;
                IfxDataAdapter sda = new IfxDataAdapter(salesCMD);
                if (conn.State == System.Data.ConnectionState.Closed)
                {
                    conn.Open();
                }
                DataTable dt = new DataTable();
                sda.Fill(dt);
                sda.Dispose();
                return(dt);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
コード例 #5
0
ファイル: EnDa.cs プロジェクト: zhaoyingju/ccflow
        public static int Retrieve(Entity en, string sql, Paras paras)
        {
            DataTable dt;

            switch (en.EnMap.EnDBUrl.DBUrlType)
            {
            case DBUrlType.AppCenterDSN:
                dt = DBAccess.RunSQLReturnTable(sql, paras);
                break;

            case DBUrlType.DBAccessOfMSMSSQL:
                dt = DBAccessOfMSMSSQL.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOracle:
                dt = DBAccessOfOracle.RunSQLReturnTable(sql);
                break;

            default:
                throw new Exception("@没有设置DB类型。");
            }

            if (dt.Rows.Count == 0)
            {
                return(0);
            }
            Attrs attrs = en.EnMap.Attrs;

            EnDA.fullDate(dt, en, attrs);
            int i = dt.Rows.Count;

            dt.Dispose();
            return(i);
        }
コード例 #6
0
ファイル: DBAccessOfOracle1.cs プロジェクト: splanton/CCFlow
        public static int RunSP(string spName, string para, string paraVal)
        {
            Paras paras = new Paras();
            Para  p     = new Para(para, DbType.String, paraVal);

            paras.Add(p);
            return(DBProcedure.RunSP(spName, paras, DBAccessOfOracle1.GetSingleConn));
        }
コード例 #7
0
ファイル: Write.aspx.cs プロジェクト: zhaoyingju/ccflow
        void btn_Click(object sender, EventArgs e)
        {
            BP.Sys.SMS msg = new BP.Sys.SMS();
            msg.Title  = this.Pub1.GetTextBoxByID("TB_Title").Text;
            msg.Doc    = this.Pub1.GetTextBoxByID("TB_Doc").Text;
            msg.Sender = WebUser.No;
            msg.RDT    = DataType.CurrentDataTime;

            string acces = this.Pub1.GetTextBoxByID("TB_Emps").Text.Trim();

            if (acces.Length == 0)
            {
                throw new Exception("请输入或者选择接受人.");
            }

            if (msg.Title.Length == 0)
            {
                throw new Exception("请输入标题.");
            }

            acces = acces.Replace(";", ",");
            acces = acces.Replace(";;", ",");
            acces = acces.Replace(" ", ",");
            acces = acces.Replace(",,", ",");

            string[] strs = acces.Split(',');
            foreach (string str in strs)
            {
                if (str == null || str == "")
                {
                    continue;
                }

                msg.MsgAccepter = str;
                msg.MyPK        = DBAccess.GenerOID().ToString();
                msg.Insert();
            }

            BP.DA.Paras ps = new BP.DA.Paras();
            ps.Add("Sender", WebUser.No);
            ps.Add("Receivers", msg.MsgAccepter);
            ps.Add("Title", msg.Title);
            ps.Add("Context", msg.Doc);
            try
            {
                DBAccess.RunSP("CCstaff", ps);
            }
            catch (Exception ex)
            {
                this.ToMsgPage("发送消息出现错误:" + ex.Message);
                return;
            }
            this.ToMsgPage("您的信息已经成功的发送到:" + acces);
        }
コード例 #8
0
 /// <summary>
 /// 运行存储过程返回Table
 /// </summary>
 /// <param name="spName">存储过程名称</param>
 /// <param name="paras">参说集合</param>
 /// <returns>执行后的Table</returns>
 public static DataTable RunSPReturnDataTable(string spName, Paras paras)
 {
     if (DBAccess.AppCenterDBType == DBType.MSSQL)
     {
         return(DBProcedure.RunSPReturnDataTable(spName, paras, (SqlConnection)DBAccess.GetAppCenterDBConn));
     }
     else
     {
         return(DBProcedure.RunSPReturnDataTable(spName, paras, (SqlConnection)DBAccess.GetAppCenterDBConn));
     }
 }
コード例 #9
0
        /// <summary>
        /// 运行存储过程返回一个decimal.
        /// </summary>
        /// <param name="spName"></param>
        /// <param name="paras"></param>
        /// <param name="isNullReVal"></param>
        /// <returns></returns>
        public static decimal RunSPReDecimal(string spName, Paras paras, decimal isNullReVal)
        {
            object obj = RunSPReObj(spName, paras);

            if (obj == null || obj == DBNull.Value)
            {
                return(isNullReVal);
            }

            try
            {
                return(decimal.Parse(obj.ToString()));
            }
            catch (Exception ex)
            {
                throw new Exception("RunSPReDecimal error=" + ex.Message + " Obj=" + obj);
            }
        }
コード例 #10
0
        public static int RunSP(string spName, Paras paras, OracleConnection conn)
        {
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }

            OracleCommand salesCMD = new OracleCommand(spName, conn);

            salesCMD.CommandType = CommandType.StoredProcedure;
            foreach (Para para in paras)
            {
                OracleParameter myParameter = new OracleParameter(para.ParaName, OracleType.VarChar);
                myParameter.Direction = ParameterDirection.Input;
                myParameter.Size      = para.Size;
                myParameter.Value     = para.val;
                salesCMD.Parameters.Add(myParameter);
            }
            return(salesCMD.ExecuteNonQuery());
        }
コード例 #11
0
        /// <summary>
        /// 运行存储过程.
        /// </summary>
        /// <param name="spName"></param>
        /// <param name="paras"></param>
        /// <returns></returns>
        public static object RunSPReObj(string spName, Paras paras)
        {
            SqlConnection conn = DBAccessOfMSSQL2.GetSingleConn;
            SqlCommand    cmd  = new SqlCommand(spName, conn);

            cmd.CommandType = CommandType.StoredProcedure;
            if (conn.State == System.Data.ConnectionState.Closed)
            {
                conn.Open();
            }

            foreach (Para para in paras)
            {
                SqlParameter myParameter = new SqlParameter(para.ParaName, para.val);
                myParameter.Direction = ParameterDirection.Input;
                myParameter.Size      = para.Size;
                myParameter.Value     = para.val;
                cmd.Parameters.Add(myParameter);
            }

            return(cmd.ExecuteScalar());
        }
コード例 #12
0
        /// <summary>
        /// 运行存储过程,有Para。返回影响的行。
        /// </summary>
        /// <param name="spName"></param>
        /// <param name="conn"></param>
        /// <param name="paras"></param>
        public static int RunSP(string spName, Paras paras, SqlConnection conn)
        {
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }

            SqlCommand cmd = new SqlCommand(spName, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            // 加入参数
            foreach (Para para in paras)
            {
                SqlParameter myParameter = new SqlParameter(para.ParaName, para.val);
                myParameter.Size = para.Size;
                cmd.Parameters.Add(myParameter);
            }

            int i = cmd.ExecuteNonQuery();

            conn.Close();
            return(i);
        }
コード例 #13
0
 /// <summary>
 /// 运行存储过程
 /// </summary>
 /// <param name="spName">名称</param>
 /// <param name="paras">参数</param>
 /// <returns>DataTable</returns>
 public static DataTable RunSPReTable(string spName, Paras paras)
 {
     return(DBProcedure.RunSPReturnDataTable(spName, paras, DBAccessOfMSSQL2.GetSingleConn));
 }
コード例 #14
0
 /// <summary>
 /// 运行存储过程
 /// </summary>
 /// <param name="spName">名称</param>
 /// <param name="paras">参数</param>
 /// <returns>返回影响的行数</returns>
 public static int RunSP(string spName, Paras paras)
 {
     return(DBProcedure.RunSP(spName, paras, DBAccessOfMSSQL2.GetSingleConn));
 }
コード例 #15
0
        /// <summary>
        /// 签名流程
        /// </summary>
        public string Signcase()
        {
            string flowId  = getUTF8ToString("flowId");
            int    fk_Node = Int32.Parse(getUTF8ToString("nodeId"));
            long   workID  = Int64.Parse(getUTF8ToString("workId"));
            long   fId     = Int64.Parse(getUTF8ToString("fId"));

            if (fId > 0)
            {
                workID = fId;
            }
            string yj = getUTF8ToString("yj");

            if (yj == null || yj == "")
            {
                yj = "已阅";
            }

            BP.DA.Paras ps = new BP.DA.Paras();
            ps.Add("FK_Node", fk_Node);

            DataTable Sys_FrmSln = BP.DA.DBAccess.RunSQLReturnTable("select Sys_FrmSln.FK_MapData,Sys_FrmSln.KeyOfEn,Sys_FrmSln.IsSigan,Sys_MapAttr.MyDataType from Sys_FrmSln,Sys_MapAttr where Sys_FrmSln.UIIsEnable=1 and Sys_FrmSln.IsNotNull=1 and Sys_FrmSln.FK_Node=" + BP.Sys.SystemConfig.AppCenterDBVarStr + "FK_Node and Sys_FrmSln.KeyOfEn=Sys_MapAttr.KeyOfEn and Sys_FrmSln.FK_MapData=Sys_MapAttr.FK_MapData", ps);
            Boolean   IsSign     = false;

            foreach (DataRow DR in Sys_FrmSln.Rows)
            {
                string PTableField = DR["KeyOfEn"].ToString();
                string autotext    = "";
                if (DR["IsSigan"].ToString() == "1")
                {
                    autotext = WebUser.No;
                }
                else if (DR["MyDataType"].ToString() == "6")//时间字段
                {
                    autotext = DateTime.Now.ToString("yyyy-MM-dd");
                }
                else if (DR["MyDataType"].ToString() == "1")//意见字段
                {
                    PTableField = PTableField.ToUpper();
                    if (PTableField.EndsWith("YJ") || PTableField.EndsWith("YJ1") || PTableField.EndsWith("YJ2") || PTableField.EndsWith("YJ3") || PTableField.EndsWith("YJ4") || PTableField.EndsWith("YJ5") || PTableField.EndsWith("YJ6") || PTableField.EndsWith("YJ7") || PTableField.EndsWith("YJ8") || PTableField.EndsWith("YJ9"))
                    {
                        autotext = yj;
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    continue;
                }
                string PTable = BP.DA.DBAccess.RunSQLReturnString("select PTable from Sys_MapData where No='" + DR["FK_MapData"].ToString() + "'");
                if (PTable != null)
                {
                    Int32 HavData = BP.DA.DBAccess.RunSQLReturnValInt("select count(oid) from " + PTable + " where oid=" + workID.ToString());
                    if (HavData == 0)
                    {
                        BP.DA.DBAccess.RunSQL("insert into " + PTable + "(oid," + PTableField + ") values(" + workID.ToString() + ",'" + autotext + "')");
                    }
                    else
                    {
                        BP.DA.DBAccess.RunSQL("update " + PTable + " set " + PTableField + "='" + autotext + "' where oid=" + workID.ToString());
                    }
                    IsSign = true;
                }
            }
            if (IsSign)
            {
                return("签名完毕");
            }
            else
            {
                return("没有签名可签");
            }
        }
コード例 #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
            this.Request.ContentEncoding  = System.Text.UTF8Encoding.UTF8;

            #region 功能执行.
            if (this.DoType == "Del")
            {
                FrmAttachmentDB delDB = new FrmAttachmentDB();
                delDB.MyPK = this.DelPKVal == null ? this.MyPK : this.DelPKVal;

                delDB.DirectDelete();
            }
            if (this.DoType == "Down")
            {
                FrmAttachmentDB downDB = new FrmAttachmentDB();

                downDB.MyPK = this.DelPKVal == null ? this.MyPK : this.DelPKVal;
                downDB.Retrieve();

                string downpath = GetRealPath(downDB.FileFullName);
                BP.Sys.PubClass.DownloadFile(downpath, downDB.FileName);
                this.WinClose();
                return;
            }

            if (this.DoType == "WinOpen")
            {
                FrmAttachmentDB downDB = new FrmAttachmentDB();
                downDB.MyPK = this.MyPK;
                downDB.Retrieve();
                Response.ContentType = "Application/pdf";
                string downpath = GetRealPath(downDB.FileFullName);
                Response.WriteFile(downpath);
                Response.End();
                return;
            }
            #endregion 功能执行.

            #region 处理权限控制.
            BP.Sys.FrmAttachment athDesc = new BP.Sys.FrmAttachment();
            athDesc.MyPK = this.FK_FrmAttachment;
            if (this.FK_Node == null || this.FK_Flow == null)
            {
                athDesc.RetrieveFromDBSources();
            }
            else
            {
                #region 判断是否可以查询出来,如果查询不出来,就可能是公文流程。
                athDesc.MyPK = this.FK_FrmAttachment;
                if (athDesc.RetrieveFromDBSources() == 0 && string.IsNullOrEmpty(this.FK_Flow) == false)
                {
                    /*如果没有查询到它,就有可能是公文多附件被删除了.*/
                    athDesc.MyPK       = this.FK_FrmAttachment;
                    athDesc.NoOfObj    = "DocMultiAth";
                    athDesc.FK_MapData = this.FK_MapData;
                    athDesc.Exts       = "*.*";

                    //存储路径.
                    athDesc.SaveTo    = "/DataUser/UploadFile/";
                    athDesc.IsNote    = false; //不显示note字段.
                    athDesc.IsVisable = false; // 让其在form 上不可见.

                    //位置.
                    athDesc.X = (float)94.09;
                    athDesc.Y = (float)333.18;
                    athDesc.W = (float)626.36;
                    athDesc.H = (float)150;

                    //多附件.
                    athDesc.UploadType = AttachmentUploadType.Multi;
                    athDesc.Name       = "公文多附件(系统自动增加)";
                    athDesc.SetValByKey("AtPara",
                                        "@IsWoEnablePageset=1@IsWoEnablePrint=1@IsWoEnableViewModel=1@IsWoEnableReadonly=0@IsWoEnableSave=1@IsWoEnableWF=1@IsWoEnableProperty=1@IsWoEnableRevise=1@IsWoEnableIntoKeepMarkModel=1@FastKeyIsEnable=0@IsWoEnableViewKeepMark=1@FastKeyGenerRole=@IsWoEnableTemplete=1");
                    athDesc.Insert();

                    //有可能在其其它的节点上没有这个附件,所以也要循环增加上它.
                    BP.WF.Nodes nds = new BP.WF.Nodes(this.FK_Flow);
                    foreach (BP.WF.Node nd in nds)
                    {
                        athDesc.FK_MapData = "ND" + nd.NodeID;
                        athDesc.MyPK       = athDesc.FK_MapData + "_" + athDesc.NoOfObj;
                        if (athDesc.IsExits == true)
                        {
                            continue;
                        }

                        athDesc.Insert();
                    }

                    //重新查询一次,把默认值加上.
                    athDesc.RetrieveFromDBSources();
                }
                #endregion 判断是否可以查询出来,如果查询不出来,就可能是公文流程。

                #region 处理权限方案。
                /*首先判断是否具有权限方案*/
                string at = BP.Sys.SystemConfig.AppCenterDBVarStr;
                Paras  ps = new BP.DA.Paras();
                ps.SQL = "SELECT FrmSln FROM WF_FrmNode WHERE FK_Node=" + at + "FK_Node AND FK_Flow=" + at + "FK_Flow AND FK_Frm=" + at + "FK_Frm";
                ps.Add("FK_Node", this.FK_Node);
                ps.Add("FK_Flow", this.FK_Flow);
                ps.Add("FK_Frm", this.FK_MapData);
                DataTable dt = DBAccess.RunSQLReturnTable(ps);
                if (dt.Rows.Count == 0)
                {
                    athDesc.RetrieveFromDBSources();
                }
                else
                {
                    int sln = int.Parse(dt.Rows[0][0].ToString());
                    if (sln == 0)
                    {
                        athDesc.RetrieveFromDBSources();
                    }
                    else
                    {
                        int result = athDesc.Retrieve(FrmAttachmentAttr.FK_MapData, this.FK_MapData,
                                                      FrmAttachmentAttr.FK_Node, this.FK_Node, FrmAttachmentAttr.NoOfObj, this.Ath);

                        if (result == 0) /*如果没有定义,就获取默认的.*/
                        {
                            athDesc.RetrieveFromDBSources();
                        }
                        //  throw new Exception("@该流程表单在该节点("+this.FK_Node+")使用的是自定义的权限控制,但是没有定义该附件的权限。");
                    }
                }
                #endregion 处理权限方案。
            }

            BP.Sys.FrmAttachmentDBs dbs = new BP.Sys.FrmAttachmentDBs();
            if (athDesc.HisCtrlWay == AthCtrlWay.PWorkID)
            {
                string pWorkID = BP.DA.DBAccess.RunSQLReturnValInt("SELECT PWorkID FROM WF_GenerWorkFlow WHERE WorkID=" + this.PKVal, 0).ToString();
                if (pWorkID == null || pWorkID == "0")
                {
                    pWorkID = this.PKVal;
                }

                if (athDesc.AthUploadWay == AthUploadWay.Inherit)
                {
                    /* 继承模式 */
                    BP.En.QueryObject qo = new BP.En.QueryObject(dbs);
                    qo.AddWhere(FrmAttachmentDBAttr.RefPKVal, pWorkID);
                    qo.addOr();
                    qo.AddWhere(FrmAttachmentDBAttr.RefPKVal, int.Parse(this.PKVal));
                    qo.addOrderBy("RDT");
                    qo.DoQuery();
                }

                if (athDesc.AthUploadWay == AthUploadWay.Interwork)
                {
                    /*共享模式*/
                    dbs.Retrieve(FrmAttachmentDBAttr.RefPKVal, pWorkID);
                }
            }
            else
            {
                int num = dbs.Retrieve(FrmAttachmentDBAttr.FK_FrmAttachment, this.FK_FrmAttachment,
                                       FrmAttachmentDBAttr.RefPKVal, this.PKVal, "RDT");
                if (num == 0 && this.IsCC == "1")
                {
                    CCList cc  = new CCList();
                    int    nnn = cc.Retrieve(CCListAttr.FK_Node, this.FK_Node, CCListAttr.WorkID, this.WorkID, CCListAttr.CCTo, WebUser.No);
                    if (cc.NDFrom != 0)
                    {
                        this._fk_node = cc.NDFrom;

                        dbs.Retrieve(FrmAttachmentDBAttr.FK_FrmAttachment, this.FK_FrmAttachmentExt,
                                     FrmAttachmentDBAttr.FK_MapData, "ND" + cc.NDFrom, FrmAttachmentDBAttr.RefPKVal, this.WorkID.ToString());

                        //重新设置文件描述。
                        athDesc.Retrieve(FrmAttachmentAttr.FK_MapData, this.FK_MapData, FrmAttachmentAttr.NoOfObj, "DocMultiAth");
                    }
                }
            }

            #endregion 处理权限控制.

            #region 生成表头表体.
            this.Title = athDesc.Name;

            #region 如果图片显示.
            if (athDesc.FileShowWay == FileShowWay.Pict)
            {
                /* 如果是图片轮播,就在这里根据数据输出轮播的html代码.*/
                if (dbs.Count == 0 && athDesc.IsUpload == true)
                {
                    /*没有数据并且,可以上传,就转到上传的界面上去.*/
                    this.Response.Redirect("AttachmentUploadImg.aspx?1=1" + this.RequestParas, true);
                    return;
                }

                if (dbs.Count != 0)
                {
                    /*有数据,就输出.*/
                    this.Pub1.Add("<div class='slideBox' id='" + athDesc.MyPK + "' style='width:" + athDesc.W + "px;height:" + athDesc.H + "px; position:relative;  overflow:hidden;'>");
                    this.Pub1.Add("<ul class='items'> ");
                    foreach (FrmAttachmentDB db in dbs)
                    {
                        if (BP.DA.DataType.IsImgExt(db.FileExts) == false)
                        {
                            continue;
                        }
                        if (athDesc.IsDelete != false)
                        {
                            if (athDesc.IsDelete == true)
                            {
                                this.Pub1.Add("<li> <a  title='" + db.MyNote + "'><img src = '" + db.FileFullName + "' width=" + athDesc.W + " height=" + athDesc.H + "/></a> | <a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a></li>");
                            }
                            else if (athDesc.IsDeleteInt == 2)
                            {
                                if (db.Rec.Equals(WebUser.No))
                                {
                                    this.Pub1.Add("<li> <a  title='" + db.MyNote + "'><img src = '" + db.FileFullName + "' width=" + athDesc.W + " height=" + athDesc.H + "/></a> | <a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a></li>");
                                }
                            }
                            else
                            {
                                this.Pub1.Add("<li> <a  title='" + db.MyNote + "'><img src = '" + db.FileFullName + "' width=" + athDesc.W + " height=" + athDesc.H + "/></a> </li>");
                            }
                        }
                        else
                        {
                            this.Pub1.Add("<li> <a  title='" + db.MyNote + "'><img src = '" + db.FileFullName + "' width=" + athDesc.W + " height=" + athDesc.H + "/></a> </li>");
                        }
                    }
                    this.Pub1.Add("</ul>");
                    this.Pub1.Add("</div>");
                    this.Pub1.Add("<script>$(function(){$('#" + athDesc.MyPK + "').slideBox({duration : 0.3,easing : 'linear',delay : 5,hideClickBar : false,clickBarRadius : 10});})</script>");
                }

                if (athDesc.IsUpload == true)
                {
                    /*可以上传,就显示上传的按钮.. */
                    this.Pub1.Add("<a href='AttachmentUploadImg.aspx?1=1" + this.RequestParas + "' >上传</a>");
                }
                return;
            }
            #endregion 如果图片显示.


            float athWidth = athDesc.W - 20;
            // 执行装载模版.
            if (dbs.Count == 0 && athDesc.IsWoEnableTemplete == true)
            {
                /*如果数量为0,就检查一下是否有模版如果有就加载模版文件.*/
                string templetePath = BP.Sys.SystemConfig.PathOfDataUser + "AthTemplete\\" + athDesc.NoOfObj.Trim();
                if (Directory.Exists(templetePath) == false)
                {
                    Directory.CreateDirectory(templetePath);
                }

                /*有模版文件夹*/
                DirectoryInfo mydir = new DirectoryInfo(templetePath);
                FileInfo[]    fls   = mydir.GetFiles();
                if (fls.Length == 0)
                {
                    throw new Exception("@流程设计错误,该多附件启用了模版组件,模版目录:" + templetePath + "里没有模版文件.");
                }

                foreach (FileInfo fl in fls)
                {
                    if (System.IO.Directory.Exists(athDesc.SaveTo) == false)
                    {
                        System.IO.Directory.CreateDirectory(athDesc.SaveTo);
                    }

                    int    oid    = BP.DA.DBAccess.GenerOID();
                    string saveTo = athDesc.SaveTo + "\\" + oid + "." + fl.Name.Substring(fl.Name.LastIndexOf('.') + 1);
                    if (saveTo.Contains("@") == true || saveTo.Contains("*") == true)
                    {
                        /*如果有变量*/
                        saveTo = saveTo.Replace("*", "@");
                        if (saveTo.Contains("@") && this.FK_Node != null)
                        {
                            /*如果包含 @ */
                            BP.WF.Flow       flow = new BP.WF.Flow(this.FK_Flow);
                            BP.WF.Data.GERpt myen = flow.HisGERpt;
                            myen.OID = this.WorkID;
                            myen.RetrieveFromDBSources();
                            saveTo = BP.WF.Glo.DealExp(saveTo, myen, null);
                        }
                        if (saveTo.Contains("@") == true)
                        {
                            throw new Exception("@路径配置错误,变量没有被正确的替换下来." + saveTo);
                        }
                    }
                    fl.CopyTo(saveTo);

                    FileInfo        info     = new FileInfo(saveTo);
                    FrmAttachmentDB dbUpload = new FrmAttachmentDB();

                    dbUpload.CheckPhysicsTable();
                    dbUpload.MyPK             = athDesc.FK_MapData + oid.ToString();
                    dbUpload.NodeID           = FK_Node.ToString();
                    dbUpload.FK_FrmAttachment = this.FK_FrmAttachment;

                    if (athDesc.AthUploadWay == AthUploadWay.Inherit)
                    {
                        /*如果是继承,就让他保持本地的PK. */
                        dbUpload.RefPKVal = this.PKVal.ToString();
                    }

                    if (athDesc.AthUploadWay == AthUploadWay.Interwork)
                    {
                        /*如果是协同,就让他是PWorkID. */
                        string pWorkID = BP.DA.DBAccess.RunSQLReturnValInt("SELECT PWorkID FROM WF_GenerWorkFlow WHERE WorkID=" + this.PKVal, 0).ToString();
                        if (pWorkID == null || pWorkID == "0")
                        {
                            pWorkID = this.PKVal;
                        }
                        dbUpload.RefPKVal = pWorkID;
                    }

                    dbUpload.FK_MapData       = athDesc.FK_MapData;
                    dbUpload.FK_FrmAttachment = this.FK_FrmAttachment;

                    dbUpload.FileExts     = info.Extension;
                    dbUpload.FileFullName = saveTo;
                    dbUpload.FileName     = fl.Name;
                    dbUpload.FileSize     = (float)info.Length;

                    dbUpload.RDT     = DataType.CurrentDataTime;
                    dbUpload.Rec     = BP.Web.WebUser.No;
                    dbUpload.RecName = BP.Web.WebUser.Name;
                    //if (athDesc.IsNote)
                    //    dbUpload.MyNote = this.Pub1.GetTextBoxByID("TB_Note").Text;
                    //if (athDesc.Sort.Contains(","))
                    //    dbUpload.Sort = this.Pub1.GetDDLByID("ddl").SelectedItemStringVal;

                    dbUpload.Insert();

                    dbs.AddEntity(dbUpload);
                }
                //BP.Sys.FrmAttachmentDBs dbs = new BP.Sys.FrmAttachmentDBs();
            }

            #region 处理权限问题.
            // 处理权限问题, 有可能当前节点是可以上传或者删除,但是当前节点上不能让此人执行工作。
            bool isDel    = athDesc.IsDeleteInt == 0 ? false : true;
            bool isUpdate = athDesc.IsUpload;
            if (isDel == true || isUpdate == true)
            {
                if (this.WorkID != 0 &&
                    string.IsNullOrEmpty(this.FK_Flow) == false &&
                    this.FK_Node != 0)
                {
                    isDel = BP.WF.Dev2Interface.Flow_IsCanDoCurrentWork(this.FK_Flow, this.FK_Node, this.WorkID, WebUser.No);
                    if (isDel == false)
                    {
                        isUpdate = false;
                    }
                }
            }
            #endregion 处理权限问题.

            if (athDesc.FileShowWay == FileShowWay.Free)
            {
                this.Pub1.AddTable("border='0' cellspacing='0' cellpadding='0' style='width:" + athWidth + "px'");
                foreach (FrmAttachmentDB db in dbs)
                {
                    this.Pub1.AddTR();
                    if (CanEditor(db.FileExts))
                    {
                        if (athDesc.IsWoEnableWF)
                        {
                            this.Pub1.AddTD("<a href=\"javascript:OpenOfiice('" + this.FK_FrmAttachment + "','" +
                                            this.WorkID + "','" + db.MyPK + "','" + this.FK_MapData + "','" + this.Ath +
                                            "','" + this.FK_Node + "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>");
                        }
                        else
                        {
                            this.Pub1.AddTD("<a href=\"javascript:OpenView('" + this.PKVal + "','" + db.MyPK +
                                            "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>");
                        }
                    }
                    else if (DataType.IsImgExt(db.FileExts) || db.FileExts.ToUpper() == "PDF" || db.FileExts.ToUpper() == "CEB")
                    {
                        this.Pub1.AddTD("<a href=\"javascript:OpenView('" + this.PKVal + "','" + db.MyPK +
                                        "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>");
                    }
                    else
                    {
                        this.Pub1.AddTD("<a href='AttachmentUpload.aspx?DoType=Down&MyPK=" + db.MyPK +
                                        "' target=_blank ><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>");
                    }

                    if (athDesc.IsDownload)
                    {
                        this.Pub1.AddTD("<a href=\"javascript:Down('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">下载</a>");
                    }
                    else
                    {
                        this.Pub1.AddTD("");
                    }

                    if (this.IsReadonly != "1")
                    {
                        if (athDesc.IsDelete != false)
                        {
                            if (athDesc.IsDelete == true)
                            {
                                this.Pub1.AddTD("style='border:0px'", "<a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a>");
                            }
                            else if (athDesc.IsDeleteInt == 2)
                            {
                                if (db.Rec.Equals(WebUser.No))
                                {
                                    this.Pub1.AddTD("style='border:0px'", "<a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a>");
                                }
                            }
                            else
                            {
                                this.Pub1.AddTD("");
                            }
                        }
                        else
                        {
                            this.Pub1.AddTD("");
                        }
                    }
                    else
                    {
                        this.Pub1.AddTD("");
                        this.Pub1.AddTD("");
                    }

                    this.Pub1.AddTREnd();
                }
                AddFileUpload(isUpdate, athDesc);
                this.Pub1.AddTableEnd();
                return;
            }

            this.Pub1.AddTable("border='0' cellspacing='0' cellpadding='0' style='width:" + athWidth + "px'");
            if (athDesc.IsShowTitle == true)
            {
                this.Pub1.AddTR("style='border:0px'");

                this.Pub1.AddTDTitleExt("序号");
                if (athDesc.Sort.Contains(","))
                {
                    this.Pub1.AddTD("style='background:#f4f4f4; font-size:12px; padding:3px;'", "类别");
                }
                this.Pub1.AddTDTitleExt("文件名");
                this.Pub1.AddTDTitleExt("大小KB");
                this.Pub1.AddTDTitleExt("上传时间");
                this.Pub1.AddTDTitleExt("上传人");
                this.Pub1.AddTDTitleExt("操作");
                this.Pub1.AddTREnd();
            }

            int           i       = 0;
            StringBuilder picHtml = new StringBuilder();
            foreach (FrmAttachmentDB db in dbs)
            {
                i++;
                this.Pub1.AddTR();
                this.Pub1.AddTDIdx(i);
                if (athDesc.Sort.Contains(","))
                {
                    this.Pub1.AddTD(db.Sort);
                }

                // this.Pub1.AddTDIdx(i++);
                if (athDesc.IsDownload)
                {
                    if (athDesc.IsWoEnableWF && CanEditor(db.FileExts))
                    {
                        this.Pub1.AddTD("<a href=\"javascript:OpenOfiice('" + this.FK_FrmAttachment + "','" + this.WorkID + "','" + db.MyPK + "','" + this.FK_MapData + "','" + this.Ath + "','" + this.FK_Node + "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>");
                    }
                    else if (db.FileExts.ToUpper() == "TXT" || db.FileExts.ToUpper() == "JPG" || db.FileExts.ToUpper() == "JPEG" || db.FileExts.ToUpper() == "GIF" || db.FileExts.ToUpper() == "PNG" || db.FileExts.ToUpper() == "BMP" || db.FileExts.ToUpper() == "PDF" || db.FileExts.ToUpper() == "CEB")
                    {
                        this.Pub1.AddTD("<a href=\"javascript:OpenView('" + this.PKVal + "','" + db.MyPK + "')\"><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>");
                    }
                    else
                    {
                        this.Pub1.AddTD("<a href='AttachmentUpload.aspx?DoType=Down&MyPK=" + db.MyPK + "' target=_blank ><img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName + "</a>");
                    }
                }
                else
                {
                    this.Pub1.AddTD("<img src='../Img/FileType/" + db.FileExts + ".gif' border=0 onerror=\"src='../Img/FileType/Undefined.gif'\" />" + db.FileName);
                }

                this.Pub1.AddTD(db.FileSize);
                this.Pub1.AddTD(db.RDT);
                this.Pub1.AddTD(db.RecName);

                //输出操作部分.
                this.Pub1.AddTDBegin();
                if (athDesc.IsDownload)
                {
                    this.Pub1.Add("<a href=\"javascript:Down('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">下载</a>");
                }
                if (this.IsReadonly != "1")
                {
                    string op = null;
                    if (isDel == true)
                    {
                        if (athDesc.IsDelete == true)
                        {
                            op = "&nbsp;&nbsp;&nbsp;<a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a>";
                        }
                        else if (athDesc.IsDeleteInt == 2)
                        {
                            if (db.Rec.Equals(WebUser.No))
                            {
                                op = "&nbsp;&nbsp;&nbsp;<a href=\"javascript:Del('" + this.FK_FrmAttachment + "','" + this.PKVal + "','" + db.MyPK + "')\">删除</a>";
                            }
                        }
                    }

                    this.Pub1.Add(op);
                }
                this.Pub1.AddTDEnd();

                this.Pub1.AddTREnd();
            }
            if (i == 0)
            {
                this.Pub1.AddTR();
                this.Pub1.AddTD("0");
                if (athDesc.Sort.Contains(","))
                {
                    this.Pub1.AddTD("&nbsp&nbsp");
                }
                this.Pub1.AddTD("style='width:100px'", "<span style='color:red;' >上传附件</span>");
                this.Pub1.AddTD("&nbsp&nbsp");
                this.Pub1.AddTD("&nbsp&nbsp");
                this.Pub1.AddTD("&nbsp&nbsp");
                this.Pub1.AddTD("&nbsp&nbsp");
                this.Pub1.AddTREnd();
            }

            AddFileUpload(isUpdate, athDesc);
            this.Pub1.AddTableEnd();

            #endregion 生成表头表体.
        }
コード例 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Page.RegisterClientScriptBlock("s",
                                            "<link href='/WF/Comm/Style/Table" + BP.Web.WebUser.Style + ".css' rel='stylesheet' type='text/css' />");

        if (this.Request.RawUrl.ToLower().Contains("login.aspx") == false)
        {
            if (BP.Web.WebUser.No == null)
            {
                this.Response.Redirect("Login.aspx", true);
                return;
            }
        }

        Response.AddHeader("P3P", "CP=CAO PSA OUR");
        Response.AddHeader("Cache-Control", "no-store");
        Response.AddHeader("Expires", "0");
        Response.AddHeader("Pragma", "no-cache");

        BP.WF.XML.ToolBars ens = new BP.WF.XML.ToolBars();
        ens.RetrieveAll();

        int numCC = 0;
        int num   = 0;

        if (BP.Web.WebUser.NoOfRel != null)
        {
            BP.DA.Paras ps = new BP.DA.Paras();
            string      sql, sql2;
            if (BP.Web.WebUser.IsAuthorize)
            {
                BP.WF.Port.WFEmp emp = new BP.WF.Port.WFEmp(BP.Web.WebUser.No);
                ps.SQL = "SELECT COUNT(*) AS Num FROM WF_EmpWorks WHERE ( WFState=" + (int)BP.WF.WFState.Runing + " ) AND FK_Emp=" + SystemConfig.AppCenterDBVarStr + "FK_Emp  AND FK_Flow IN " + emp.AuthorFlows;
                ps.AddFK_Emp();
            }
            else
            {
                ps.AddFK_Emp();
                ps.SQL = "SELECT COUNT(*) AS Num FROM WF_EmpWorks WHERE WFState=" + (int)BP.WF.WFState.Runing + " and FK_Emp=" + SystemConfig.AppCenterDBVarStr + "FK_Emp";
            }
            num = BP.DA.DBAccess.RunSQLReturnValInt(ps);

            ps     = new BP.DA.Paras();
            ps.SQL = "SELECT COUNT(MyPK) FROM WF_CCList WHERE Sta=0 AND CCTo=" + BP.SystemConfig.AppCenterDBVarStr + "FK_Emp";
            ps.AddFK_Emp();

            numCC = BP.DA.DBAccess.RunSQLReturnValInt(ps);
        }

        string msg   = "待办";
        string msgCC = "抄送";

        if (num != 0)
        {
            msg = "<div id='blink'>待办-" + num + "</div>";
            string script = "";
            script += "<script language=javascript>";
            script += "function changeColor(){";
            script += " var color='#f00|#0f0|#00f|#880|#808|#088|yellow|green|blue|gray';";
            script += " color=color.split('|'); ";
            script += " try{";
            script += " document.getElementById('blink').style.color=color[parseInt(Math.random() * color.length)] ";
            script += " catch ()";
            script += " }";
            script += " setInterval('changeColor()',200);";
            script += "</script> ";
            this.Page.ClientScript.RegisterClientScriptBlock(typeof(string), "s", script);
        }
        if (numCC != 0)
        {
            msgCC = "<div id='blink'>抄送-" + numCC + "</div>";
            string script = "";
            script += "<script language=javascript>";
            script += "function changeColor1(){";
            script += " var color='#f00|#0f0|#00f|#880|#808|#088|yellow|green|blue|gray';";
            script += " color=color.split('|'); ";
            script += " document.getElementById('blink').style.color=color[parseInt(Math.random() * color.length)] ";
            script += " }";
            script += " setInterval('changeColor1()',300);";
            script += "</script> ";
            this.Page.ClientScript.RegisterClientScriptBlock(typeof(string), "scc", script);
        }

        #region 菜单输出区域


        string dotype = this.PageID;
        if (BP.WF.Glo.IsShowTitle)
        {
            this.Pub1.Add("<DIV class='wp' >");
            this.Pub1.Add("<div  id='Top' class='top' /><h2><img src='/DataUser/ICON/" + SystemConfig.CompanyID + "/LogBiger.png'  border=0 /></h2></div>");
        }

        this.Page.RegisterClientScriptBlock("d",
                                            "<link href='/DataUser/Style/Skin/T" + BP.Web.WebUser.Style + "/Style.css' rel='stylesheet' type='text/css' />");

        this.Pub1.Add("<DIV ID=nv class='nv' >");
        this.Pub1.Add("<UL>");
        foreach (BP.WF.XML.ToolBar en in ens)
        {
            if (en.No == dotype)
            {
                if (en.No == "EmpWorks")
                {
                    this.Pub1.Add("<li class=current ><a href=\"" + en.Url + "\" target='_self' title='" + en.Title + "' ><span>" + msg + "</span></a></li>");
                }
                else if (en.No == "CC")
                {
                    this.Pub1.Add("<li class=current ><a href=\"" + en.Url + "\" target='_self' title='" + en.Title + "' ><span>" + msgCC + "</span></a></li>");
                }
                else
                {
                    this.Pub1.Add("<li class=current ><a href=\"" + en.Url + "\" target='_self' title='" + en.Title + "' ><span>" + en.Name + "</span></a></li>");
                }
            }
            else
            {
                if (en.No == "EmpWorks")
                {
                    this.Pub1.Add("<li class='Barli' ><a href=\"" + en.Url + "\" target='_self' title='" + en.Title + "' ><span>" + msg + "</span></a></li>");
                }
                else if (en.No == "CC")
                {
                    this.Pub1.Add("<li class='Barli' ><a href=\"" + en.Url + "\" target='_self' title='" + en.Title + "' ><span>" + msgCC + "</span></a></li>");
                }
                else
                {
                    this.Pub1.Add("<li class='Barli' ><a href=\"" + en.Url + "\" target='_self' title='" + en.Title + "' ><span>" + en.Name + "</span></a></li>");
                }
            }
        }

        if (BP.Web.WebUser.NoOfRel == null)
        {
            this.Pub1.Add("</UL> <div style='float:right;margin-right:30px;display:inline-block;line-height:35px;color:white' >未登录</div>");
        }
        else
        {
            this.Pub1.Add("</UL> <div style='float:right;margin-right:30px;display:inline-block;line-height:35px;color:white' >您好:" + BP.Web.WebUser.No + "," + BP.Web.WebUser.Name + "</div>");
        }

        this.Pub1.Add("</DIV>");
        if (BP.WF.Glo.IsShowTitle)
        {
            this.Pub1.Add("</DIV>");
        }
        #endregion 菜单输出区域
    }
コード例 #18
0
        public static DataTable RunSPReturnDataTable(string spName, OracleConnection conn)
        {
            Paras ens = new Paras();

            return(DBProcedure.RunSPReturnDataTable(spName, ens, conn));
        }
コード例 #19
0
ファイル: EnDa.cs プロジェクト: zhaoyingju/ccflow
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="en">产生要更新的语句</param>
        /// <param name="keys">要更新的属性(null,认为更新全部)</param>
        /// <returns>sql</returns>
        public static int Update(Entity en, string[] keys)
        {
            if (en.EnMap.EnType == EnType.View)
            {
                return(0);
            }
            try
            {
                switch (en.EnMap.EnDBUrl.DBUrlType)
                {
                case DBUrlType.AppCenterDSN:
                    switch (SystemConfig.AppCenterDBType)
                    {
                    case DBType.MSSQL:
                    case DBType.Oracle:
                    case DBType.MySQL:
                        return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys), SqlBuilder.GenerParas(en, keys)));

                    case DBType.Informix:
                        return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys), SqlBuilder.GenerParas_Update_Informix(en, keys)));

                    case DBType.Access:
                        return(DBAccess.RunSQL(SqlBuilder.UpdateOfMSAccess(en, keys)));

                    default:
                        //return DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys),
                        //    SqlBuilder.GenerParas(en, keys));
                        if (keys != null)
                        {
                            Paras ps   = new Paras();
                            Paras myps = SqlBuilder.GenerParas(en, keys);
                            foreach (Para p in myps)
                            {
                                foreach (string s in keys)
                                {
                                    if (s == p.ParaName)
                                    {
                                        ps.Add(p);
                                        break;
                                    }
                                }
                            }
                            return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys), ps));
                        }
                        else
                        {
                            return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys),
                                                   SqlBuilder.GenerParas(en, keys)));
                        }
                        break;
                    }

                case DBUrlType.DBAccessOfMSMSSQL:
                    return(DBAccessOfMSMSSQL.RunSQL(SqlBuilder.Update(en, keys)));

                case DBUrlType.DBAccessOfOracle:

                    return(DBAccessOfOracle.RunSQL(SqlBuilder.Update(en, keys)));

                default:
                    throw new Exception("@没有设置类型。");
                }
            }
            catch (Exception ex)
            {
                if (BP.SystemConfig.IsDebug)
                {
                    en.CheckPhysicsTable();
                }
                throw ex;
            }
        }
コード例 #20
0
        public DataTable BindDG()
        {
            #region 校验选择项目。
            if (this.DDL_V1.SelectedIndex == this.DDL_V2.SelectedIndex)
            {
                if (this.DDL_V1.SelectedIndex == 0)
                {
                    this.DDL_V2.SelectedIndex = 1;
                }
                else
                {
                    this.DDL_V2.SelectedIndex = 0;
                }
            }

            if (this.DDL_Group.SelectedIndex == this.DDL_D.SelectedIndex)
            {
                if (this.DDL_Group.SelectedIndex == 0)
                {
                    this.DDL_D.SelectedIndex = 1;
                }
                else
                {
                    this.DDL_D.SelectedIndex = 0;
                }
            }
            this.SaveState();
            #endregion 校验选择项目。


            Attrs attrs = this.HisMD.AttrsInTableEns;
            Attr  d1    = attrs.GetAttrByKey(this.DDL_D.SelectedItemStringVal);
            Attr  dNum  = attrs.GetAttrByKey(this.DDL_Num.SelectedItemStringVal);


            string v1        = this.DDL_V1.SelectedItemStringVal;
            string v2        = this.DDL_V2.SelectedItemStringVal;
            string groupAttr = this.DDL_Group.SelectedItemStringVal;
            string fxField   = this.DDL_FXWay.SelectedItemStringVal + "(" + dNum.Key + ")";

            string sql1 = "SELECT " + groupAttr + "," + d1.Key + "," + fxField + " FROM " + this.HisMD.No + " WHERE " + d1.Field + "='" + this.DDL_V1.SelectedItemStringVal + "'  GROUP BY " + groupAttr + "," + d1.Key;
            string sql2 = "SELECT " + groupAttr + "," + d1.Key + "," + fxField + " FROM " + this.HisMD.No + " WHERE " + d1.Field + "='" + this.DDL_V2.SelectedItemStringVal + "' GROUP BY " + groupAttr + "," + d1.Key;

            //   throw new Exception(sql1);

            DataTable dt1 = DBAccess.RunSQLReturnTable(sql1);
            DataTable dt2 = DBAccess.RunSQLReturnTable(sql2);
            this.Bind(dt1, dt2, "sss");
            return(null);

            SysEnums sesD1 = null;
            Entities ensD1 = null;
            SysEnums sesD2 = null;
            Entities ensD2 = null;
            Map      map   = this.HisMD.HisEn.EnMap;

            #region 生成两个纬度报表
            Attr attrD1 = attrs.GetAttrByKey(this.DDL_V1.SelectedItemStringVal);
            if (attrD1.IsEnum)
            {
                sesD1 = new SysEnums(attrD1.UIBindKey);
            }
            else
            {
                ensD1 = attrD1.HisFKEns;
            }

            Attr attrD2 = attrs.GetAttrByKey(this.DDL_V2.SelectedItemStringVal);
            if (attrD2.IsEnum)
            {
                sesD2 = new SysEnums(attrD2.UIBindKey);
            }
            else
            {
                ensD2 = attrD2.HisFKEns;
            }
            #endregion


            #region 生成执行的原始sql
            string Condition = ""; //处理特殊字段的条件问题。
            Paras  myps      = new BP.DA.Paras();
            string sql       = "SELECT " + attrD1.Key + "," + attrD2.Key + ", " + this.DDL_FXWay.SelectedItemStringVal + "(" + this.DDL_Num.SelectedItemStringVal + ") FROM " + map.PhysicsTable;
            // 找到 WHERE 数据。
            string where = " WHERE ";
            string whereOfLJ = " WHERE "; // 累计的where.
            string url       = "";
            foreach (Control item in this.ToolBar1.Controls)
            {
                if (item.ID == null)
                {
                    continue;
                }
                if (item.ID.IndexOf("DDL_") == -1)
                {
                    continue;
                }
                if (item.ID.IndexOf("DDL_Form_") == 0 || item.ID.IndexOf("DDL_To_") == 0)
                {
                    continue;
                }

                string key = item.ID.Substring("DDL_".Length);
                DDL    ddl = (DDL)item;
                if (ddl.SelectedItemStringVal == "all")
                {
                    continue;
                }

                string val = ddl.SelectedItemStringVal;
                if (val == null)
                {
                    continue;
                }

                if (val == "mvals")
                {
                    UserRegedit sUr = new UserRegedit();
                    sUr.MyPK = WebUser.No + this.EnsName + "_SearchAttrs";
                    sUr.RetrieveFromDBSources();

                    /* 如果是多选值 */
                    string cfgVal = sUr.MVals;
                    AtPara ap     = new AtPara(cfgVal);
                    string instr  = ap.GetValStrByKey(key);
                    if (instr == null || instr == "")
                    {
                        if (key == "FK_Dept" || key == "FK_Unit")
                        {
                            if (key == "FK_Dept")
                            {
                                val = WebUser.FK_Dept;
                                ddl.SelectedIndex = 0;
                            }

                            if (key == "FK_Unit")
                            {
                                //   val = WebUser.FK_Unit;
                                ddl.SelectedIndex = 0;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        instr  = instr.Replace("..", ".");
                        instr  = instr.Replace(".", "','");
                        instr  = instr.Substring(2);
                        instr  = instr.Substring(0, instr.Length - 2);
                        where += " " + key + " IN (" + instr + ")  AND ";
                        continue;
                    }
                }

                if (key == "FK_Dept")
                {
                    if (val.Length == 8)
                    {
                        where += " FK_Dept =" + SystemConfig.AppCenterDBVarStr + "V_Dept    AND ";
                    }
                    else
                    {
                        switch (SystemConfig.AppCenterDBType)
                        {
                        case DBType.Oracle:
                        case DBType.Informix:
                            where += " FK_Dept LIKE '%'||:V_Dept||'%'   AND ";
                            break;

                        case DBType.MSSQL:
                        default:
                            where += " FK_Dept LIKE  " + SystemConfig.AppCenterDBVarStr + "V_Dept+'%'   AND ";
                            break;
                        }
                    }
                    myps.Add("V_Dept", val);
                }
                else
                {
                    where += " " + key + " =" + SystemConfig.AppCenterDBVarStr + key + "   AND ";
                    if (key != "FK_NY")
                    {
                        whereOfLJ += " " + key + " =" + SystemConfig.AppCenterDBVarStr + key + "   AND ";
                    }

                    myps.Add(key, val);
                }
            }
            #endregion

            #region 加上 where like 条件
            try
            {
                string key = this.ToolBar1.GetTBByID("TB_Key").Text.Trim();
                if (key.Length > 1)
                {
                    string whereLike = "";

                    bool isAddAnd = false;
                    foreach (Attr likeKey in attrs)
                    {
                        if (likeKey.IsNum)
                        {
                            continue;
                        }
                        if (likeKey.IsRefAttr)
                        {
                            continue;
                        }

                        switch (likeKey.Field)
                        {
                        case "MyFileExt":
                        case "MyFilePath":
                        case "WebPath":
                            continue;

                        default:
                            break;
                        }


                        if (isAddAnd == false)
                        {
                            isAddAnd   = true;
                            whereLike += "      " + likeKey.Field + " LIKE '%" + key + "%' ";
                        }
                        else
                        {
                            whereLike += "   AND   " + likeKey.Field + " LIKE '%" + key + "%'";
                        }
                    }
                    whereLike += "          ";
                    where     += whereLike;
                }
            }
            catch
            {
            }
            #endregion

            #region 加上日期时间段.
            if (map.DTSearchWay != DTSearchWay.None)
            {
                string dtFrom = this.ToolBar1.GetTBByID("TB_S_From").Text.Trim();
                string dtTo   = this.ToolBar1.GetTBByID("TB_S_To").Text.Trim();
                string field  = map.DTSearchKey;
                if (map.DTSearchWay == DTSearchWay.ByDate)
                {
                    where += "( " + field + ">='" + dtFrom + " 01:01' AND " + field + "<='" + dtTo + " 23:59')     ";
                }
                else
                {
                    where += "(";
                    where += field + " >='" + dtFrom + "' AND " + field + "<='" + dtTo + "'";
                    where += ")";
                }
            }
            if (where == " WHERE ")
            {
                where     = "" + Condition.Replace("and", "");
                whereOfLJ = "" + Condition.Replace("and", "");
            }
            else
            {
                where     = where.Substring(0, where.Length - " AND ".Length) + Condition;
                whereOfLJ = whereOfLJ.Substring(0, whereOfLJ.Length - " AND ".Length) + Condition;
            }
            #endregion

            sql     += where + " GROUP BY  " + attrD1.Key + "," + attrD2.Key;
            myps.SQL = sql;
            DataTable dt = DBAccess.RunSQLReturnTable(myps);


            return(null);
        }
コード例 #21
0
        /// <summary>
        /// 添加图片
        /// </summary>
        private void RenderPic(string type)
        {
            #region 处理权限控制.
            BP.Sys.FrmAttachment athDesc = new BP.Sys.FrmAttachment();
            athDesc.MyPK = this.FK_FrmAttachment;
            if (this.FK_Node == null || this.FK_Flow == null)
            {
                athDesc.RetrieveFromDBSources();
            }
            else
            {
                #region 判断是否可以查询出来,如果查询不出来,就可能是公文流程。
                athDesc.MyPK = this.FK_FrmAttachment;
                if (athDesc.RetrieveFromDBSources() == 0 && string.IsNullOrEmpty(this.FK_Flow) == false)
                {
                    /*如果没有查询到它,就有可能是公文多附件被删除了.*/
                    athDesc.MyPK       = this.FK_FrmAttachment;
                    athDesc.NoOfObj    = "DocMultiAth";
                    athDesc.FK_MapData = this.FK_MapData;
                    athDesc.Exts       = "*.*";

                    //存储路径.
                    string path = Server.MapPath("/DataUser/UploadFile/");
                    path          += "\\F" + this.FK_Flow + "MultiAth";
                    athDesc.SaveTo = path;
                    athDesc.IsNote = false; //不显示note字段.


                    //位置.
                    athDesc.X = (float)94.09;
                    athDesc.Y = (float)333.18;
                    athDesc.W = (float)626.36;
                    athDesc.H = (float)150;

                    //多附件.
                    athDesc.UploadType = AttachmentUploadType.Multi;
                    athDesc.Name       = "公文多附件(系统自动增加)";
                    athDesc.SetValByKey("AtPara",
                                        "@IsWoEnablePageset=1@IsWoEnablePrint=1@IsWoEnableViewModel=1@IsWoEnableReadonly=0@IsWoEnableSave=1@IsWoEnableWF=1@IsWoEnableProperty=1@IsWoEnableRevise=1@IsWoEnableIntoKeepMarkModel=1@FastKeyIsEnable=0@IsWoEnableViewKeepMark=1@FastKeyGenerRole=@IsWoEnableTemplete=1");
                    athDesc.Insert();

                    //有可能在其其它的节点上没有这个附件,所以也要循环增加上它.
                    BP.WF.Nodes nds = new BP.WF.Nodes(this.FK_Flow);
                    foreach (BP.WF.Node nd in nds)
                    {
                        athDesc.FK_MapData = "ND" + nd.NodeID;
                        athDesc.MyPK       = athDesc.FK_MapData + "_" + athDesc.NoOfObj;
                        if (athDesc.IsExits == true)
                        {
                            continue;
                        }

                        athDesc.Insert();
                    }

                    //重新查询一次,把默认值加上.
                    athDesc.RetrieveFromDBSources();
                }
                #endregion 判断是否可以查询出来,如果查询不出来,就可能是公文流程。

                #region 处理权限方案。
                /*首先判断是否具有权限方案*/
                string at = BP.Sys.SystemConfig.AppCenterDBVarStr;
                Paras  ps = new BP.DA.Paras();
                ps.SQL = "SELECT FrmSln FROM WF_FrmNode WHERE FK_Node=" + at + "FK_Node AND FK_Flow=" + at + "FK_Flow AND FK_Frm=" + at + "FK_Frm";
                ps.Add("FK_Node", this.FK_Node);
                ps.Add("FK_Flow", this.FK_Flow);
                ps.Add("FK_Frm", this.FK_MapData);
                DataTable dt = DBAccess.RunSQLReturnTable(ps);
                if (dt.Rows.Count == 0)
                {
                    athDesc.RetrieveFromDBSources();
                }
                else
                {
                    int sln = int.Parse(dt.Rows[0][0].ToString());
                    if (sln == 0)
                    {
                        athDesc.RetrieveFromDBSources();
                    }
                    else
                    {
                        int result = athDesc.Retrieve(FrmAttachmentAttr.FK_MapData, this.FK_MapData,
                                                      FrmAttachmentAttr.FK_Node, this.FK_Node, FrmAttachmentAttr.NoOfObj, this.Ath);

                        if (result == 0) /*如果没有定义,就获取默认的.*/
                        {
                            athDesc.RetrieveFromDBSources();
                        }
                        //  throw new Exception("@该流程表单在该节点("+this.FK_Node+")使用的是自定义的权限控制,但是没有定义该附件的权限。");
                    }
                }
                #endregion 处理权限方案。
            }



            #endregion 处理权限控制.

            BP.Sys.FrmAttachmentDBs dbs = LoadAttach(athDesc);
            this.Pub1.AddTable("style='width:100%;overflow:hidden;padding:0px;margin:0px;display:block;'");
            int  idx        = 0;
            bool isHave     = false;
            bool isRedirect = false;
            int  count      = 0;
            foreach (FrmAttachmentDB db in dbs)
            {
                if (!DataType.IsImgExt(db.FileExts))
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(type))
                {
                    int updateIdx = int.Parse(this.Request.QueryString["Idx"]);
                    if (type.Equals("UP"))
                    {
                        if (db.Idx == updateIdx)
                        {
                            db.Idx = updateIdx - 1;
                            db.Update();
                        }
                        else if (db.Idx == updateIdx - 1)
                        {
                            db.Idx = updateIdx;
                            db.Update();
                        }
                    }
                    else if (type.Equals("DOWN"))
                    {
                        if (db.Idx == updateIdx)
                        {
                            db.Idx = updateIdx + 1;
                            db.Update();
                        }
                        else if (db.Idx == updateIdx + 1)
                        {
                            db.Idx = updateIdx;
                            db.Update();
                        }
                    }
                }


                if (db.Idx != 0)
                {
                    isHave = true;
                }



                count++;
            }

            if (!string.IsNullOrEmpty(type))
            {
                dbs = LoadAttach(athDesc);
            }

            foreach (FrmAttachmentDB db in dbs)
            {
                if (!DataType.IsImgExt(db.FileExts))
                {
                    continue;
                }


                this.Pub1.AddTR();



                if (!athDesc.SaveTo.EndsWith("/"))
                {
                    athDesc.SaveTo += "/";
                }

                //s  image.ImageUrl = athDesc.SaveTo + this.WorkID + "/" + db.MyPK + "." + db.FileName;
                // this.Pub1.AddTD("style='width:80%;margin-left:5%;display:block;text-align:center;overflow:scroll' align='center' valign='middle'" ,image);
                this.Pub1.AddTDBegin();

                this.Pub1.Add("<div style='width:80%;margin:0 auto;'>");
                // image.Attributes["style"]="width:800px;heght:600px;";

                string url = athDesc.SaveTo + this.WorkID + "/" + db.MyPK + "." + db.FileName;
                //  url = "";
                this.Pub1.Add("<img src='" + url + "' border=0 />");
                this.Pub1.Add("</div>");
                this.Pub1.AddTDEnd();

                if (athDesc.IsOrder && count > 1)
                {
                    this.Pub1.AddTR();
                    idx++;

                    if (db.Idx == 0)
                    {
                        if (isHave)
                        {
                            db.Idx = count - idx + 1;
                            db.Update();
                        }
                        else
                        {
                            db.Idx = idx;
                            db.Update();
                        }
                        isRedirect = true;
                    }

                    this.Pub1.AddTDBegin();

                    this.Pub1.Add("<div style='width:80%;margin:0 auto;text-align:center;'>");


                    if (idx == count)
                    {
                        this.Pub1.Add(db.FileName + "&nbsp;&nbsp;<a href='FilesView.aspx?DoType=UP&Idx=" + idx + "&DelPKVal=" + db.MyPK + "&FK_FrmAttachment=" + this.FK_FrmAttachment + "&PKVal=" + this.PKVal + "&FK_Flow=" + this.FK_Flow + "&FK_Node=" + this.FK_Node + "&WorkID=" + this.WorkID + "&FK_FrmAttachmentExt=" + this.FK_FrmAttachmentExt + "&IsCC=" + this.IsCC + "&Ath=" + this.Ath + "'>上移</a>&nbsp;&nbsp;<a href='FilesView.aspx?DoType=ViewPic&DelPKVal=" + db.MyPK + "'  target='_balnk'>查看原图</a>");
                    }
                    else if (idx == 1)
                    {
                        this.Pub1.Add(db.FileName + "&nbsp;&nbsp;<a href='FilesView.aspx?DoType=DOWN&Idx=" + idx + "&DelPKVal=" + db.MyPK + "&FK_FrmAttachment=" + this.FK_FrmAttachment + "&PKVal=" + this.PKVal + "&FK_Flow=" + this.FK_Flow + "&FK_Node=" + this.FK_Node + "&WorkID=" + this.WorkID + "&FK_FrmAttachmentExt=" + this.FK_FrmAttachmentExt + "&IsCC=" + this.IsCC + "&Ath=" + this.Ath + "'>下移</a>&nbsp;&nbsp;<a href='FilesView.aspx?DoType=ViewPic&DelPKVal=" + db.MyPK + "'  target='_balnk'>查看原图</a>");
                    }
                    else
                    {
                        this.Pub1.Add(db.FileName + "&nbsp;&nbsp;<a href='FilesView.aspx?DoType=UP&Idx=" + idx + "&DelPKVal=" + db.MyPK + "&FK_FrmAttachment=" + this.FK_FrmAttachment + "&PKVal=" + this.PKVal + "&FK_Flow=" + this.FK_Flow + "&FK_Node=" + this.FK_Node + "&WorkID=" + this.WorkID + "&FK_FrmAttachmentExt=" + this.FK_FrmAttachmentExt + "&IsCC=" + this.IsCC + "&Ath=" + this.Ath + "'>上移</a>&nbsp;&nbsp;<a href='FilesView.aspx?DoType=DOWN&Idx=" + idx + "&DelPKVal=" + db.MyPK + "&FK_FrmAttachment=" + this.FK_FrmAttachment + "&PKVal=" + this.PKVal + "&FK_Flow=" + this.FK_Flow + "&FK_Node=" + this.FK_Node + "&WorkID=" + this.WorkID + "&FK_FrmAttachmentExt=" + this.FK_FrmAttachmentExt + "&IsCC=" + this.IsCC + "&Ath=" + this.Ath + "'>下移</a>&nbsp;&nbsp;<a href='FilesView.aspx?DoType=ViewPic&DelPKVal=" + db.MyPK + "'  target='_balnk'>查看原图</a>");
                    }
                    this.Pub1.Add("</div>");
                    this.Pub1.AddTDEnd();
                    this.Pub1.AddTREnd();
                }
                else
                {
                    this.Pub1.AddTR();

                    this.Pub1.Add("<div style='width:80%;margin:0 auto;text-align:center'>");
                    this.Pub1.AddTDBegin();
                    this.Pub1.Add(db.FileName);
                    this.Pub1.Add("</div>");
                    this.Pub1.AddTDEnd();
                    this.Pub1.AddTREnd();
                }

                this.Pub1.AddTREnd();
            }
            this.Pub1.AddTableEnd();


            if (isRedirect)
            {
                this.Response.Redirect(this.Request.RawUrl, true);
            }
        }
コード例 #22
0
        /// <summary>
        /// 加载一个tab chart
        /// </summary>
        /// <returns></returns>
        private string GetFirstTabColChartData()
        {
            sBuilder = new StringBuilder();

            string sql = "SELECT distinct EmpFrom,EmpFromT FROM ND" + int.Parse(flow.No) +
                         "Track WHERE NDFrom='" + node.NodeID + "'";

            DataTable dt = DBAccess.RunSQLReturnTable(sql);

            Paras ps;
            int   maxValue = 0;
            int   setCount = 0;

            if (dt.Rows.Count <= 4)//使用MSCOL图形 取最近一年的数据
            {
                DateTime dTime = DateTime.Now;

                List <string> listMouth = new List <string>();

                for (int i = -11; i <= 0; i++)
                {
                    listMouth.Add(dTime.AddMonths(i).ToString("yyyy-MM"));
                }

                sBuilder.Append("<categories>");
                foreach (string lm in listMouth)
                {
                    sBuilder.Append("<category label='" + lm + "' />");
                }
                sBuilder.Append("</categories>");


                foreach (DataRow dr in dt.Rows)
                {
                    sBuilder.Append("<dataset seriesName='" + dr["EmpFromT"] + "'>");

                    foreach (string lm in listMouth)
                    {
                        ps     = new BP.DA.Paras();
                        ps.SQL = "SELECT COUNT(distinct WorkID)  FROM  " + tkTable +
                                 " WHERE EmpFrom=" + dbstr + "EmpFrom AND NDFrom=" + dbstr +
                                 "NDFrom AND RDT LIKE'%" + lm + "%'";

                        ps.Add(BP.WF.TrackAttr.EmpFrom, dr["EmpFrom"].ToString());
                        ps.Add(BP.WF.TrackAttr.NDFrom, node.NodeID);

                        setCount = BP.DA.DBAccess.RunSQLReturnValInt(ps, 0);

                        if (setCount > maxValue)
                        {
                            maxValue = setCount;
                        }

                        sBuilder.Append("<set value='" + setCount + "' />");
                    }


                    sBuilder.Append("</dataset>");
                }

                sBuilder.Append("</chart>");

                maxValue += 10;
                sBuilder.Insert(0, "<chart baseFontSize='14'  subcaption='" + "节点:[" + node.NodeID + "]" + node.Name +
                                "-" + listMouth[0] + "至" + listMouth[11] + "统计" + "' formatNumberScale='0' divLineAlpha='20'" +
                                " divLineColor='CC3300' alternateHGridColor='CC3300' shadowAlpha='40'" +
                                " numvdivlines='9'  bgColor='FFFFFF,CC3300' bgAngle='270' bgAlpha='10,10'" +
                                " alternateHGridAlpha='5'   yAxisMaxValue ='" + maxValue + "'>");
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    ps     = new BP.DA.Paras();
                    ps.SQL = "SELECT COUNT(distinct WorkID)  FROM  " + tkTable +
                             " WHERE EmpFrom=" + dbstr + "EmpFrom AND NDFrom=" + dbstr + "NDFrom";
                    ps.Add(BP.WF.TrackAttr.EmpFrom, dr["EmpFrom"].ToString());
                    ps.Add(BP.WF.TrackAttr.NDFrom, node.NodeID);

                    setCount = BP.DA.DBAccess.RunSQLReturnValInt(ps, 0);
                    if (setCount > maxValue)
                    {
                        maxValue = setCount;
                    }

                    sBuilder.Append("<set label='" + dr["EmpFromT"] + "' value='" + setCount + "' />");
                }

                sBuilder.Append("</chart>");

                maxValue += 10;//加10  不置顶
                sBuilder.Insert(0, "<chart baseFontSize='12' subcaption='" + "节点:[" + node.NodeID + "]" + node.Name +
                                "-总数统计" + "' formatNumberScale='0' divLineAlpha='20'" +
                                " divLineColor='CC3300' alternateHGridColor='CC3300' shadowAlpha='40'" +
                                " numvdivlines='9'  bgColor='FFFFFF,CC3300' bgAngle='270' bgAlpha='10,10'" +
                                " alternateHGridAlpha='5'   yAxisMaxValue ='" + maxValue + "'>");
            }

            return("{rowsCount:\"" + dt.Rows.Count + "\",chartData:\"" + sBuilder.ToString() + "\"}");
        }
コード例 #23
0
        /// <summary>
        /// 加载第一个面板二维表
        /// </summary>
        /// <returns></returns>
        private string TabIndex_0()
        {
            this.sBuilder = new StringBuilder();

            string    sql = "";
            DataTable dt  = new DataTable();

            sql = "SELECT distinct EmpFrom,EmpFromT FROM ND" + int.Parse(flow.No) +
                  "Track WHERE NDFrom='" + node.NodeID + "'";

            dt = BP.DA.DBAccess.RunSQLReturnTable(sql);
            this.sBuilder.Append("<table id='tab_0' style=\"width: 100%; min-width: 800px;\">");

            this.sBuilder.Append("<tr>");
            this.sBuilder.Append("<th class=\"center\" rowspan=\"2\">");
            this.sBuilder.Append("序");
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\" rowspan=\"2\">");
            this.sBuilder.Append("人员");
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\" colspan=\"3\">");
            this.sBuilder.Append("工作分析");
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\" colspan=\"4\">");
            this.sBuilder.Append("按月份分析");
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\" colspan=\"4\">");
            this.sBuilder.Append("按周分析");
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("</tr>");
            this.sBuilder.Append("<tr>");
            this.sBuilder.Append("<th class=\"center\">");
            this.sBuilder.Append("工作总数");
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\">");
            this.sBuilder.Append("待处理");
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\">");
            this.sBuilder.Append("退回次数");
            this.sBuilder.Append("</th>");

            //改为上月与上上月之间的比较,周类似     周要求

            DateTime dTime = DateTime.Now;

            //上上月
            string beforeLastMouth = dTime.AddMonths(-2).ToString("yyyy-MM");
            string lastMouth       = dTime.AddMonths(-1).ToString("yyyy-MM");


            //上上周的开始,截止日期
            string beforeLastWeekFDay   = DataType.WeekOfMonday(DataType.WeekOfMonday(dTime).AddDays(-9)).ToString("yyyy-MM-dd");
            string beforeLastWeekEndDay = DataType.WeekOfMonday(DataType.WeekOfMonday(dTime).AddDays(-9)).AddDays(6).ToString("yyyy-MM-dd");

            //上周的开始,截止日期
            string lastWeekFDay   = DataType.WeekOfMonday(DataType.WeekOfMonday(dTime).AddDays(-3)).ToString("yyyy-MM-dd");
            string lastWeekEndDay = DataType.WeekOfMonday(DataType.WeekOfMonday(dTime).AddDays(-3)).AddDays(6).ToString("yyyy-MM-dd");

            this.sBuilder.Append("<th class=\"center\">");
            this.sBuilder.Append(beforeLastMouth);
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\">");
            this.sBuilder.Append(lastMouth);
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\">");
            this.sBuilder.Append("同比");
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\">");
            this.sBuilder.Append("同比增长");
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\">");
            this.sBuilder.Append("上上周</br>" + beforeLastWeekFDay + "</br>" + beforeLastWeekEndDay);
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\">");
            this.sBuilder.Append("上周</br>" + lastWeekFDay + "</br>" + lastWeekEndDay);
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\">");
            this.sBuilder.Append("同比");
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("<th class=\"center\">");
            this.sBuilder.Append("同比增长");
            this.sBuilder.Append("</th>");
            this.sBuilder.Append("</tr>");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                //处理总数
                BP.DA.Paras ps = new BP.DA.Paras();
                ps.SQL = "SELECT COUNT(distinct WorkID)  FROM  " + tkTable +
                         " WHERE EmpFrom=" + dbstr + "EmpFrom AND NDFrom=" + dbstr + "NDFrom";
                ps.Add(BP.WF.TrackAttr.EmpFrom, dt.Rows[i]["EmpFrom"].ToString());
                ps.Add(BP.WF.TrackAttr.NDFrom, node.NodeID);
                int sumCount = BP.DA.DBAccess.RunSQLReturnValInt(ps, 0);

                //待处理
                ps     = new BP.DA.Paras();
                ps.SQL = "SELECT COUNT(distinct WorkID)  FROM  WF_GenerWorkerlist WHERE FK_Emp=" + dbstr +
                         "FK_Emp AND FK_Node=" + dbstr + "FK_Node AND IsPass=0  ";
                ps.Add(BP.WF.GenerWorkerListAttr.FK_Emp, dt.Rows[i]["EmpFrom"].ToString());
                ps.Add(BP.WF.GenerWorkerListAttr.FK_Node, node.NodeID);
                int todoNum = BP.DA.DBAccess.RunSQLReturnValInt(ps, 0);


                //  退回数  count WorkID
                ps     = new BP.DA.Paras();
                ps.SQL = "SELECT COUNT(WorkID)  FROM  " + tkTable +
                         " WHERE EmpFrom=" + dbstr + "EmpFrom AND NDFrom=" + dbstr +
                         "NDFrom AND ActionType=" + dbstr + "ActionType";
                ps.Add(BP.WF.TrackAttr.EmpFrom, dt.Rows[i]["EmpFrom"].ToString());
                ps.Add(BP.WF.TrackAttr.NDFrom, node.NodeID);
                ps.Add(BP.WF.TrackAttr.ActionType, (int)BP.WF.ActionType.Return);
                int returnCount = BP.DA.DBAccess.RunSQLReturnValInt(ps, 0);

                this.sBuilder.Append("<tr>");
                this.sBuilder.Append("<td class=\"Idx\">");
                this.sBuilder.Append(i + 1);
                this.sBuilder.Append("</td>");
                this.sBuilder.Append("<td class=\"center\">");
                this.sBuilder.Append(dt.Rows[i]["EmpFromT"]);
                this.sBuilder.Append("</td>");
                this.sBuilder.Append("<td class=\"center\">");
                this.sBuilder.Append(sumCount);
                this.sBuilder.Append("</td>");
                this.sBuilder.Append("<td class=\"center\">");

                if (todoNum == 0)
                {
                    this.sBuilder.Append(todoNum);
                }
                else
                {
                    this.sBuilder.Append("<font style=\"color: Green;\"><b>" + todoNum + "</b></font>");
                }

                this.sBuilder.Append("</td>");
                this.sBuilder.Append("<td class=\"center\">");
                if (returnCount == 0)
                {
                    this.sBuilder.Append(returnCount);
                }
                else
                {
                    this.sBuilder.Append("<font style=\"color: Red;\"><b>" + returnCount + "</b></font>");
                }

                this.sBuilder.Append("</td>");


                //上上月
                this.sBuilder.Append("<td class=\"center\">");

                ps     = new BP.DA.Paras();
                ps.SQL = "SELECT COUNT(distinct WorkID)  FROM  " + tkTable +
                         " WHERE EmpFrom=" + dbstr + "EmpFrom AND NDFrom=" + dbstr +
                         "NDFrom AND RDT LIKE'%" + beforeLastMouth + "%'";
                ps.Add(BP.WF.TrackAttr.EmpFrom, dt.Rows[i]["EmpFrom"].ToString());
                ps.Add(BP.WF.TrackAttr.NDFrom, node.NodeID);

                int llastCount = BP.DA.DBAccess.RunSQLReturnValInt(ps, 0);

                //if (llastCount == 0)
                //    this.sBuilder.Append("<font style=\"color: Red;\"><b>" + llastCount + "</b></font>");
                //else
                this.sBuilder.Append(llastCount);

                this.sBuilder.Append("</td>");

                //上月
                this.sBuilder.Append("<td class=\"center\">");

                ps     = new BP.DA.Paras();
                ps.SQL = "SELECT COUNT(distinct WorkID)  FROM  " + tkTable +
                         " WHERE EmpFrom=" + dbstr + "EmpFrom AND NDFrom=" + dbstr +
                         "NDFrom AND RDT LIKE'%" + lastMouth + "%'";
                ps.Add(BP.WF.TrackAttr.EmpFrom, dt.Rows[i]["EmpFrom"].ToString());
                ps.Add(BP.WF.TrackAttr.NDFrom, node.NodeID);

                int lastCount = BP.DA.DBAccess.RunSQLReturnValInt(ps, 0);

                //if (lastCount == 0)
                //    this.sBuilder.Append("<font style=\"color: Red;\"><b>" + lastCount + "</b></font>");
                //else
                this.sBuilder.Append(lastCount);

                this.sBuilder.Append("</td>");

                //按月  同比 红字标示小于零的列
                this.sBuilder.Append("<td class=\"center\">");

                if (lastCount - llastCount <= 0)
                {
                    this.sBuilder.Append("<font style=\"color: Red;\"><b>" + (lastCount - llastCount) + "</b></font>");
                }
                else
                {
                    this.sBuilder.Append("<font style=\"color: Green;\"><b>" + (lastCount - llastCount) + "</b></font>");
                }

                this.sBuilder.Append("</td>");

                //按月百分比
                this.sBuilder.Append("<td class=\"center\">");

                double bl;          //比率

                if (lastCount == 0) //
                {
                    this.sBuilder.Append("-");
                }
                else
                {
                    //比率
                    bl = (lastCount - llastCount) * 100.0 / lastCount;

                    if (bl < 0)
                    {
                        this.sBuilder.Append("<font style=\"color: Red;\"><b>" + bl.ToString("0.00") + "%</b></font>");
                    }
                    if (bl > 0)
                    {
                        this.sBuilder.Append("<font style=\"color: Green;\"><b>" + bl.ToString("0.00") + "%</b></font>");
                    }

                    if (lastCount == llastCount)
                    {
                        this.sBuilder.Append("-");
                    }
                }
                this.sBuilder.Append("</td>");

                //上上周
                ps     = new BP.DA.Paras();
                ps.SQL = "SELECT COUNT(distinct WorkID)  FROM  " + tkTable +
                         " WHERE EmpFrom=" + dbstr + "EmpFrom AND NDFrom=" + dbstr +
                         "NDFrom AND RDT >='" + beforeLastWeekFDay + "' AND RDT<='" +
                         beforeLastWeekEndDay + "'";
                ps.Add(BP.WF.TrackAttr.EmpFrom, dt.Rows[i]["EmpFrom"].ToString());
                ps.Add(BP.WF.TrackAttr.NDFrom, node.NodeID);
                llastCount = BP.DA.DBAccess.RunSQLReturnValInt(ps, 0);

                this.sBuilder.Append("<td class=\"center\">");
                this.sBuilder.Append(llastCount);
                this.sBuilder.Append("</td>");

                //上周
                this.sBuilder.Append("<td class=\"center\">");
                ps     = new BP.DA.Paras();
                ps.SQL = "SELECT COUNT(distinct WorkID)  FROM  " + tkTable +
                         " WHERE EmpFrom=" + dbstr + "EmpFrom AND NDFrom=" + dbstr +
                         "NDFrom AND RDT >='" + lastWeekFDay + "' AND RDT<='" +
                         lastWeekEndDay + "'";
                ps.Add(BP.WF.TrackAttr.EmpFrom, dt.Rows[i]["EmpFrom"].ToString());
                ps.Add(BP.WF.TrackAttr.NDFrom, node.NodeID);

                lastCount = BP.DA.DBAccess.RunSQLReturnValInt(ps, 0);
                this.sBuilder.Append(lastCount);
                this.sBuilder.Append("</td>");

                //按周  同比 红字标示小于零的列
                this.sBuilder.Append("<td class=\"center\">");
                if (lastCount - llastCount <= 0)
                {
                    this.sBuilder.Append("<font style=\"color: Red;\"><b>" + (lastCount - llastCount) + "</b></font>");
                }
                else
                {
                    this.sBuilder.Append("<font style=\"color: Green;\"><b>" + (lastCount - llastCount) + "</b></font>");
                }

                this.sBuilder.Append("</td>");

                //按周百分比
                this.sBuilder.Append("<td class=\"center\">");

                if (lastCount == 0)//
                {
                    this.sBuilder.Append("-");
                }
                else
                {
                    bl = (lastCount - llastCount) * 100.0 / lastCount;

                    if (bl < 0)
                    {
                        this.sBuilder.Append("<font style=\"color: Red;\"><b>" + bl.ToString("0.00") + "%</b></font>");
                    }
                    if (bl > 0)
                    {
                        this.sBuilder.Append("<font style=\"color: Green;\"><b>" + bl.ToString("0.00") + "%</b></font>");
                    }
                    if (lastCount == llastCount)
                    {
                        this.sBuilder.Append("-");
                    }
                }
                this.sBuilder.Append("</td>");
                this.sBuilder.Append("</tr>");
            }//循环

            this.sBuilder.Append("<tr><td colspan='13' class='center td_chart'>工作总量统计图</td></tr>");
            this.sBuilder.Append("</table>");
            return(this.sBuilder.ToString());
        }
コード例 #24
0
        public DataTable BindDG()
        {
            //处理数据源是否正确.
            if (this.DDL_D1.Items.Count <= 1 || this.DDL_Num.Items.Count == 0)
            {
                this.Right.Clear();
                this.ToolBar1.Visible = false;
                this.Right.AddMsgGreen("提示:", "<h2>没有足够的纬度或者没有数据分析项目。</h2>");
                return(null);
            }

            //不能让两个维度选择一致.
            if (this.DDL_D1.SelectedItemStringVal == this.DDL_D2.SelectedItemStringVal)
            {
                if (this.DDL_D1.SelectedIndex == 0)
                {
                    this.DDL_D2.SelectedIndex = 1;
                }
                else
                {
                    this.DDL_D2.SelectedIndex = 0;
                }
            }

            Attrs    attrs = this.currEn.EnMap.Attrs;
            SysEnums sesD1 = null;
            Entities ensD1 = null;

            SysEnums sesD2 = null;
            Entities ensD2 = null;
            Map      map   = this.currEn.EnMap;

            #region 生成两个纬度报表
            Attr attrD1 = attrs.GetAttrByKey(this.DDL_D1.SelectedItemStringVal);
            if (attrD1.IsEnum)
            {
                sesD1 = new SysEnums(attrD1.UIBindKey);
            }
            else
            {
                ensD1 = attrD1.HisFKEns;
                if (ensD1.Count == 0)
                {
                    ensD1.RetrieveAll();
                }
            }

            Attr attrD2 = attrs.GetAttrByKey(this.DDL_D2.SelectedItemStringVal);
            if (attrD2.IsEnum)
            {
                sesD2 = new SysEnums(attrD2.UIBindKey);
            }
            else
            {
                ensD2 = attrD2.HisFKEns;
                if (ensD2.Count == 0)
                {
                    ensD2.RetrieveAll();
                }
            }
            #endregion


            #region 生成执行的原始sql
            string Condition = ""; //处理特殊字段的条件问题。
            Paras  myps      = new BP.DA.Paras();
            string sql       = "SELECT " + attrD1.Key + "," + attrD2.Key + ", " + this.DDL_FXWay.SelectedItemStringVal + "(" + this.DDL_Num.SelectedItemStringVal + ") FROM " + map.PhysicsTable;
            // 找到 WHERE 数据。
            string where = " WHERE ";
            string whereOfLJ = " WHERE "; // 累计的where.
            string url       = "";
            foreach (Control item in this.ToolBar1.Controls)
            {
                if (item.ID == null)
                {
                    continue;
                }
                if (item.ID.IndexOf("DDL_") == -1)
                {
                    continue;
                }
                if (item.ID.IndexOf("DDL_Form_") == 0 || item.ID.IndexOf("DDL_To_") == 0)
                {
                    continue;
                }

                string key = item.ID.Substring("DDL_".Length);
                DDL    ddl = (DDL)item;
                if (ddl.SelectedItemStringVal == "all")
                {
                    continue;
                }

                string val = ddl.SelectedItemStringVal;
                if (val == null)
                {
                    continue;
                }

                if (val == "mvals")
                {
                    UserRegedit sUr = new UserRegedit();
                    sUr.MyPK = WebUser.No + this.RptNo + "_SearchAttrs";
                    sUr.RetrieveFromDBSources();

                    /* 如果是多选值 */
                    string cfgVal = sUr.MVals;
                    AtPara ap     = new AtPara(cfgVal);
                    string instr  = ap.GetValStrByKey(key);
                    if (instr == null || instr == "")
                    {
                        if (key == "FK_Dept" || key == "FK_Unit")
                        {
                            if (key == "FK_Dept")
                            {
                                val = WebUser.FK_Dept;
                                ddl.SelectedIndex = 0;
                            }

                            if (key == "FK_Unit")
                            {
                                //  val = WebUser.FK_Unit;
                                ddl.SelectedIndex = 0;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        instr  = instr.Replace("..", ".");
                        instr  = instr.Replace(".", "','");
                        instr  = instr.Substring(2);
                        instr  = instr.Substring(0, instr.Length - 2);
                        where += " " + key + " IN (" + instr + ")  AND ";
                        continue;
                    }
                }

                if (key == "FK_Dept")
                {
                    if (val.Length == 8)
                    {
                        where += " FK_Dept =" + SystemConfig.AppCenterDBVarStr + "V_Dept    AND ";
                    }
                    else
                    {
                        switch (SystemConfig.AppCenterDBType)
                        {
                        case DBType.Oracle:
                        case DBType.Informix:
                            where += " FK_Dept LIKE '%'||:V_Dept||'%'   AND ";
                            break;

                        case DBType.MSSQL:
                        default:
                            where += " FK_Dept LIKE  " + SystemConfig.AppCenterDBVarStr + "V_Dept+'%'   AND ";
                            break;
                        }
                    }
                    myps.Add("V_Dept", val);
                }
                else
                {
                    where += " " + key + " =" + SystemConfig.AppCenterDBVarStr + key + "   AND ";
                    if (key != "FK_NY")
                    {
                        whereOfLJ += " " + key + " =" + SystemConfig.AppCenterDBVarStr + key + "   AND ";
                    }

                    myps.Add(key, val);
                }
            }
            #endregion

            #region 加上 where like 条件
            try
            {
                string key = this.ToolBar1.GetTBByID("TB_Key").Text.Trim();
                if (key.Length > 1)
                {
                    string whereLike = "";

                    bool isAddAnd = false;
                    foreach (Attr likeKey in attrs)
                    {
                        if (likeKey.IsNum)
                        {
                            continue;
                        }
                        if (likeKey.IsRefAttr)
                        {
                            continue;
                        }

                        switch (likeKey.Field)
                        {
                        case "MyFileExt":
                        case "MyFilePath":
                        case "WebPath":
                            continue;

                        default:
                            break;
                        }


                        if (isAddAnd == false)
                        {
                            isAddAnd   = true;
                            whereLike += "      " + likeKey.Field + " LIKE '%" + key + "%' ";
                        }
                        else
                        {
                            whereLike += "   AND   " + likeKey.Field + " LIKE '%" + key + "%'";
                        }
                    }
                    whereLike += "          ";
                    where     += whereLike;
                }
            }
            catch
            {
            }
            #endregion

            #region 加上日期时间段.
            if (map.DTSearchWay != DTSearchWay.None)
            {
                string dtFrom = this.ToolBar1.GetTBByID("TB_S_From").Text.Trim();
                string dtTo   = this.ToolBar1.GetTBByID("TB_S_To").Text.Trim();
                string field  = map.DTSearchKey;
                if (map.DTSearchWay == DTSearchWay.ByDate)
                {
                    where += "( " + field + ">='" + dtFrom + " 01:01' AND " + field + "<='" + dtTo + " 23:59')     ";
                }
                else
                {
                    where += "(";
                    where += field + " >='" + dtFrom + "' AND " + field + "<='" + dtTo + "'";
                    where += ")";
                }
            }
            if (where == " WHERE ")
            {
                where     = "" + Condition.Replace("and", "");
                whereOfLJ = "" + Condition.Replace("and", "");
            }
            else
            {
                where     = where.Substring(0, where.Length - " AND ".Length) + Condition;
                whereOfLJ = whereOfLJ.Substring(0, whereOfLJ.Length - " AND ".Length) + Condition;
            }
            #endregion

            sql     += where + " GROUP BY  " + attrD1.Key + "," + attrD2.Key;
            myps.SQL = sql;
            DataTable dt = DBAccess.RunSQLReturnTable(myps);

            string leftMsg = this.DDL_FXWay.SelectedItem.Text + ":" + this.DDL_Num.SelectedItem.Text;

            #region 生成表格 -  生成标题
            this.Right.AddTable("class='Table' cellspacing='0' cellpadding='0' border='0' style='width:100%'");
            this.Right.AddTR();
            this.Right.AddTDGroupTitle(leftMsg);
            if (sesD1 != null)
            {
                foreach (SysEnum se in sesD1)
                {
                    this.Right.AddTDGroupTitle(se.Lab);
                }
            }
            if (ensD1 != null)
            {
                if (ensD1.Count == 0)
                {
                    ensD1.RetrieveAll();
                }
                foreach (Entity en in ensD1)
                {
                    this.Right.AddTDGroupTitle(en.GetValStrByKey("Name"));
                }
            }
            this.Right.AddTREnd();
            #endregion .生成标题.

            #region 生成单元格
            if (sesD2 != null)
            {
                foreach (SysEnum se in sesD2)
                {
                    this.Right.AddTR();
                    this.Right.AddTDGroupTitle(se.Lab);

                    if (sesD1 != null)
                    {
                        foreach (SysEnum seD1 in sesD1)
                        {
                            this.Right.AddTD("onclick='' ", this.GetIt(dt, seD1.IntKey.ToString(), se.IntKey.ToString()));
                        }
                    }

                    if (ensD1 != null)
                    {
                        foreach (Entity enD1 in ensD1)
                        {
                            this.Right.AddTD(this.GetIt(dt, enD1.GetValStrByKey("No"), se.IntKey.ToString()));
                        }
                    }
                    this.Right.AddTREnd();
                }
            }

            if (ensD2 != null)
            {
                foreach (Entity en in ensD2)
                {
                    this.Right.AddTR();
                    this.Right.AddTDGroupTitle(en.GetValStrByKey("Name"));

                    if (sesD1 != null)
                    {
                        foreach (SysEnum seD1 in sesD1)
                        {
                            this.Right.AddTD(this.GetIt(dt, seD1.IntKey.ToString(), en.GetValStrByKey("No")));
                        }
                    }
                    if (ensD1 != null)
                    {
                        foreach (Entity enD1 in ensD1)
                        {
                            this.Right.AddTD(this.GetIt(dt, enD1.GetValStrByKey("No"), en.GetValStrByKey("No")));
                        }
                    }
                    this.Right.AddTREnd();
                }
            }
            this.Right.AddTableEnd();
            #endregion .生成单元格.

            #region 保存状态
            string paras = "";
            if (this.CB_IsImg.Checked)
            {
                paras = "@IsImg=1";
            }
            else
            {
                paras = "@IsImg=0";
            }

            if (this.CB_IsRate.Checked)
            {
                paras += "@IsRate=1";
            }
            else
            {
                paras += "@IsRate=0";
            }

            if (this.CB_IsNull.Checked)
            {
                paras += "@IsNull=1";
            }
            else
            {
                paras += "@IsNull=0";
            }

            paras += "@Num=" + this.DDL_Num.SelectedItemStringVal;
            paras += "@FXWay=" + this.DDL_FXWay.SelectedItemStringVal;
            paras += "@D1=" + this.DDL_D1.SelectedItemStringVal;
            paras += "@D1_Order=" + this.DDL_D1_Order.SelectedItemStringVal;
            paras += "@D2=" + this.DDL_D2.SelectedItemStringVal;
            paras += "@D2_Order=" + this.DDL_D2_Order.SelectedItemStringVal;
            paras += "@W=" + this.Left.GetTextBoxByID("TB_W").Text;
            paras += "@H=" + this.Left.GetTextBoxByID("TB_H").Text;

            ur.CfgKey = this.RptNo + "_D3";
            ur.MyPK   = WebUser.No + "_" + ur.CfgKey;
            ur.FK_Emp = WebUser.NoOfSessionID;
            ur.Paras  = paras;
            ur.Save();
            #endregion

            return(null);
        }
コード例 #25
0
        public string SaveDT(DataTable dt)
        {
            string igF = "@RowIndex@RowState@";

            if (dt.Rows.Count == 0)
            {
                return("");
            }

            string tableName = dt.TableName.Replace("CopyOf", "");

            if (tableName == "Sys_MapData")
            {
                int i = 0;
            }

            #region gener sql.
            //生成updataSQL.
            string updataSQL = "UPDATE " + tableName + " SET ";
            foreach (DataColumn dc in dt.Columns)
            {
                if (igF.Contains("@" + dc.ColumnName + "@"))
                {
                    continue;
                }

                switch (dc.ColumnName)
                {
                case "MyPK":
                case "OID":
                case "No":
                    continue;

                default:
                    break;
                }

                if (tableName == "Sys_MapAttr" && dc.ColumnName == "UIBindKey")
                {
                    continue;
                }

                try
                {
                    updataSQL += dc.ColumnName + "=" + BP.SystemConfig.AppCenterDBVarStr + dc.ColumnName + ",";
                }
                catch
                {
                }
            }
            updataSQL = updataSQL.Substring(0, updataSQL.Length - 1);
            string pk = "";
            if (dt.Columns.Contains("MyPK"))
            {
                pk = "MyPK";
            }
            if (dt.Columns.Contains("OID"))
            {
                pk = "OID";
            }
            if (dt.Columns.Contains("No"))
            {
                pk = "No";
            }

            updataSQL += " WHERE " + pk + "=" + BP.SystemConfig.AppCenterDBVarStr + pk;

            //生成INSERT SQL.
            string insertSQL = "INSERT INTO " + tableName + " ( ";
            foreach (DataColumn dc in dt.Columns)
            {
                if (igF.Contains("@" + dc.ColumnName + "@"))
                {
                    continue;
                }

                if (tableName == "Sys_MapAttr" && dc.ColumnName == "UIBindKey")
                {
                    continue;
                }

                insertSQL += dc.ColumnName + ",";
            }
            insertSQL  = insertSQL.Substring(0, insertSQL.Length - 1);
            insertSQL += ") VALUES (";
            foreach (DataColumn dc in dt.Columns)
            {
                if (igF.Contains("@" + dc.ColumnName + "@"))
                {
                    continue;
                }

                if (tableName == "Sys_MapAttr" && dc.ColumnName == "UIBindKey")
                {
                    continue;
                }

                insertSQL += BP.SystemConfig.AppCenterDBVarStr + dc.ColumnName + ",";
            }
            insertSQL  = insertSQL.Substring(0, insertSQL.Length - 1);
            insertSQL += ")";
            #endregion gener sql.

            #region save to data.
            foreach (DataRow dr in dt.Rows)
            {
                BP.DA.Paras ps = new BP.DA.Paras();
                foreach (DataColumn dc in dt.Columns)
                {
                    if (dc.ColumnName == pk)
                    {
                        continue;
                    }

                    if (tableName == "Sys_MapAttr" && dc.ColumnName == "UIBindKey")
                    {
                        continue;
                    }

                    if (updataSQL.Contains(BP.SystemConfig.AppCenterDBVarStr + dc.ColumnName))
                    {
                        ps.Add(dc.ColumnName, dr[dc.ColumnName]);
                    }
                }

                ps.Add(pk, dr[pk]);
                ps.SQL = updataSQL;
                try
                {
                    if (BP.DA.DBAccess.RunSQL(ps) == 0)
                    {
                        ps.Clear();
                        foreach (DataColumn dc in dt.Columns)
                        {
                            if (tableName == "Sys_MapAttr" && dc.ColumnName == "UIBindKey")
                            {
                                continue;
                            }

                            if (updataSQL.Contains(BP.SystemConfig.AppCenterDBVarStr + dc.ColumnName))
                            {
                                ps.Add(dc.ColumnName, dr[dc.ColumnName]);
                            }
                        }
                        ps.SQL = insertSQL;
                        BP.DA.DBAccess.RunSQL(ps);
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    string pastrs = "";
                    foreach (Para p in ps)
                    {
                        pastrs += "\t\n@" + p.ParaName + "=" + p.val;
                    }
                    throw new Exception("@执行sql=" + ps.SQL + "失败." + ex.Message + "\t\n@paras=" + pastrs);
                }
            }
            #endregion save to data.
            return(null);
        }
コード例 #26
0
ファイル: EnDa.cs プロジェクト: zhaoyingju/ccflow
        public static int Retrieve(Entities ens, string sql, Paras paras, string[] fullAttrs)
        {
            DataTable dt = null;

            switch (ens.GetNewEntity.EnMap.EnDBUrl.DBUrlType)
            {
            case DBUrlType.AppCenterDSN:
                dt = DBAccess.RunSQLReturnTable(sql, paras);
                break;

            case DBUrlType.DBAccessOfMSMSSQL:
                dt = DBAccessOfMSMSSQL.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOracle:
                dt = DBAccessOfOracle.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOLE:
                dt = DBAccessOfOLE.RunSQLReturnTable(sql);
                break;

            default:
                throw new Exception("@没有设置DB类型。");
            }

            if (dt.Rows.Count == 0)
            {
                return(0);
            }

            if (fullAttrs == null)
            {
                Map   enMap = ens.GetNewEntity.EnMap;
                Attrs attrs = enMap.Attrs;
                try
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        Entity en = ens.GetNewEntity;
                        foreach (Attr attr in attrs)
                        {
                            en.Row.SetValByKey(attr.Key, dr[attr.Key]);
                        }
                        ens.AddEntity(en);
                    }
                }
                catch (Exception ex)
                {
                    #warning  应该出现的错误. 2011-12-03 add
                    string cols = "";
                    foreach (DataColumn dc in dt.Columns)
                    {
                        cols += " , " + dc.ColumnName;
                    }
                    throw new Exception("Columns=" + cols + "@Ens=" + ens.ToString() + "@SQL=" + sql + ". @异常信息:" + ex.Message);
                }
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    Entity en = ens.GetNewEntity;
                    foreach (string str in fullAttrs)
                    {
                        en.Row.SetValByKey(str, dr[str]);
                    }
                    ens.AddEntity(en);
                }
            }
            int i = dt.Rows.Count;
            dt.Dispose();
            return(i);
            //return dt.Rows.Count;
        }