Beispiel #1
0
        /// <summary>
        /// 初始化Home
        /// </summary>
        /// <returns></returns>
        public string Home_Init()
        {
            Hashtable ht = new Hashtable();

            ht.Add("UserNo", BP.Web.WebUser.No);
            ht.Add("UserName", BP.Web.WebUser.Name);

            //系统名称.
            ht.Add("SysName", BP.Sys.SystemConfig.SysName);
            ht.Add("CustomerName", BP.Sys.SystemConfig.CustomerName);

            ht.Add("Todolist_EmpWorks", BP.WF.Dev2Interface.Todolist_EmpWorks);
            ht.Add("Todolist_Runing", BP.WF.Dev2Interface.Todolist_Runing);
            ht.Add("Todolist_Sharing", BP.WF.Dev2Interface.Todolist_Sharing);
            ht.Add("Todolist_CCWorks", BP.WF.Dev2Interface.Todolist_CCWorks);
            ht.Add("Todolist_Apply", BP.WF.Dev2Interface.Todolist_Apply);       //申请下来的任务个数.
            ht.Add("Todolist_Draft", BP.WF.Dev2Interface.Todolist_Draft);       //草稿数量.
            ht.Add("Todolist_Complete", BP.WF.Dev2Interface.Todolist_Complete); //完成数量.
            ht.Add("UserDeptName", WebUser.FK_DeptName);

            //我发起
            MyStartFlows myStartFlows = new MyStartFlows();
            QueryObject  obj          = new QueryObject(myStartFlows);

            obj.AddWhere(MyStartFlowAttr.Starter, WebUser.No);
            obj.addAnd();
            //运行中\已完成\挂起\退回\转发\加签\批处理\
            obj.addLeftBracket();
            obj.AddWhere("WFState=2 or WFState=3 or WFState=4 or WFState=5 or WFState=6 or WFState=8 or WFState=10");
            obj.addRightBracket();
            obj.DoQuery();
            ht.Add("Todolist_MyStartFlow", myStartFlows.Count);

            //我参与
            MyJoinFlows myFlows = new MyJoinFlows();

            obj = new QueryObject(myFlows);
            obj.AddWhere("Emps like '%" + WebUser.No + "%'");
            obj.DoQuery();
            ht.Add("Todolist_MyFlow", myFlows.Count);

            return(BP.Tools.Json.ToJsonEntityModel(ht));
        }
Beispiel #2
0
        /// <summary>
        /// 查询工作(不适合审核节点查询)
        /// </summary>
        /// <param name="empId">工作人员</param>
        /// <param name="nodeStat">节点状态</param>
        /// <param name="fromdate">记录日期从</param>
        /// <param name="todate">记录日期到</param>
        /// <returns></returns>
        public int Retrieve(string key, string empId, string fromdate, string todate)
        {
            QueryObject qo = new QueryObject(this);

            qo.AddWhere(WorkAttr.Rec, empId);

            qo.addAnd();
            qo.AddWhere(WorkAttr.RDT, ">=", fromdate);
            qo.addAnd();
            qo.AddWhere(WorkAttr.RDT, "<=", todate);

            if (key.Trim().Length == 0)
            {
                return(qo.DoQuery());
            }
            else
            {
                if (key.IndexOf("%") == -1)
                {
                    key = "%" + key + "%";
                }
                Entity en = this.GetNewEntity;
                qo.addAnd();
                qo.addLeftBracket();
                qo.AddWhere(en.PK, " LIKE ", key);
                foreach (Attr attr in en.EnMap.Attrs)
                {
                    if (attr.MyFieldType == FieldType.RefText)
                    {
                        continue;
                    }
                    if (attr.UIContralType == UIContralType.DDL || attr.UIContralType == UIContralType.CheckBok)
                    {
                        continue;
                    }
                    qo.addOr();
                    qo.AddWhere(attr.Key, " LIKE ", key);
                }
                qo.addRightBracket();
                return(qo.DoQuery());
            }
        }
        /// <summary>
        /// 构造工作人员集合
        /// </summary>
        /// <param name="workId">工作ID</param>
        /// <param name="nodeId">节点ID</param>
        /// <param name="isWithEmpExts">是否包含为分配的人员</param>
        public GenerWorkerLists(Int64 workId, int nodeId, bool isWithEmpExts)
        {
            QueryObject qo = new QueryObject(this);

            qo.addLeftBracket();
            qo.AddWhere(GenerWorkerListAttr.WorkID, workId);
            qo.addOr();
            qo.AddWhere(GenerWorkerListAttr.FID, workId);
            qo.addRightBracket();
            qo.addAnd();
            qo.AddWhere(GenerWorkerListAttr.FK_Node, nodeId);
            int i = qo.DoQuery();

            if (isWithEmpExts == false)
            {
                return;
            }

            if (i == 0)
            {
                throw new Exception("@系统错误,工作人员丢失请与管理员联系。NodeID=" + nodeId + " WorkID=" + workId);
            }

            RememberMe rm = new RememberMe();

            rm.FK_Emp  = BP.Web.WebUser.No;
            rm.FK_Node = nodeId;
            if (rm.RetrieveFromDBSources() == 0)
            {
                return;
            }

            GenerWorkerList wl = (GenerWorkerList)this[0];

            string[] emps = rm.Emps.Split('@');
            foreach (string emp in emps)
            {
                if (emp == null || emp == "")
                {
                    continue;
                }

                if (this.GetCountByKey(GenerWorkerListAttr.FK_Emp, emp) >= 1)
                {
                    continue;
                }

                GenerWorkerList mywl = new GenerWorkerList();
                mywl.Copy(wl);
                mywl.IsEnable = false;
                mywl.FK_Emp   = emp;
                WF.Port.WFEmp myEmp = new Port.WFEmp(emp);
                mywl.FK_EmpText = myEmp.Name;
                try
                {
                    mywl.Insert();
                }
                catch
                {
                    mywl.Update();
                    continue;
                }
                this.AddEntity(mywl);
            }
            return;
        }
        public QueryObject InitQueryObjectByEns(Entities ens, bool IsShowSearchKey, DTSearchWay dw, string dtKey, Attrs attrs, AttrsOfSearch attrsOfSearch, AttrSearchs searchAttrs)
        {
            QueryObject qo = new QueryObject(ens);

            #region 关键字
            string keyVal = "";
            //Attrs attrs = en.EnMap.Attrs;
            if (IsShowSearchKey)
            {
                TB keyTB = this.GetTBByID("TB_Key");
                if (keyTB != null)
                {
                    keyVal = keyTB.Text.Trim();
                }
                else
                {
                    UserRegedit ur = new UserRegedit();
                    //ur.MyPK = WebUser.No + ens.GetNewEntity.ClassID + "_SearchAttrs";
                    QueryObject urObj = new QueryObject(ur);
                    urObj.AddWhere("MyPK", WebUser.No + ens.GetNewEntity.ClassID + "_SearchAttrs");
                    urObj.DoQuery();

                    keyVal = ur.SearchKey;
                }
                this.Page.Session["SKey"] = keyVal;
            }

            if (keyVal.Length >= 1)
            {
                Attr attrPK = new Attr();
                foreach (Attr attr in attrs)
                {
                    if (attr.IsPK)
                    {
                        attrPK = attr;
                        break;
                    }
                }
                int i = 0;
                foreach (Attr attr in attrs)
                {
                    switch (attr.MyFieldType)
                    {
                    case FieldType.Enum:
                    case FieldType.FK:
                    case FieldType.PKFK:
                        continue;

                    default:
                        break;
                    }


                    if (attr.MyDataType != DataType.AppString)
                    {
                        continue;
                    }

                    if (attr.MyFieldType == FieldType.RefText)
                    {
                        continue;
                    }

                    if (attr.Key == "FK_Dept")
                    {
                        continue;
                    }

                    i++;
                    if (i == 1)
                    {
                        /* 第一次进来。 */
                        qo.addLeftBracket();
                        switch (SystemConfig.AppCenterDBType)
                        {
                        case BP.DA.DBType.Oracle:
                        case BP.DA.DBType.Informix:
                            qo.AddWhere(attr.Key, " LIKE ", " '%'||" + SystemConfig.AppCenterDBVarStr + "SKey||'%'");
                            break;

                        case BP.DA.DBType.MySQL:
                            qo.AddWhere(attr.Key, " LIKE ", "CONCAT('%'," + SystemConfig.AppCenterDBVarStr + "SKey,'%')");
                            break;

                        default:
                            qo.AddWhere(attr.Key, " LIKE ", " '%'+" + SystemConfig.AppCenterDBVarStr + "SKey+'%'");
                            break;
                        }
                        continue;
                    }
                    qo.addOr();

                    switch (SystemConfig.AppCenterDBType)
                    {
                    case BP.DA.DBType.Oracle:
                    case BP.DA.DBType.Informix:
                        qo.AddWhere(attr.Key, " LIKE ", "'%'||" + SystemConfig.AppCenterDBVarStr + "SKey||'%'");
                        break;

                    case BP.DA.DBType.MySQL:
                        qo.AddWhere(attr.Key, " LIKE ", "CONCAT('%'," + SystemConfig.AppCenterDBVarStr + "SKey,'%')");
                        break;

                    default:
                        qo.AddWhere(attr.Key, " LIKE ", "'%'+" + SystemConfig.AppCenterDBVarStr + "SKey+'%'");
                        break;
                    }
                }
                qo.MyParas.Add("SKey", keyVal);
                qo.addRightBracket();
            }
            else
            {
                qo.addLeftBracket();
                qo.AddWhere("abc", "all");
                qo.addRightBracket();
            }
            #endregion

            #region 普通属性
            string opkey = ""; // 操作符号。
            foreach (AttrOfSearch attr in attrsOfSearch)
            {
                if (attr.IsHidden)
                {
                    qo.addAnd();
                    qo.addLeftBracket();
                    qo.AddWhere(attr.RefAttrKey, attr.DefaultSymbol, attr.DefaultValRun);
                    qo.addRightBracket();
                    continue;
                }

                if (attr.SymbolEnable == true)
                {
                    opkey = this.GetDDLByKey("DDL_" + attr.Key).SelectedItemStringVal;
                    if (opkey == "all")
                    {
                        continue;
                    }
                }
                else
                {
                    opkey = attr.DefaultSymbol;
                }

                qo.addAnd();
                qo.addLeftBracket();

                if (attr.DefaultVal.Length >= 8)
                {
                    string date = "2005-09-01";
                    try
                    {
                        /* 就可能是年月日。 */
                        string y = this.GetDDLByKey("DDL_" + attr.Key + "_Year").SelectedItemStringVal;
                        string m = this.GetDDLByKey("DDL_" + attr.Key + "_Month").SelectedItemStringVal;
                        string d = this.GetDDLByKey("DDL_" + attr.Key + "_Day").SelectedItemStringVal;
                        date = y + "-" + m + "-" + d;

                        if (opkey == "<=")
                        {
                            DateTime dt = DataType.ParseSysDate2DateTime(date).AddDays(1);
                            date = dt.ToString(DataType.SysDataFormat);
                        }
                    }
                    catch
                    {
                    }

                    qo.AddWhere(attr.RefAttrKey, opkey, date);
                }
                else
                {
                    qo.AddWhere(attr.RefAttrKey, opkey, this.GetTBByID("TB_" + attr.Key).Text);
                }
                qo.addRightBracket();
            }
            #endregion

            #region 外键
            foreach (AttrSearch attr1 in searchAttrs)
            {
                Attr attr = attr1.HisAttr;

                if (attr.MyFieldType == FieldType.RefText)
                {
                    continue;
                }


                DDL ddl = this.GetDDLByKey("DDL_" + attr.Key);
                if (ddl.Items.Count == 0)
                {
                    continue;
                }

                string selectVal = ddl.SelectedItemStringVal;
                if (selectVal == "all")
                {
                    continue;
                }

                if (selectVal == "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(attr.Key);
                    if (instr == null || instr == "")
                    {
                        if (attr.Key == "FK_Dept" || attr.Key == "FK_Unit")
                        {
                            if (attr.Key == "FK_Dept")
                            {
                                selectVal         = WebUser.FK_Dept;
                                ddl.SelectedIndex = 0;
                            }

                            //if (attr.Key == "FK_Unit")
                            //{
                            //    selectVal = 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);

                        qo.addAnd();
                        qo.addLeftBracket();
                        qo.AddWhereIn(attr.Key, "(" + instr + ")");
                        qo.addRightBracket();
                        continue;
                    }
                }


                qo.addAnd();
                qo.addLeftBracket();

                if (attr.UIBindKey == "BP.Port.Depts" || attr.UIBindKey == "BP.Port.Units")  //判断特殊情况。
                {
                    qo.AddWhere(attr.Key, " LIKE ", selectVal + "%");
                }
                else
                {
                    qo.AddWhere(attr.Key, selectVal);
                }

                //qo.AddWhere(attr.Key,this.GetDDLByKey("DDL_"+attr.Key).SelectedItemStringVal ) ;
                qo.addRightBracket();
            }
            #endregion .

            if (dw != DTSearchWay.None)
            {
                string dtFrom = this.GetTBByID("TB_S_From").Text.Trim();
                string dtTo   = this.GetTBByID("TB_S_To").Text.Trim();
                if (dw == DTSearchWay.ByDate)
                {
                    qo.addAnd();
                    qo.addLeftBracket();
                    qo.SQL = dtKey + " >= '" + dtFrom + " 01:01'";
                    qo.addAnd();
                    qo.SQL = dtKey + " <= '" + dtTo + " 23:59'";
                    qo.addRightBracket();

                    //qo.AddWhere(dtKey, ">=", dtFrom+" 01:01");
                    //qo.addAnd();
                    //qo.AddWhere(dtKey, "<=", dtTo + " 23:59");
                    //qo.addRightBracket();
                }

                if (dw == DTSearchWay.ByDateTime)
                {
                    qo.addAnd();
                    qo.addLeftBracket();
                    qo.SQL = dtKey + " >= '" + dtFrom + "'";
                    qo.addAnd();
                    qo.SQL = dtKey + " <= '" + dtTo + "'";
                    qo.addRightBracket();

                    //qo.addAnd();
                    //qo.addLeftBracket();
                    //qo.AddWhere(dtKey, ">=", dtFrom);
                    //qo.addAnd();
                    //qo.AddWhere(dtKey, "<=", dtTo);
                    //qo.addRightBracket();
                }
            }

            //  throw new Exception(qo.SQL);
            return(qo);
        }
Beispiel #5
0
        public void BindData()
        {
            string ensname = this.Request.QueryString["EnsName"];

            if (ensname == null)
            {
                ensname = this.Request.QueryString["EnsName"];
            }

            Entities ens = BP.DA.ClassFactory.GetEns(ensname);
            Entity   en  = ens.GetNewEntity;

            this.FK_Flow = ensname;
            this.FK_Flow = FK_Flow.Replace("Rpt", "");
            this.FK_Flow = FK_Flow.Replace("ND", "");
            this.FK_Flow = this.FK_Flow.PadLeft(3, '0');

            QueryObject qo = new QueryObject(ens);

            string[] strs  = this.Request.RawUrl.Split('&');
            string[] strs1 = this.Request.RawUrl.Split('&');
            int      i     = 0;

            foreach (string str in strs)
            {
                if (str.IndexOf("EnsName") != -1)
                {
                    continue;
                }

                string[] mykey = str.Split('=');
                string   key   = mykey[0];

                if (key == "OID" || key == "MyPK")
                {
                    continue;
                }

                if (key == "FK_Dept")
                {
                    this.FK_Dept = mykey[1];
                    continue;
                }

                if (en.EnMap.Attrs.Contains(key) == false)
                {
                    continue;
                }

                qo.AddWhere(mykey[0], mykey[1]);
                qo.addAnd();
            }


            if (this.FK_Dept != null && (this.Request.QueryString["FK_Emp"] == null ||
                                         this.Request.QueryString["FK_Emp"] == "all"))
            {
                if (this.FK_Dept.Length == 2)
                {
                    qo.AddWhere("FK_Dept", " = ", "all");
                    qo.addAnd();
                }
                else
                {
                    if (this.FK_Dept.Length == 8)
                    {
                        //if (this.Request.QueryString["ByLike"] != "1")
                        qo.AddWhere("FK_Dept", " = ", this.FK_Dept);
                    }
                    else
                    {
                        qo.AddWhere("FK_Dept", " like ", this.FK_Dept + "%");
                    }

                    qo.addAnd();
                }
            }
            qo.AddHD();

            #region 加上日期时间段.
            if (en.EnMap.DTSearchWay != DTSearchWay.None)
            {
                string field = en.EnMap.DTSearchKey;
                qo.addAnd();
                qo.addLeftBracket();
                if (en.EnMap.DTSearchWay == DTSearchWay.ByDate)
                {
                    qo.AddWhere(field, " >= ", this.DTFrom + " 01:01");
                    qo.addAnd();
                    qo.AddWhere(field, " >= ", this.DTTo + " 23:59");
                }
                else
                {
                    qo.AddWhere(field, " >= ", this.DTFrom);
                    qo.addAnd();
                    qo.AddWhere(field, " >= ", this.DTTo);
                }
                qo.addRightBracket();
            }
            #endregion


            int num = qo.DoQuery();
            this.DataPanelDtl(ens, null);
        }
Beispiel #6
0
    /// <summary>
    /// Entities 的基本应用.
    /// </summary>
    public void EntitiesBaseApp()
    {
        #region 查询全部
        /* 查询全部分为两种方式,1 从缓存里查询全部。2,从数据库查询全部。  */
        Emps emps = new Emps();
        int  num  = emps.RetrieveAll(); //从缓存里查询全部数据.

        this.Response.Write("RetrieveAll查询出来(" + num + ")个");
        foreach (Emp emp in emps)
        {
            this.Response.Write("<hr>人员名称:" + emp.Name);
            this.Response.Write("<br>人员编号:" + emp.No);
            this.Response.Write("<br>部门编号:" + emp.FK_Dept);
            this.Response.Write("<br>部门名称:" + emp.FK_DeptText);
        }

        //把entities 数据转入到DataTable里。
        DataTable empsDTfield = emps.ToDataTableField(); //以英文字段做为列名。
        DataTable empsDTDesc  = emps.ToDataTableDesc();  //以中文字段做为列名。

        // 从数据库里查询全部。
        emps = new Emps();
        num  = emps.RetrieveAllFromDBSource();
        this.Response.Write("RetrieveAllFromDBSource查询出来(" + num + ")个");
        foreach (Emp emp in emps)
        {
            this.Response.Write("<hr>人员名称:" + emp.Name);
            this.Response.Write("<br>人员编号:" + emp.No);
            this.Response.Write("<br>部门编号:" + emp.FK_Dept);
            this.Response.Write("<br>部门名称:" + emp.FK_DeptText);
        }
        #endregion 查询全部

        #region  条件查询
        // 单个条件查询。
        Emps        myEmps = new Emps();
        QueryObject qo     = new QueryObject(myEmps);
        qo.AddWhere(EmpAttr.FK_Dept, "01");
        qo.addOrderBy(EmpAttr.No); // 增加排序规则,Order  OrderByDesc, addOrderByDesc addOrderByRandom.
        num = qo.DoQuery();        // 返回查询的个数.
        this.Response.Write("查询出来(" + num + ")个,部门编号=01的人员。");
        foreach (Emp emp in myEmps)
        {
            this.Response.Write("<hr>人员名称:" + emp.Name);
            this.Response.Write("<br>人员编号:" + emp.No);
            this.Response.Write("<br>部门编号:" + emp.FK_Dept);
            this.Response.Write("<br>部门名称:" + emp.FK_DeptText);
        }

        //   DataTable mydt = qo.DoQueryToTable();  // 查询出来的数据转入到datatable里。.

        Emps myEmp1s = new Emps();
        myEmp1s.Retrieve(EmpAttr.FK_Dept, "01");
        foreach (Emp item in myEmp1s)
        {
            this.Response.Write("<hr>人员名称:" + item.Name);
            this.Response.Write("<br>人员编号:" + item.No);
            this.Response.Write("<br>部门编号:" + item.FK_Dept);
            this.Response.Write("<br>部门名称:" + item.FK_DeptText);
        }

        // 多个条件查询。
        myEmps = new Emps();
        qo     = new QueryObject(myEmps);
        qo.AddWhere(EmpAttr.FK_Dept, "01");
        qo.addAnd();
        qo.AddWhere(EmpAttr.No, "guobaogen");
        num = qo.DoQuery();  // 返回查询的个数.
        this.Response.Write("查询出来(" + num + ")个,部门编号=01并且编号=guobaogen的人员。");
        foreach (Emp emp in myEmps)
        {
            this.Response.Write("<hr>人员名称:" + emp.Name);
            this.Response.Write("<br>人员编号:" + emp.No);
            this.Response.Write("<br>部门编号:" + emp.FK_Dept);
            this.Response.Write("<br>部门名称:" + emp.FK_DeptText);
        }
        // 具有括号表达式的查询。
        myEmps = new Emps();
        qo     = new QueryObject(myEmps);
        qo.addLeftBracket(); // 加上左括号.
        qo.AddWhere(EmpAttr.FK_Dept, "01");
        qo.addAnd();
        qo.AddWhere(EmpAttr.No, "guobaogen");
        qo.addRightBracket(); // 加上右括号.
        num = qo.DoQuery();   // 返回查询的个数.
        this.Response.Write("查询出来(" + num + ")个,部门编号=01并且编号=guobaogen的人员。");
        foreach (Emp emp in myEmps)
        {
            this.Response.Write("<hr>人员名称:" + emp.Name);
            this.Response.Write("<br>人员编号:" + emp.No);
            this.Response.Write("<br>部门编号:" + emp.FK_Dept);
            this.Response.Write("<br>部门名称:" + emp.FK_DeptText);
        }
        // 具有where in 方式的查询。
        myEmps = new Emps();
        qo     = new QueryObject(myEmps);
        qo.AddWhereInSQL(EmpAttr.No, "SELECT No FROM Port_Emp WHERE FK_Dept='02'");
        num = qo.DoQuery();  // 返回查询的个数.
        this.Response.Write("查询出来(" + num + ")个,WHERE IN (SELECT No FROM Port_Emp WHERE FK_Dept='02')人员。");
        foreach (Emp emp in myEmps)
        {
            this.Response.Write("<hr>人员名称:" + emp.Name);
            this.Response.Write("<br>人员编号:" + emp.No);
            this.Response.Write("<br>部门编号:" + emp.FK_Dept);
            this.Response.Write("<br>部门名称:" + emp.FK_DeptText);
        }

        // 具有LIKE 方式的查询。
        myEmps = new Emps();
        qo     = new QueryObject(myEmps);
        qo.AddWhere(EmpAttr.No, " LIKE ", "guo");
        num = qo.DoQuery();  // 返回查询的个数.
        this.Response.Write("查询出来(" + num + ")个,人员编号包含guo的人员。");
        foreach (Emp emp in myEmps)
        {
            this.Response.Write("<hr>人员名称:" + emp.Name);
            this.Response.Write("<br>人员编号:" + emp.No);
            this.Response.Write("<br>部门编号:" + emp.FK_Dept);
            this.Response.Write("<br>部门名称:" + emp.FK_DeptText);
        }
        #endregion  条件查询

        #region 集合业务处理.
        myEmps = new Emps();
        myEmps.RetrieveAll(); // 查询全部出来.
        // 遍历集合是常用的处理方法。
        foreach (Emp emp in myEmps)
        {
            this.Response.Write("<hr>人员名称:" + emp.Name);
            this.Response.Write("<br>人员编号:" + emp.No);
            this.Response.Write("<br>部门编号:" + emp.FK_Dept);
            this.Response.Write("<br>部门名称:" + emp.FK_DeptText);
        }
        // 判断是否包含是指定的主键值.
        bool isHave  = myEmps.Contains("Name", "郭宝庚"); //判断是否集合里面包含Name=郭宝庚的实体.
        bool isHave1 = myEmps.Contains("guobaogeng");  //判断是否集合里面主键No=guobaogeng的实体.

        // 获取Name=郭宝庚的实体,如果没有就返回空。
        Emp empFind = myEmps.GetEntityByKey("Name", "郭宝庚") as Emp;
        if (empFind == null)
        {
            this.Response.Write("<br>没有找到: Name =郭宝庚 的实体.");
        }
        else
        {
            this.Response.Write("<br>已经找到了: Name =郭宝庚 的实体. 他的部门编号=" + empFind.FK_Dept + ",部门名称=" + empFind.FK_DeptText);
        }
        // 批量更新实体。
        myEmps.Update(); // 等同于下一个循环。
        foreach (Emp emp in myEmps)
        {
            emp.Update();
        }
        // 删除实体.
        myEmps.Delete(); // 等同于下一个循环。
        foreach (Emp emp in myEmps)
        {
            emp.Delete();
        }
        // 执行数据库删除,类于执行 DELETE Port_Emp WHERE FK_Dept='01' 的sql.
        myEmps.Delete("FK_Dept", "01");
        #endregion
    }
        public void BindBill()
        {
            Flow   fl1 = new Flow(this.FK_Flow);
            string ens = "BP.WF.Bills";

            this.Pub1.AddTable("width='100%'");
            this.Pub1.AddCaption("您的位置:单据查询 <a href='FlowSearch.aspx' >返回</a> => " + fl1.Name);
            this.Pub1.AddTR();
            this.Pub1.Add("<TD  class=TD  height=800px  width=100% >");
            string src = "" + BP.WF.Glo.CCFlowAppPath + "WF/Comm/Search.aspx?EnsName=BP.WF.Bills&FK_Flow=" + this.FK_Flow;

            this.Pub1.Add("<iframe ID='f23' frameborder=0  style='padding:0px;border:0px;'  leftMargin='0'  topMargin='0' src='" + src + "' height='100%' width='100%' scrolling=no  /></iframe>");
            this.Pub1.AddTDEnd();
            this.Pub1.AddTREnd();
            this.Pub1.AddTableEnd();
            return;



            Bills       bills = new Bills();
            QueryObject qo    = new QueryObject(bills);

            qo.AddWhere(BillAttr.FK_Flow, this.FK_Flow);
            qo.addAnd();
            qo.addLeftBracket();
            qo.AddWhere(BillAttr.FK_Emp, WebUser.No);
            qo.addOr();
            qo.AddWhere(BillAttr.FK_Starter, WebUser.No);
            qo.addRightBracket();
            qo.DoQuery();

            if (this.FK_Flow != null)
            {
                Flow fl = new Flow(this.FK_Flow);
                this.Pub1.AddTable("width=100%");
                this.Pub1.AddCaption("您的位置:单据查询 <a href='FlowSearch" + this.PageSmall + ".aspx' >返回</a> => " + fl.Name);
            }
            else
            {
                this.Pub1.AddTable();
            }

            this.Pub1.AddTR();
            this.Pub1.AddTDTitle("ID");
            this.Pub1.AddTDTitle("标题");
            this.Pub1.AddTDTitle("发起");
            this.Pub1.AddTDTitle("发起日期");
            this.Pub1.AddTDTitle("发起人部门");
            this.Pub1.AddTDTitle("单据名称");
            this.Pub1.AddTDTitle("打印人");
            this.Pub1.AddTDTitle("打印日期");
            this.Pub1.AddTDTitle("月份");
            this.Pub1.AddTREnd();

            int  i   = 0;
            bool is1 = false;

            foreach (BP.WF.Data.Bill bill in bills)
            {
                this.Pub1.AddTR(is1);
                i++;
                this.Pub1.AddTDIdx(i);
                this.Pub1.AddTD(bill.Title);
                this.Pub1.AddTD(bill.FK_StarterT);
                this.Pub1.AddTD(bill.RDT);
                this.Pub1.AddTD(bill.FK_DeptT);
                this.Pub1.AddTDA("javascript:WinOpen('" + bill.Url + "')", "<img src='" + BP.WF.Glo.CCFlowAppPath + "WF/Img/Btn/Word.gif' border=0 />" + bill.FK_BillText);
                this.Pub1.AddTD(bill.FK_EmpT);
                this.Pub1.AddTD(bill.RDT);
                this.Pub1.AddTD(bill.FK_NY);
                this.Pub1.AddTREnd();
            }
            this.Pub1.AddTableEnd();
        }
Beispiel #8
0
        public void BindBill()
        {
            Flow   fl1 = new Flow(this.FK_Flow);
            string ens = "BP.WF.Bills";

            this.Pub1.AddTable("width='100%'");
            this.Pub1.AddCaptionLeft("您的位置:单据查询 <a href='FlowSearch.aspx' >返回</a> => " + fl1.Name);
            this.Pub1.AddTR();
            this.Pub1.Add("<TD  class=TD  height=800px  width=100% >");
            string src = "/WF/Comm/PanelEns.aspx?EnsName=BP.WF.Bills&FK_Flow=" + this.FK_Flow;

            this.Pub1.Add("<iframe ID='f23' frameborder=0  style='padding:0px;border:0px;'  leftMargin='0'  topMargin='0' src='" + src + "' height='100%' width='100%' scrolling=no  /></iframe>");
            this.Pub1.AddTDEnd();
            this.Pub1.AddTREnd();
            this.Pub1.AddTableEnd();
            return;

            //if (this.RefNo == null)
            //{
            //    this.Pub1.AddTable("width=100%");
            //    this.Pub1.AddTR();
            //    this.Pub1.AddTD("colspan=1 class=ToolBar", "选择您是查询的单据");
            //    this.Pub1.AddTREnd();

            //    this.Pub1.AddTR();
            //    this.Pub1.AddTDBegin();

            //    BillTypes ens = new BillTypes();
            //    ens.RetrieveAll();
            //    this.Pub1.AddUL();

            //    foreach (BillType en in ens)
            //    {
            //        this.Pub1.AddLi("FlowSearch.aspx?FK_Flow="+en.No+"&DoType=Bill&Type=" + en.No, en.Name);
            //    }
            //    this.Pub1.AddULEnd();
            //    this.Pub1.AddTDEnd();
            //    this.Pub1.AddTREnd();
            //    this.Pub1.AddTableEnd();
            //    return;
            //}

            Bills       bills = new Bills();
            QueryObject qo    = new QueryObject(bills);

            qo.AddWhere(BillAttr.FK_Flow, this.FK_Flow);
            qo.addAnd();
            qo.addLeftBracket();
            qo.AddWhere(BillAttr.FK_Emp, WebUser.No);
            qo.addOr();
            qo.AddWhere(BillAttr.FK_Starter, WebUser.No);
            qo.addRightBracket();
            qo.DoQuery();

            if (this.FK_Flow != null)
            {
                Flow fl = new Flow(this.FK_Flow);
                this.Pub1.AddTable();
                this.Pub1.AddCaptionLeft("您的位置:单据查询 <a href='FlowSearch" + this.PageSmall + ".aspx' >返回</a> => " + fl.Name);
            }
            else
            {
                this.Pub1.AddTable();
            }

            this.Pub1.AddTR();
            this.Pub1.AddTDTitle("ID");
            this.Pub1.AddTDTitle("标题");
            this.Pub1.AddTDTitle("发起");
            this.Pub1.AddTDTitle("发起日期");
            this.Pub1.AddTDTitle("发起人部门");
            this.Pub1.AddTDTitle("单据名称");
            this.Pub1.AddTDTitle("打印人");
            this.Pub1.AddTDTitle("打印日期");
            this.Pub1.AddTDTitle("月份");
            this.Pub1.AddTREnd();

            int  i   = 0;
            bool is1 = false;

            foreach (BP.WF.Bill bill in bills)
            {
                this.Pub1.AddTR(is1);
                i++;
                this.Pub1.AddTDIdx(i);
                this.Pub1.AddTD(bill.Title);
                this.Pub1.AddTD(bill.FK_StarterT);
                this.Pub1.AddTD(bill.RDT);
                this.Pub1.AddTD(bill.FK_DeptT);
                this.Pub1.AddTDA("javascript:WinOpen('" + bill.Url + "')", "<img src='/WF/Img/Btn/Word.gif' border=0 />" + bill.FK_BillText);
                this.Pub1.AddTD(bill.FK_EmpT);
                this.Pub1.AddTD(bill.RDT);
                this.Pub1.AddTD(bill.FK_NY);
                this.Pub1.AddTREnd();
            }
            this.Pub1.AddTableEnd();
        }
Beispiel #9
0
        /// <summary>
        /// 获取从表数据,用于显示dtl.htm
        /// </summary>
        /// <param name="frmID">表单ID</param>
        /// <param name="pkval">主键</param>
        /// <param name="atParas">参数</param>
        /// <param name="specDtlFrmID">指定明细表的参数,如果为空就标识主表数据,否则就是从表数据.</param>
        /// <returns>数据</returns>
        public static DataSet GenerDBForCCFormDtl(string frmID, MapDtl dtl, int pkval, string atParas, Int64 fid = 0)
        {
            //数据容器,就是要返回的对象.
            DataSet myds = new DataSet();

            //映射实体.
            //MapData md = new MapData(frmID);

            //实体.
            GEEntity en = new GEEntity(frmID);

            en.OID = pkval;
            if (en.RetrieveFromDBSources() == 0)
            {
                en.Insert();
            }

            //把参数放入到 En 的 Row 里面。
            if (DataType.IsNullOrEmpty(atParas) == false)
            {
                AtPara ap = new AtPara(atParas);
                foreach (string key in ap.HisHT.Keys)
                {
                    try
                    {
                        if (en.Row.ContainsKey(key) == true) //有就该变.
                        {
                            en.Row[key] = ap.GetValStrByKey(key);
                        }
                        else
                        {
                            en.Row.Add(key, ap.GetValStrByKey(key)); //增加他.
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(key);
                    }
                }
            }

            #region 加载从表表单模版信息.

            DataTable Sys_MapDtl = dtl.ToDataTableField("Sys_MapDtl");
            myds.Tables.Add(Sys_MapDtl);

            //明细表的表单描述
            DataTable Sys_MapAttr = dtl.MapAttrs.ToDataTableField("Sys_MapAttr");
            myds.Tables.Add(Sys_MapAttr);

            //明细表的配置信息.
            DataTable Sys_MapExt = dtl.MapExts.ToDataTableField("Sys_MapExt");
            myds.Tables.Add(Sys_MapExt);

            #region 把从表的- 外键表/枚举 加入 DataSet.
            MapExts mes = dtl.MapExts;
            MapExt  me  = null;

            foreach (DataRow dr in Sys_MapAttr.Rows)
            {
                string lgType   = dr["LGType"].ToString();
                string ctrlType = dr[MapAttrAttr.UIContralType].ToString();

                ////不是枚举/外键字段
                //if (lgType.Equals("0") && ctrlType.Equals("0") )
                //    continue;

                string uiBindKey = dr["UIBindKey"].ToString();
                if (DataType.IsNullOrEmpty(uiBindKey) == true)
                {
                    continue;
                }

                var mypk = dr["MyPK"].ToString();

                #region 枚举字段
                if (lgType.Equals("1") == true)
                {
                    // 如果是枚举值, 判断是否存在.
                    if (myds.Tables.Contains(uiBindKey) == true)
                    {
                        continue;
                    }

                    string    mysql  = "SELECT IntKey AS No, Lab as Name FROM Sys_Enum WHERE EnumKey='" + uiBindKey + "' ORDER BY IntKey ";
                    DataTable dtEnum = DBAccess.RunSQLReturnTable(mysql);
                    dtEnum.TableName = uiBindKey;

                    dtEnum.Columns[0].ColumnName = "No";
                    dtEnum.Columns[1].ColumnName = "Name";

                    myds.Tables.Add(dtEnum);
                    continue;
                }
                #endregion

                #region 外键字段
                string UIIsEnable = dr["UIIsEnable"].ToString();
                if (UIIsEnable.Equals("0")) //字段未启用
                {
                    continue;
                }

                // 检查是否有下拉框自动填充。
                string keyOfEn = dr["KeyOfEn"].ToString();

                #region 处理下拉框数据范围. for 小杨.
                me = mes.GetEntityByKey(MapExtAttr.ExtType, MapExtXmlList.AutoFullDLL, MapExtAttr.AttrOfOper, keyOfEn) as MapExt;
                if (me != null) //有范围限制时
                {
                    string fullSQL = me.Doc.Clone() as string;
                    fullSQL = fullSQL.Replace("~", ",");
                    fullSQL = BP.WF.Glo.DealExp(fullSQL, en, null);

                    DataTable dt = DBAccess.RunSQLReturnTable(fullSQL);

                    dt.TableName = uiBindKey;

                    dt.Columns[0].ColumnName = "No";
                    dt.Columns[1].ColumnName = "Name";

                    myds.Tables.Add(dt);
                    continue;
                }
                #endregion 处理下拉框数据范围.

                // 判断是否存在.
                if (myds.Tables.Contains(uiBindKey) == true)
                {
                    continue;
                }

                // 获得数据.
                DataTable mydt = BP.Sys.PubClass.GetDataTableByUIBineKey(uiBindKey);
                myds.Tables.Add(mydt);

                #endregion 外键字段
            }
            #endregion 把从表的- 外键表/枚举 加入 DataSet.


            #endregion 加载从表表单模版信息.

            #region 把主表数据放入.
            if (BP.Sys.SystemConfig.IsBSsystem == true)
            {
                // 处理传递过来的参数。
                foreach (string k in System.Web.HttpContext.Current.Request.QueryString.AllKeys)
                {
                    en.SetValByKey(k, System.Web.HttpContext.Current.Request.QueryString[k]);
                }
            }

            //重设默认值.
            en.ResetDefaultVal();


            //增加主表数据.
            DataTable mainTable = en.ToDataTableField(frmID);
            mainTable.TableName = "MainTable";
            myds.Tables.Add(mainTable);
            #endregion 把主表数据放入.

            #region  把从表的数据放入.
            GEDtls      dtls = new GEDtls(dtl.No);
            QueryObject qo   = null;
            try
            {
                qo = new QueryObject(dtls);
                switch (dtl.DtlOpenType)
                {
                case DtlOpenType.ForEmp:      // 按人员来控制.
                    qo.AddWhere(GEDtlAttr.RefPK, pkval);
                    qo.addAnd();
                    qo.AddWhere(GEDtlAttr.Rec, WebUser.No);
                    break;

                case DtlOpenType.ForWorkID:     // 按工作ID来控制
                    qo.addLeftBracket();
                    qo.AddWhere(GEDtlAttr.RefPK, pkval);
                    qo.addOr();
                    qo.AddWhere(GEDtlAttr.FID, pkval);
                    qo.addRightBracket();
                    break;

                case DtlOpenType.ForFID:     // 按流程ID来控制.
                    if (fid == 0)
                    {
                        qo.AddWhere(GEDtlAttr.FID, pkval);
                    }
                    else
                    {
                        qo.AddWhere(GEDtlAttr.FID, fid);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                dtls.GetNewEntity.CheckPhysicsTable();
                throw ex;
            }

            //条件过滤.
            if (dtl.FilterSQLExp != "")
            {
                string[] strs = dtl.FilterSQLExp.Split('=');
                if (strs.Length == 2)
                {
                    qo.addAnd();
                    qo.AddWhere(strs[0], strs[1]);
                }
            }

            //增加排序.
            //    qo.addOrderByDesc( dtls.GetNewEntity.PKField );

            //从表
            DataTable dtDtl = qo.DoQueryToTable();

            //查询所有动态SQL查询类型的字典表记录
            SFTable   sftable   = null;
            DataTable dtsftable = null;
            DataRow[] drs       = null;

            SFTables sftables = new SFTables();
            sftables.Retrieve(SFTableAttr.SrcType, (int)SrcType.SQL);

            // 为明细表设置默认值.
            MapAttrs dtlAttrs = new MapAttrs(dtl.No);
            foreach (MapAttr attr in dtlAttrs)
            {
                #region 修改区分大小写.
                if (BP.DA.DBType.Oracle == SystemConfig.AppCenterDBType)
                {
                    foreach (DataColumn dr in dtDtl.Columns)
                    {
                        var a = attr.KeyOfEn;
                        var b = dr.ColumnName;
                        if (attr.KeyOfEn.ToUpper().Equals(dr.ColumnName))
                        {
                            dr.ColumnName = attr.KeyOfEn;
                            continue;
                        }

                        if (attr.LGType == FieldTypeS.Enum || attr.LGType == FieldTypeS.FK)
                        {
                            if (dr.ColumnName.Equals(attr.KeyOfEn.ToUpper() + "TEXT"))
                            {
                                dr.ColumnName = attr.KeyOfEn + "Text";
                            }
                        }
                    }
                    foreach (DataRow dr in dtDtl.Rows)
                    {
                        //本身是大写的不进行修改
                        if (DataType.IsNullOrEmpty(dr[attr.KeyOfEn] + ""))
                        {
                            dr[attr.KeyOfEn]           = dr[attr.KeyOfEn.ToUpper()];
                            dr[attr.KeyOfEn.ToUpper()] = null;
                        }
                    }
                }
                #endregion 修改区分大小写.

                if (attr.UIContralType == UIContralType.TB)
                {
                    continue;
                }

                //处理增加动态SQL查询类型的下拉框选中值Text值,added by liuxc,2017-9-22
                if (attr.UIContralType == UIContralType.DDL &&
                    attr.LGType == FieldTypeS.Normal &&
                    attr.UIIsEnable == true)
                {
                    sftable = sftables.GetEntityByKey(attr.UIBindKey) as SFTable;
                    if (sftable != null)
                    {
                        dtsftable = sftable.GenerHisDataTable;

                        //为Text赋值
                        foreach (DataRow dr in dtDtl.Rows)
                        {
                            drs = dtsftable.Select("No='" + dr[attr.KeyOfEn] + "'");
                            if (drs.Length == 0)
                            {
                                continue;
                            }
                            if (dtsftable.Columns.Contains(attr.KeyOfEn + "Text") == true)
                            {
                                dr[attr.KeyOfEn + "Text"] = drs[0]["Name"];
                            }
                            if (dtsftable.Columns.Contains(attr.KeyOfEn + "T") == true)
                            {
                                dr[attr.KeyOfEn + "T"] = drs[0]["Name"];
                            }
                        }
                    }
                }

                //处理它的默认值.
                if (attr.DefValReal.Contains("@") == false)
                {
                    continue;
                }

                foreach (DataRow dr in dtDtl.Rows)
                {
                    dr[attr.KeyOfEn] = attr.DefVal;
                }
            }

            dtDtl.TableName = "DBDtl"; //修改明细表的名称.
            myds.Tables.Add(dtDtl);    //加入这个明细表, 如果没有数据,xml体现为空.
            #endregion 把从表的数据放入.


            //放入一个空白的实体,用与获取默认值.
            GEDtl dtlBlank = dtls.GetNewEntity as GEDtl;
            dtlBlank.ResetDefaultVal();

            myds.Tables.Add(dtlBlank.ToDataTableField("Blank"));

            // myds.WriteXml("c:\\xx.xml");

            return(myds);
        }
Beispiel #10
0
        public DataTable Search_Data()
        {
            DataSet ds = new DataSet();

            #region 查询语句

            MapData md = new MapData(this.FrmID);


            //取出来查询条件.
            BP.Sys.UserRegedit ur = new UserRegedit();
            ur.MyPK = WebUser.No + "_" + this.FrmID + "_SearchAttrs";
            ur.RetrieveFromDBSources();

            GEEntitys rpts = new GEEntitys(this.FrmID);

            Attrs attrs = rpts.GetNewEntity.EnMap.Attrs;

            QueryObject qo = new QueryObject(rpts);

            #region 关键字字段.
            string keyWord = ur.SearchKey;

            if (md.GetParaBoolen("IsSearchKey") && DataType.IsNullOrEmpty(keyWord) == false && keyWord.Length >= 1)
            {
                Attr attrPK = new Attr();
                foreach (Attr attr in attrs)
                {
                    if (attr.IsPK)
                    {
                        attrPK = attr;
                        break;
                    }
                }
                int    i       = 0;
                string enumKey = ","; //求出枚举值外键.
                foreach (Attr attr in attrs)
                {
                    switch (attr.MyFieldType)
                    {
                    case FieldType.Enum:
                        enumKey = "," + attr.Key + "Text,";
                        break;

                    case FieldType.FK:

                        continue;

                    default:
                        break;
                    }

                    if (attr.MyDataType != DataType.AppString)
                    {
                        continue;
                    }

                    //排除枚举值关联refText.
                    if (attr.MyFieldType == FieldType.RefText)
                    {
                        if (enumKey.Contains("," + attr.Key + ",") == true)
                        {
                            continue;
                        }
                    }

                    if (attr.Key == "FK_Dept")
                    {
                        continue;
                    }

                    i++;
                    if (i == 1)
                    {
                        /* 第一次进来。 */
                        qo.addLeftBracket();
                        if (SystemConfig.AppCenterDBVarStr == "@" || SystemConfig.AppCenterDBVarStr == "?")
                        {
                            qo.AddWhere(attr.Key, " LIKE ", SystemConfig.AppCenterDBType == DBType.MySQL ? (" CONCAT('%'," + SystemConfig.AppCenterDBVarStr + "SKey,'%')") : (" '%'+" + SystemConfig.AppCenterDBVarStr + "SKey+'%'"));
                        }
                        else
                        {
                            qo.AddWhere(attr.Key, " LIKE ", " '%'||" + SystemConfig.AppCenterDBVarStr + "SKey||'%'");
                        }
                        continue;
                    }
                    qo.addOr();

                    if (SystemConfig.AppCenterDBVarStr == "@" || SystemConfig.AppCenterDBVarStr == "?")
                    {
                        qo.AddWhere(attr.Key, " LIKE ", SystemConfig.AppCenterDBType == DBType.MySQL ? ("CONCAT('%'," + SystemConfig.AppCenterDBVarStr + "SKey,'%')") : ("'%'+" + SystemConfig.AppCenterDBVarStr + "SKey+'%'"));
                    }
                    else
                    {
                        qo.AddWhere(attr.Key, " LIKE ", "'%'||" + SystemConfig.AppCenterDBVarStr + "SKey||'%'");
                    }
                }
                qo.MyParas.Add("SKey", keyWord);
                qo.addRightBracket();
            }
            else
            {
                qo.AddHD();
            }
            #endregion 关键字段查询

            #region 时间段的查询
            if (md.GetParaInt("DTSearchWay") != (int)DTSearchWay.None && DataType.IsNullOrEmpty(ur.DTFrom) == false)
            {
                string dtFrom = ur.DTFrom; // this.GetTBByID("TB_S_From").Text.Trim().Replace("/", "-");
                string dtTo   = ur.DTTo;   // this.GetTBByID("TB_S_To").Text.Trim().Replace("/", "-");

                //按日期查询
                if (md.GetParaInt("DTSearchWay") == (int)DTSearchWay.ByDate)
                {
                    qo.addAnd();
                    qo.addLeftBracket();
                    dtTo  += " 23:59:59";
                    qo.SQL = md.GetParaString("DTSearchKey") + " >= '" + dtFrom + "'";
                    qo.addAnd();
                    qo.SQL = md.GetParaString("DTSearchKey") + " <= '" + dtTo + "'";
                    qo.addRightBracket();
                }

                if (md.GetParaInt("DTSearchWay") == (int)DTSearchWay.ByDateTime)
                {
                    //取前一天的24:00
                    if (dtFrom.Trim().Length == 10) //2017-09-30
                    {
                        dtFrom += " 00:00:00";
                    }
                    if (dtFrom.Trim().Length == 16) //2017-09-30 00:00
                    {
                        dtFrom += ":00";
                    }

                    dtFrom = DateTime.Parse(dtFrom).AddDays(-1).ToString("yyyy-MM-dd") + " 24:00";

                    if (dtTo.Trim().Length < 11 || dtTo.Trim().IndexOf(' ') == -1)
                    {
                        dtTo += " 24:00";
                    }

                    qo.addAnd();
                    qo.addLeftBracket();
                    qo.SQL = md.GetParaString("DTSearchKey") + " >= '" + dtFrom + "'";
                    qo.addAnd();
                    qo.SQL = md.GetParaString("DTSearchKey") + " <= '" + dtTo + "'";
                    qo.addRightBracket();
                }
            }
            #endregion 时间段的查询

            #region 外键或者枚举的查询

            //获得关键字.
            AtPara ap = new AtPara(ur.Vals);
            foreach (string str in ap.HisHT.Keys)
            {
                var val = ap.GetValStrByKey(str);
                if (val.Equals("all"))
                {
                    continue;
                }
                qo.addAnd();
                qo.addLeftBracket();
                qo.AddWhere(str, ap.GetValStrByKey(str));
                qo.addRightBracket();
            }
            #endregion 外键或者枚举的查询

            #endregion 查询语句
            qo.addOrderBy("OID");
            return(qo.DoQueryToTable());
        }
Beispiel #11
0
        public string Search_Init()
        {
            DataSet ds = new DataSet();

            #region 查询显示的列
            MapAttrs mapattrs = new MapAttrs();
            mapattrs.Retrieve(MapAttrAttr.FK_MapData, this.FrmID, MapAttrAttr.Idx);

            DataRow   row = null;
            DataTable dt  = new DataTable("Attrs");
            dt.Columns.Add("KeyOfEn", typeof(string));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Width", typeof(int));
            dt.Columns.Add("UIContralType", typeof(int));
            dt.Columns.Add("LGType", typeof(int));

            //设置标题、单据号位于开始位置


            foreach (MapAttr attr in mapattrs)
            {
                string searchVisable = attr.atPara.GetValStrByKey("SearchVisable");
                if (searchVisable == "0")
                {
                    continue;
                }
                if (attr.UIVisible == false)
                {
                    continue;
                }
                row                  = dt.NewRow();
                row["KeyOfEn"]       = attr.KeyOfEn;
                row["Name"]          = attr.Name;
                row["Width"]         = attr.UIWidthInt;
                row["UIContralType"] = attr.UIContralType;
                row["LGType"]        = attr.LGType;
                dt.Rows.Add(row);
            }
            ds.Tables.Add(dt);
            #endregion 查询显示的列

            #region 查询语句

            MapData md = new MapData(this.FrmID);


            //取出来查询条件.
            BP.Sys.UserRegedit ur = new UserRegedit();
            ur.MyPK = WebUser.No + "_" + this.FrmID + "_SearchAttrs";
            ur.RetrieveFromDBSources();

            GEEntitys rpts = new GEEntitys(this.FrmID);

            Attrs attrs = rpts.GetNewEntity.EnMap.Attrs;

            QueryObject qo = new QueryObject(rpts);

            #region 关键字字段.
            string keyWord = ur.SearchKey;

            if (md.GetParaBoolen("IsSearchKey") && DataType.IsNullOrEmpty(keyWord) == false && keyWord.Length >= 1)
            {
                Attr attrPK = new Attr();
                foreach (Attr attr in attrs)
                {
                    if (attr.IsPK)
                    {
                        attrPK = attr;
                        break;
                    }
                }
                int    i       = 0;
                string enumKey = ","; //求出枚举值外键.
                foreach (Attr attr in attrs)
                {
                    switch (attr.MyFieldType)
                    {
                    case FieldType.Enum:
                        enumKey = "," + attr.Key + "Text,";
                        break;

                    case FieldType.FK:

                        continue;

                    default:
                        break;
                    }

                    if (attr.MyDataType != DataType.AppString)
                    {
                        continue;
                    }

                    //排除枚举值关联refText.
                    if (attr.MyFieldType == FieldType.RefText)
                    {
                        if (enumKey.Contains("," + attr.Key + ",") == true)
                        {
                            continue;
                        }
                    }

                    if (attr.Key == "FK_Dept")
                    {
                        continue;
                    }

                    i++;
                    if (i == 1)
                    {
                        /* 第一次进来。 */
                        qo.addLeftBracket();
                        if (SystemConfig.AppCenterDBVarStr == "@" || SystemConfig.AppCenterDBVarStr == "?")
                        {
                            qo.AddWhere(attr.Key, " LIKE ", SystemConfig.AppCenterDBType == DBType.MySQL ? (" CONCAT('%'," + SystemConfig.AppCenterDBVarStr + "SKey,'%')") : (" '%'+" + SystemConfig.AppCenterDBVarStr + "SKey+'%'"));
                        }
                        else
                        {
                            qo.AddWhere(attr.Key, " LIKE ", " '%'||" + SystemConfig.AppCenterDBVarStr + "SKey||'%'");
                        }
                        continue;
                    }
                    qo.addOr();

                    if (SystemConfig.AppCenterDBVarStr == "@" || SystemConfig.AppCenterDBVarStr == "?")
                    {
                        qo.AddWhere(attr.Key, " LIKE ", SystemConfig.AppCenterDBType == DBType.MySQL ? ("CONCAT('%'," + SystemConfig.AppCenterDBVarStr + "SKey,'%')") : ("'%'+" + SystemConfig.AppCenterDBVarStr + "SKey+'%'"));
                    }
                    else
                    {
                        qo.AddWhere(attr.Key, " LIKE ", "'%'||" + SystemConfig.AppCenterDBVarStr + "SKey||'%'");
                    }
                }
                qo.MyParas.Add("SKey", keyWord);
                qo.addRightBracket();
            }
            else
            {
                qo.AddHD();
            }
            #endregion 关键字段查询

            #region 时间段的查询
            if (md.GetParaInt("DTSearchWay") != (int)DTSearchWay.None && DataType.IsNullOrEmpty(ur.DTFrom) == false)
            {
                string dtFrom = ur.DTFrom; // this.GetTBByID("TB_S_From").Text.Trim().Replace("/", "-");
                string dtTo   = ur.DTTo;   // this.GetTBByID("TB_S_To").Text.Trim().Replace("/", "-");

                //按日期查询
                if (md.GetParaInt("DTSearchWay") == (int)DTSearchWay.ByDate)
                {
                    qo.addAnd();
                    qo.addLeftBracket();
                    dtTo  += " 23:59:59";
                    qo.SQL = md.GetParaString("DTSearchKey") + " >= '" + dtFrom + "'";
                    qo.addAnd();
                    qo.SQL = md.GetParaString("DTSearchKey") + " <= '" + dtTo + "'";
                    qo.addRightBracket();
                }

                if (md.GetParaInt("DTSearchWay") == (int)DTSearchWay.ByDateTime)
                {
                    //取前一天的24:00
                    if (dtFrom.Trim().Length == 10) //2017-09-30
                    {
                        dtFrom += " 00:00:00";
                    }
                    if (dtFrom.Trim().Length == 16) //2017-09-30 00:00
                    {
                        dtFrom += ":00";
                    }

                    dtFrom = DateTime.Parse(dtFrom).AddDays(-1).ToString("yyyy-MM-dd") + " 24:00";

                    if (dtTo.Trim().Length < 11 || dtTo.Trim().IndexOf(' ') == -1)
                    {
                        dtTo += " 24:00";
                    }

                    qo.addAnd();
                    qo.addLeftBracket();
                    qo.SQL = md.GetParaString("DTSearchKey") + " >= '" + dtFrom + "'";
                    qo.addAnd();
                    qo.SQL = md.GetParaString("DTSearchKey") + " <= '" + dtTo + "'";
                    qo.addRightBracket();
                }
            }
            #endregion 时间段的查询

            #region 外键或者枚举的查询

            //获得关键字.
            AtPara ap = new AtPara(ur.Vals);
            foreach (string str in ap.HisHT.Keys)
            {
                var val = ap.GetValStrByKey(str);
                if (val.Equals("all"))
                {
                    continue;
                }
                qo.addAnd();
                qo.addLeftBracket();
                qo.AddWhere(str, ap.GetValStrByKey(str));
                qo.addRightBracket();
            }
            #endregion 外键或者枚举的查询

            #endregion 查询语句

            //获得行数.
            ur.SetPara("RecCount", qo.GetCount());
            ur.Save();

            qo.DoQuery("OID", this.PageSize, this.PageIdx);

            DataTable mydt = rpts.ToDataTableField();
            mydt.TableName = "DT";

            ds.Tables.Add(mydt); //把数据加入里面.

            return(BP.Tools.Json.ToJson(ds));
        }
Beispiel #12
0
        /// <summary>
        /// 单据初始化
        /// </summary>
        /// <returns></returns>
        public string RefBill_Init()
        {
            DataSet ds = new DataSet();

            #region 查询显示的列
            MapAttrs mapattrs = new MapAttrs();
            mapattrs.Retrieve(MapAttrAttr.FK_MapData, this.FrmID, MapAttrAttr.Idx);

            DataRow   row = null;
            DataTable dt  = new DataTable("Attrs");
            dt.Columns.Add("KeyOfEn", typeof(string));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Width", typeof(int));
            dt.Columns.Add("UIContralType", typeof(int));
            dt.Columns.Add("LGType", typeof(int));

            //设置标题、单据号位于开始位置


            foreach (MapAttr attr in mapattrs)
            {
                string searchVisable = attr.atPara.GetValStrByKey("SearchVisable");
                if (searchVisable == "0")
                {
                    continue;
                }
                if (attr.UIVisible == false)
                {
                    continue;
                }
                row                  = dt.NewRow();
                row["KeyOfEn"]       = attr.KeyOfEn;
                row["Name"]          = attr.Name;
                row["Width"]         = attr.UIWidthInt;
                row["UIContralType"] = attr.UIContralType;
                row["LGType"]        = attr.LGType;
                dt.Rows.Add(row);
            }
            ds.Tables.Add(dt);
            #endregion 查询显示的列

            #region 查询语句

            MapData md = new MapData(this.FrmID);

            GEEntitys rpts = new GEEntitys(this.FrmID);

            Attrs attrs = rpts.GetNewEntity.EnMap.Attrs;

            QueryObject qo = new QueryObject(rpts);

            #region 关键字字段.
            string keyWord = this.GetRequestVal("SearchKey");

            if (DataType.IsNullOrEmpty(keyWord) == false && keyWord.Length >= 1)
            {
                qo.addLeftBracket();
                if (SystemConfig.AppCenterDBVarStr == "@" || SystemConfig.AppCenterDBVarStr == "?")
                {
                    qo.AddWhere("Title", " LIKE ", SystemConfig.AppCenterDBType == DBType.MySQL ? (" CONCAT('%'," + SystemConfig.AppCenterDBVarStr + "SKey,'%')") : (" '%'+" + SystemConfig.AppCenterDBVarStr + "SKey+'%'"));
                }
                else
                {
                    qo.AddWhere("Title", " LIKE ", " '%'||" + SystemConfig.AppCenterDBVarStr + "SKey||'%'");
                }
                qo.addOr();
                if (SystemConfig.AppCenterDBVarStr == "@" || SystemConfig.AppCenterDBVarStr == "?")
                {
                    qo.AddWhere("BillNo", " LIKE ", SystemConfig.AppCenterDBType == DBType.MySQL ? ("CONCAT('%'," + SystemConfig.AppCenterDBVarStr + "SKey,'%')") : ("'%'+" + SystemConfig.AppCenterDBVarStr + "SKey+'%'"));
                }
                else
                {
                    qo.AddWhere("BillNo", " LIKE ", "'%'||" + SystemConfig.AppCenterDBVarStr + "SKey||'%'");
                }

                qo.MyParas.Add("SKey", keyWord);
                qo.addRightBracket();
            }
            else
            {
                qo.AddHD();
            }
            #endregion 关键字段查询

            #region 时间段的查询
            string dtFrom = this.GetRequestVal("DTFrom");
            string dtTo   = this.GetRequestVal("DTTo");
            if (DataType.IsNullOrEmpty(dtFrom) == false)
            {
                //取前一天的24:00
                if (dtFrom.Trim().Length == 10) //2017-09-30
                {
                    dtFrom += " 00:00:00";
                }
                if (dtFrom.Trim().Length == 16) //2017-09-30 00:00
                {
                    dtFrom += ":00";
                }

                dtFrom = DateTime.Parse(dtFrom).AddDays(-1).ToString("yyyy-MM-dd") + " 24:00";

                if (dtTo.Trim().Length < 11 || dtTo.Trim().IndexOf(' ') == -1)
                {
                    dtTo += " 24:00";
                }

                qo.addAnd();
                qo.addLeftBracket();
                qo.SQL = " RDT>= '" + dtFrom + "'";
                qo.addAnd();
                qo.SQL = "RDT <= '" + dtTo + "'";
                qo.addRightBracket();
            }
            #endregion 时间段的查询

            qo.DoQuery("OID", this.PageSize, this.PageIdx);

            #endregion

            DataTable mydt = rpts.ToDataTableField();
            mydt.TableName = "DT";

            ds.Tables.Add(mydt); //把数据加入里面.

            return(BP.Tools.Json.ToJson(ds));
        }