Beispiel #1
0
        public void SetDataV2()
        {
            this.UCSys1.ClearViewState();
            AttrOfOneVSM attrOM = this.AttrOfOneVSM;
            Entities     ensOfM = attrOM.EnsOfM;

            //if (ensOfM.Count == 0)
            ensOfM.RetrieveAll();

            try
            {
                Entities    ensOfMM = attrOM.EnsOfMM;
                QueryObject qo      = new QueryObject(ensOfMM);
                qo.AddWhere(attrOM.AttrOfOneInMM, this.PK);
                qo.DoQuery();

                if (this.DDL_Group.SelectedValue == "None")
                {
                    if (this.IsLine)
                    {
                        this.UCSys1.UIEn1ToM_OneLine(ensOfM, attrOM.AttrOfMValue, attrOM.AttrOfMText, ensOfMM, attrOM.AttrOfMInMM);
                    }
                    else
                    {
                        this.UCSys1.UIEn1ToM(ensOfM, attrOM.AttrOfMValue, attrOM.AttrOfMText, ensOfMM, attrOM.AttrOfMInMM);
                    }
                }
                else
                {
                    if (this.IsLine)
                    {
                        this.UCSys1.UIEn1ToMGroupKey_Line(ensOfM, attrOM.AttrOfMValue, attrOM.AttrOfMText, ensOfMM, attrOM.AttrOfMInMM, this.DDL_Group.SelectedValue);
                    }
                    else
                    {
                        this.UCSys1.UIEn1ToMGroupKey(ensOfM, attrOM.AttrOfMValue, attrOM.AttrOfMText, ensOfMM, attrOM.AttrOfMInMM, this.DDL_Group.SelectedValue);
                    }
                }
            }
            catch (Exception ex)
            {
                try
                {
                    ensOfM.GetNewEntity.CheckPhysicsTable();
                }
                catch (Exception ex1)
                {
                    BP.DA.Log.DefaultLogWriteLineError(ex1.Message);
                }

                this.UCSys1.ClearViewState();
                ErrMyNum++;
                if (ErrMyNum > 3)
                {
                    this.UCSys1.AddMsgOfWarning("error", ex.Message);
                    return;
                }
                this.SetDataV2();
            }
        }
Beispiel #2
0
        public void Save()
        {
            AttrOfOneVSM attr    = this.AttrOfOneVSM;
            Entities     ensOfMM = attr.EnsOfMM;

            ensOfMM.Delete(attr.AttrOfOneInMM, this.PK);
            string       msg    = "";
            AttrOfOneVSM attrOM = this.AttrOfOneVSM;
            Entities     ensOfM = attrOM.EnsOfM;

            ensOfM.RetrieveAll();
            foreach (Entity en in ensOfM)
            {
                string   pk = en.GetValStringByKey(attr.AttrOfMValue);
                CheckBox cb = (CheckBox)this.UCSys1.FindControl("CB_" + pk);
                if (cb == null)
                {
                    continue;
                }

                if (cb.Checked == false)
                {
                    continue;
                }

                Entity en1 = ensOfMM.GetNewEntity;
                en1.SetValByKey(attr.AttrOfOneInMM, this.PK);
                en1.SetValByKey(attr.AttrOfMInMM, pk);
                en1.Insert();
            }

            Entity enP = ClassFactory.GetEn(this.EnName);

            if (enP.EnMap.EnType != EnType.View)
            {
                enP.SetValByKey(enP.PK, this.PK); // =this.PK;
                enP.Retrieve();                   //查询。
                try
                {
                    enP.Update(); // 执行更新,处理写在 父实体 的业务逻辑。
                }
                catch (Exception ex)
                {
                    msg += "执行更新错误:" + enP.EnDesc + " " + ex.Message;
                }
            }
            //if (msg != "")
            //    this.ResponseWriteBlueMsg(msg);
        }
Beispiel #3
0
        public void SaveTree()
        {
            AttrOfOneVSM attr    = this.AttrOfOneVSM;
            Entities     ensOfMM = attr.EnsOfMM;

            ensOfMM.Delete(attr.AttrOfOneInMM, this.PK); //删除已经保存的数据。

            AttrOfOneVSM attrOM = this.AttrOfOneVSM;
            Entities     ensOfM = attrOM.EnsOfM;

            ensOfM.RetrieveAll();

            Entity enP = ClassFactory.GetEn(this.Request.QueryString["EnsName"]);

            if (enP.EnMap.EnType != EnType.View)
            {
                enP.SetValByKey(enP.PK, this.PK); // =this.PK;
                enP.Retrieve();                   //查询。
                enP.Update();                     // 执行更新,处理写在 父实体 的业务逻辑。
            }
        }
Beispiel #4
0
        public void Save()
        {
            AttrOfOneVSM attr    = this.AttrOfOneVSM;
            Entities     ensOfMM = attr.EnsOfMM;
            QueryObject  qo      = new QueryObject(ensOfMM);

            qo.AddWhere(attr.AttrOfOneInMM, this.PK);
            qo.DoQuery();
            ensOfMM.Delete();              // 删除以前保存得数据。

            AttrOfOneVSM attrOM = this.AttrOfOneVSM;
            Entities     ensOfM = attrOM.EnsOfM;

            ensOfM.RetrieveAll();
            foreach (Entity en in ensOfM)
            {
                string   pk = en.GetValStringByKey(attr.AttrOfMValue);
                CheckBox cb = (CheckBox)this.UCSys1.FindControl("CB_" + pk);
                if (cb.Checked == false)
                {
                    continue;
                }

                Entity en1 = ensOfMM.GetNewEntity;
                en1.SetValByKey(attr.AttrOfOneInMM, this.PK);
                en1.SetValByKey(attr.AttrOfMInMM, pk);
                en1.Insert();
            }

            Entity enP = DA.ClassFactory.GetEn(this.Request.QueryString["EnsName"]);

            if (enP.EnMap.EnType != EnType.View)
            {
                enP.SetValByKey(enP.PK, this.PK); // =this.PK;
                enP.Retrieve();                   //查询。
                enP.Update();                     // 执行更新,处理写在 父实体 的业务逻辑。
            }
        }
Beispiel #5
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <returns></returns>
        public string BranchesAndLeaf_Init()
        {
            string dot2DotEnsName      = this.GetRequestVal("Dot2DotEnsName");
            string defaultGroupAttrKey = this.GetRequestVal("DefaultGroupAttrKey");

            //string enName = this.GetRequestVal("EnName");
            Entity en = ClassFactory.GetEn(this.EnName);

            en.PKVal = this.PKVal;
            en.Retrieve();

            //找到映射.
            AttrsOfOneVSM oneVsM = en.EnMap.AttrsOfOneVSM;
            AttrOfOneVSM  vsM    = null;

            foreach (AttrOfOneVSM item in oneVsM)
            {
                if (item.Dot2DotModel == Dot2DotModel.TreeDeptEmp &&
                    item.EnsOfMM.ToString().Equals(dot2DotEnsName) &&
                    item.DefaultGroupAttrKey.Equals(defaultGroupAttrKey))
                {
                    vsM = item;
                    break;
                }
            }
            if (vsM == null)
            {
                return("err@参数错误,没有找到VSM");
            }

            //组织数据.
            DataSet ds     = new DataSet();
            string  rootNo = vsM.RootNo;

            if (rootNo.Equals("@WebUser.FK_Dept") || rootNo.Equals("WebUser.FK_Dept"))
            {
                rootNo = WebUser.FK_Dept;
            }

            #region 生成树目录.
            string   ensOfM = this.GetRequestVal("EnsOfM"); //多的实体.
            Entities ensMen = ClassFactory.GetEns(ensOfM);
            Entity   enMen  = ensMen.GetNewEntity;

            Attr attr = enMen.EnMap.GetAttrByKey(defaultGroupAttrKey);
            if (attr == null)
            {
                return("err@在实体[" + ensOfM + "]指定的分树的属性[" + defaultGroupAttrKey + "]不存在,请确认是否删除了该属性?");
            }

            if (attr.MyFieldType == FieldType.Normal)
            {
                return("err@在实体[" + ensOfM + "]指定的分树的属性[" + defaultGroupAttrKey + "]不能是普通字段,必须是外键或者枚举.");
            }

            Entities trees = attr.HisFKEns;
            trees.RetrieveAll();

            DataTable dt = trees.ToDataTableField("DBTrees");
            //如果没有parnetNo 列,就增加上, 有可能是分组显示使用这个模式.
            if (dt.Columns.Contains("ParentNo") == false)
            {
                dt.Columns.Add("ParentNo");
                foreach (DataRow dr in dt.Rows)
                {
                    dr["ParentNo"] = rootNo;
                }
            }
            ds.Tables.Add(dt);
            #endregion 生成树目录.

            #region 生成选择的数据.
            Entities dot2Dots = ClassFactory.GetEns(dot2DotEnsName);
            dot2Dots.Retrieve(vsM.AttrOfOneInMM, this.PKVal);

            DataTable dtSelected = dot2Dots.ToDataTableField("DBMMs");

            string attrOfMInMM   = this.GetRequestVal("AttrOfMInMM");
            string AttrOfOneInMM = this.GetRequestVal("AttrOfOneInMM");

            dtSelected.Columns[attrOfMInMM].ColumnName = "No";

            if (dtSelected.Columns.Contains(attrOfMInMM + "Text") == false)
            {
                return("err@MM实体类字段属性需要按照外键属性编写:" + dot2DotEnsName + " - " + attrOfMInMM);
            }

            dtSelected.Columns[attrOfMInMM + "Text"].ColumnName = "Name";

            dtSelected.Columns.Remove(AttrOfOneInMM);
            ds.Tables.Add(dtSelected); //已经选择的数据.
            #endregion 生成选择的数据.

            return(BP.Tools.Json.ToJson(ds));
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                #region 处理可能来自于 父实体 的业务逻辑。
                Entity enP = ClassFactory.GetEn(this.EnName);
                this.Page.Title  = enP.EnDesc;
                this.MainEnName  = enP.EnDesc;
                this.MainEnPKVal = this.PK;
                this.MainEnPK    = enP.PK;
                if (enP.EnMap.EnType != EnType.View)
                {
                    try
                    {
                        enP.SetValByKey(enP.PK, this.PK); // =this.PK;
                        enP.Retrieve();                   //查询。
                        enP.Update();                     // 执行更新,处理写在 父实体 的业务逻辑。
                    }
                    catch
                    {
                    }
                }
                MainEn = enP;
                #endregion
            }
            catch (Exception ex)
            {
                this.ToErrorPage(ex.Message);
                return;
            }

            AttrOfOneVSM ensattr = this.AttrOfOneVSM;
            this.ToolBar1.AddLab("lab_desc", "分组:");
            DropDownList ddl = new DropDownList();
            ddl.ID           = "DDL_Group";
            ddl.AutoPostBack = true;
            this.ToolBar1.Add(ddl);
            ddl.Items.Clear();
            ddl.SelectedIndexChanged += new EventHandler(DDL_Group_SelectedIndexChanged);
            Entity open = ensattr.EnsOfM.GetNewEntity;
            Map    map  = open.EnMap;
            int    len  = 19;

            // 如果最长的 标题  〉 15 长度。就用一行显示。
            if (len > 20)
            {
                this.IsLine = true;
            }
            else
            {
                this.IsLine = false;
            }

            // 先加入enum 类型。
            foreach (Attr attr in map.Attrs)
            {
                /* map */
                if (attr.IsFKorEnum == false)
                {
                    continue;
                }
                this.DDL_Group.Items.Add(new ListItem(attr.Desc, attr.Key));
            }

            this.DDL_Group.Items.Add(new ListItem("无", "None"));
            foreach (ListItem li in ddl.Items)
            {
                if (li.Value == this.ShowWay)
                {
                    li.Selected = true;
                }
            }

            this.ToolBar1.AddSpt("spt");
            UAC uac = ensattr.EnsOfMM.GetNewEntity.HisUAC;
            if (uac.IsInsert == true)
            {
                this.ToolBar1.AddBtn("Btn_Save", "保存");
                this.Btn_Save.UseSubmitBehavior = false;
                this.Btn_Save.OnClientClick     = "this.disabled=true;";
            }
            else
            {
                #region 解决Access 不刷新的问题。
                if (uac.IsUpdate == false)
                {
                    string rowUrl = this.Request.RawUrl;
                    if (rowUrl.IndexOf("rowUrl") > 1)
                    {
                    }
                    else
                    {
                        this.Response.Redirect(rowUrl + "&rowUrl=1", true);
                        return;
                    }
                }
                #endregion
            }

            CheckBox cb = new CheckBox();
            cb.ID = "checkedAll";
            cb.Attributes["onclick"] = "SelectAll(this);";
            cb.Text = "选择全部";

            this.ToolBar1.Add(cb);
            this.DDL_Group.SelectedIndexChanged += new EventHandler(DDL_Group_SelectedIndexChanged);

            #region 增加按钮事件
            try
            {
                this.ToolBar1.GetBtnByID("Btn_Save").Click += new EventHandler(BPToolBar1_ButtonClick);
            }
            catch
            {
            }

            try
            {
                this.ToolBar1.GetBtnByID("Btn_SaveAndClose").Click += new EventHandler(BPToolBar1_ButtonClick);
            }
            catch
            {
            }
            #endregion

            this.SetDataV2();
            if (this.IsTreeShowWay == false)
            {
                this.SetDataV2();
            }
        }
Beispiel #7
0
        public void Save()
        {
            AttrOfOneVSM attr    = this.AttrOfOneVSM;
            Entities     ensOfMM = attr.EnsOfMM;

            ensOfMM.Delete(attr.AttrOfOneInMM, this.PK);

            //执行保存.
            // edited by liuxc,2015.1.6
            // 增加去除相同项的逻辑,比如同一个人员属于多个部门,则保存的时候则可能会选中有多个相同选择项
            var keys = new List <string>();
            var key  = string.Empty;

            foreach (System.Web.UI.Control ctl in this.UCSys1.Controls)
            {
                if (ctl == null || ctl.ID == null)
                {
                    continue;
                }

                if (ctl.ID.Contains("CB_") == false)
                {
                    continue;
                }

                CheckBox cb = (CheckBox)ctl;
                if (cb == null)
                {
                    continue;
                }

                if (cb.Checked == false)
                {
                    continue;
                }

                key = ctl.ID.Split('_')[1];

                if (key == "EN" || key == "SE" || keys.Contains(key))
                {
                    continue;
                }

                Entity en1 = ensOfMM.GetNewEntity;
                en1.SetValByKey(attr.AttrOfOneInMM, this.PK);
                en1.SetValByKey(attr.AttrOfMInMM, key);
                en1.Insert();

                keys.Add(key);
            }

            //更新entity ,防止有业务逻辑出现.
            string msg = "";
            Entity enP = ClassFactory.GetEn(this.EnName);

            if (enP.EnMap.EnType != EnType.View)
            {
                enP.SetValByKey(enP.PK, this.PK); // =this.PK;
                enP.Retrieve();                   //查询。
                try
                {
                    enP.Update(); // 执行更新,处理写在 父实体 的业务逻辑。
                }
                catch (Exception ex)
                {
                    msg += "执行更新错误:" + enP.EnDesc + " " + ex.Message;
                }
            }
        }