Exemple #1
0
        public void SetDGData()
        {
            Map map = this.HisEn.EnMap;

            #region 检查布局 条件 是否合理。
            try
            {
                // 判断选择的两个对象是否相同。
                if (this.DDL_M2.SelectedItemStringVal == this.DDL_M1.SelectedItemStringVal)
                {
                    throw new Exception("对比分析的两个对象[" + this.ContrastLab + "1]与[" + this.ContrastLab + "2]不能相同,这样不符合业务逻辑。");
                }

                // 取出来隶属属性相同的全局配置。
                GlobalKeyVals xmls = new GlobalKeyVals();
                xmls.RetrieveBy(GlobalKeyValAttr.Key, GlobalKeyValList.Subjection);
                foreach (GlobalKeyVal xml in xmls)
                {
                    if (xml.Val.Contains("@" + this.ContrastKey + "@") == false)
                    {
                        continue;
                    }

                    /*
                     * 如果当前的比较对象,包含在全局的系列配置中,
                     * 就把查询条件中的所有与此有关系的都要设置为全部。
                     */
                    string[] myattrs = xml.Val.Split('@');
                    foreach (string s in myattrs)
                    {
                        if (s == null || s == "")
                        {
                            continue;
                        }

                        // 把隶属与条件都设置为查询全部。
                        if (this.ToolBar1.FindControl("DDL_" + s) != null)
                        {
                            if (s == "FK_Dept")
                            {
                                this.ToolBar1.GetDDLByKey("DDL_FK_Dept").SelectedIndex = 0;
                            }
                            else
                            {
                                this.ToolBar1.GetDDLByKey("DDL_" + s).SetSelectItem("all");
                            }
                        }
                    }

                    if (xml.Val.Contains("@" + this.DDL_Key.SelectedItemStringVal + "@"))
                    {
                        /* 分析项目与分组条件不能同选择。*/
                        throw new Exception("您不能选择[" + map.GetAttrByKey(this.DDL_Key.SelectedItemStringVal).Desc + "]做为分类条件。这样不符合业务逻辑,因为它与[" + map.GetAttrByKey(this.ContrastKey).Desc + "]之间有隶属关系。");
                    }
                }

                if (this.ToolBar1.IsExitsContral("DDL_" + this.ContrastKey))
                {
                    /*如果在查询条件里面有,就自动设置它为全部的查询条件,因为比较对象的明细已经确定了。*/
                    if (this.ContrastKey == "FK_Dept")
                    {
                        /* 设置为最大的查询条件 */
                        this.ToolBar1.GetDDLByKey("DDL_FK_Dept").SelectedIndex = 0;
                    }
                    else
                    {
                        this.ToolBar1.GetDDLByKey("DDL_" + this.ContrastKey).SetSelectItem("all");
                    }
                }

                //if (this.ToolBar1.IsExitsContral("DDL_" + this.DDL_GroupField.SelectedItemStringVal))
                //{
                //    /*如果在查询条件里面有。*/
                //    this.ToolBar1.GetDDLByKey("DDL_" + this.DDL_GroupField.SelectedItemStringVal).SetSelectItem("all");
                //}
            }
            catch (Exception ex)
            {
                this.UCSys1.AddMsgOfWarning("在检查对比条件时间出现如下问题:", ex.Message);
                return;
            }
            #endregion

            this.Label2.Text = this.ContrastLab + "1";
            this.Label3.Text = this.ContrastLab + "2";

            try
            {
                Attrs attrs = new Attrs();
                attrs.Add(map.GetAttrByKey(this.DDL_Key.SelectedItemStringVal));

                Entities ens = this.HisEns;
                //  QueryObject qo = this.ToolBar1.InitTableByEnsV2(ens, ens.GetNewEntity, 10000, 1);

                QueryObject qo = new QueryObject();
                //= this.ToolBar1.InitQueryObjectByEns(ens,
                //  map.IsShowSearchKey,map.DTSearchWay, map.DTSearchKey, map.Attrs, map.AttrsOfSearch, map.AttrsOfSearch);

                Attr attr = new Attr();
                attr = map.GetAttrByKey(this.DDL_GroupField.SelectedItemStringVal);
                qo.addAnd();
                if (this.ContrastKey == "FK_Dept")
                {
                    qo.AddWhereDept(this.DDL_M1.SelectedItemStringVal);
                }
                else
                {
                    qo.AddWhere(this.ContrastKey, this.DDL_M1.SelectedItemStringVal);
                }

                //第1个时间段
                DataTable dt1 = qo.DoGroupReturnTable(this.HisEn, attrs, attr, (GroupWay)this.DDL_GroupWay.SelectedItemIntVal, (OrderWay)this.DDL_OrderWay.SelectedItemIntVal);

                //第2个时间段
                Attrs attrs2 = new Attrs();
                attrs2.Add(map.GetAttrByKey(this.DDL_Key.SelectedItemStringVal));

                Entities ens2 = this.HisEns;
                //QueryObject qo2 = this.ToolBar1.InitTableByEnsV2(ens2, ens2.GetNewEntity, 10000, 1);
                QueryObject qo2 = new QueryObject();

                //qo2.addAnd();

                if (this.ContrastKey == "FK_Dept")
                {
                    qo2.AddWhereDept(this.DDL_M2.SelectedItemStringVal);
                }
                else
                {
                    qo2.AddWhere(this.ContrastKey, this.DDL_M2.SelectedItemStringVal);
                }

                DataTable dt2 = qo2.DoGroupReturnTable(this.HisEn, attrs2, attr, (GroupWay)this.DDL_GroupWay.SelectedItemIntVal, (OrderWay)this.DDL_OrderWay.SelectedItemIntVal);


                #region 生成要url条件
                string url = "ContrastDtl.aspx?EnsName=" + this.EnsName;
                //Map map = ens.GetNewEntity;
                foreach (Attr attrS in map.SearchAttrs)
                {
                    if (attrS.MyFieldType == FieldType.RefText)
                    {
                        continue;
                    }

                    if (this.ContrastKey == attrS.Key)
                    {
                        continue;
                    }

                    string s = this.ToolBar1.GetDDLByKey("DDL_" + attrS.Key).SelectedItemStringVal;
                    if (s == "all")
                    {
                        continue;
                    }

                    //ToolbarDDL ddl = (ToolbarDDL)ctl;
                    url += "&" + attrS.Key + "=" + s;
                }
                #endregion


                this.SaveState();
                this.Bind(dt1, dt2, url);
            }
            catch (Exception ex)
            {
                this.ResponseWriteRedMsg(ex);
            }
        }