Ejemplo n.º 1
0
        void mybtn_SaveAutoFullM2M_Click(object sender, EventArgs e)
        {
            //Button btn = sender as Button;
            var btn = sender as LinkBtn;

            if (btn.ID == NamesOfBtn.Cancel)
            {
                this.Response.Redirect("TBFullCtrl.aspx?FK_MapData=" + this.FK_MapData + "&ExtType=" + this.ExtType + "&MyPK=" + this.MyPK + "&RefNo=" + this.RefNo, true);
                return;
            }

            MapExt  myme  = new MapExt(this.MyPK);
            MapM2Ms m2ms  = new MapM2Ms(myme.FK_MapData);
            string  info  = "";
            string  error = "";

            foreach (MapM2M m2m in m2ms)
            {
                TextBox tb = this.Pub1.GetTextBoxByID("TB_" + m2m.NoOfObj);
                if (tb.Text.Trim() == "")
                {
                    continue;
                }
                try
                {
                    DataTable dt  = BP.DA.DBAccess.RunSQLReturnTable(tb.Text);
                    string    err = "";
                    if (dt.Columns[0].ColumnName != "No")
                    {
                        err += "第1列不是No.";
                    }
                    if (dt.Columns[1].ColumnName != "Name")
                    {
                        err += "第2列不是Name.";
                    }

                    if (err != "")
                    {
                        error += "在为(" + m2m.Name + ")检查sql设置时出现错误:请确认列的顺序是否正确为大小写是否匹配。" + err;
                    }
                }
                catch (Exception ex)
                {
                    this.Alert("SQL ERROR: " + ex.Message);
                    return;
                }
                info += "$" + m2m.NoOfObj + ":" + tb.Text;
            }

            if (error != "")
            {
                this.Pub1.AddEasyUiPanelInfo("错误", "设置错误,请更正:<br />" + error, "icon-no");
                //this.Pub1.AddMsgOfWarning("设置错误,请更正:", error);
                return;
            }
            myme.Tag2 = info;
            myme.Update();
            this.Response.Redirect("TBFullCtrl.aspx?FK_MapData=" + this.FK_MapData + "&ExtType=" + this.ExtType + "&MyPK=" + this.MyPK + "&RefNo=" + this.RefNo, true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 新建文本框自动完成
        /// </summary>
        public void EditAutoFullM2M_TB()
        {
            MapExt  myme = new MapExt(this.MyPK);
            MapM2Ms m2ms = new MapM2Ms(myme.FK_MapData);

            if (m2ms.Count == 0)
            {
                this.Pub1.Clear();
                //this.Pub1.AddFieldSet("设置自动填充从表. <a href='?ExtType=" + this.ExtType + "&MyPK=" + this.MyPK + "&FK_MapData=" + this.FK_MapData + "&RefNo=" + this.RefNo + "'>返回</a>");
                //this.Pub1.Add("该表单下没有从表,所以您不能为从表设置自动填充。");
                //this.Pub1.AddFieldSetEnd();
                Pub1.AddEasyUiPanelInfo("设置自动填充从表", "<p>该表单下没有从表,所以您不能为从表设置自动填充。<a href='?ExtType=" + this.ExtType + "&MyPK=" + this.MyPK + "&FK_MapData=" + this.FK_MapData + "&RefNo=" + this.RefNo + "'>返回</a></p>");
                return;
            }

            Pub1.AddTableNormal();
            Pub1.AddTRGroupTitle("设置自动填充从表. <a href='?ExtType=" + this.ExtType + "&MyPK=" + this.MyPK + "&FK_MapData=" + this.FK_MapData + "&RefNo=" + this.RefNo + "'>返回</a>");

            string[] strs       = myme.Tag2.Split('$');
            bool     isHaveM2M  = false;
            bool     isHaveM2MM = false;

            foreach (MapM2M m2m in m2ms)
            {
                if (m2m.HisM2MType == M2MType.M2M)
                {
                    isHaveM2M = true;
                }
                if (m2m.HisM2MType == M2MType.M2MM)
                {
                    isHaveM2MM = true;
                }

                TextBox tb = new TextBox();
                tb.ID      = "TB_" + m2m.NoOfObj;
                tb.Columns = 70;
                tb.Style.Add("width", "100%");
                tb.Rows     = 5;
                tb.TextMode = TextBoxMode.MultiLine;
                foreach (string s in strs)
                {
                    if (s == null)
                    {
                        continue;
                    }

                    if (s.Contains(m2m.NoOfObj + ":") == false)
                    {
                        continue;
                    }

                    string[] ss = s.Split(':');
                    tb.Text = ss[1];
                }

                //this.Pub1.AddFieldSet("编号:" + m2m.NoOfObj + ",名称:" + m2m.Name);
                Pub1.AddTR();
                Pub1.AddTDBegin();
                Pub1.Add("编号:" + m2m.NoOfObj + ",名称:" + m2m.Name);
                Pub1.Add(tb);
                Pub1.AddTDEnd();
                Pub1.AddTREnd();
                //this.Pub1.AddFieldSetEnd();
            }

            //this.Pub1.AddHR();
            Pub1.AddTableEnd();
            Pub1.AddBR();

            //Button mybtn = new Button();
            var mybtn = new LinkBtn(false, NamesOfBtn.Save, "保存");

            mybtn.Click += new EventHandler(mybtn_SaveAutoFullM2M_Click);
            this.Pub1.Add(mybtn);
            Pub1.AddSpace(1);

            mybtn        = new LinkBtn(false, NamesOfBtn.Cancel, "取消");
            mybtn.Click += new EventHandler(mybtn_SaveAutoFullM2M_Click);
            this.Pub1.Add(mybtn);
            Pub1.AddBR();
            //this.Pub1.AddFieldSetEnd();

            if (isHaveM2M)
            {
                //this.Pub1.AddFieldSet("帮助:一对多");
                Pub1.AddEasyUiPanelInfoBegin("帮助:一对多", "icon-help");
                this.Pub1.Add("在主表相关数据发生变化后,一对多数据要发生变化,变化的格式为:");
                this.Pub1.AddBR("实例:SELECT No,Name FROM WF_Emp WHERE FK_Dept='@Key' ");
                this.Pub1.AddBR("相关内容的值发生改变时而自动填充checkbox。");
                this.Pub1.AddBR("注意:");
                this.Pub1.AddBR("1,@Key 是主表字段传递过来的变量。");
                this.Pub1.AddBR("2,必须并且仅有No,Name两个列,顺序不要颠倒。");
                //this.Pub1.AddFieldSetEnd();
                Pub1.AddEasyUiPanelInfoEnd();
            }

            if (isHaveM2MM)
            {
                //this.Pub1.AddFieldSet("帮助:一对多多");
                Pub1.AddEasyUiPanelInfoBegin("帮助:一对多多", "icon-help");
                this.Pub1.Add("在主表相关数据发生变化后,一对多多数据要发生变化,变化的格式为:");
                this.Pub1.AddBR("实例:SELECT a.FK_Emp M1ID, a.FK_Station as M2ID, b.Name as M2Name FROM " + BP.WF.Glo.EmpStation + " a, Port_Station b WHERE  A.FK_Station=B.No and a.FK_Emp='@Key'");
                this.Pub1.AddBR("相关内容的值发生改变时而自动填充checkbox。");
                this.Pub1.AddBR("注意:");
                this.Pub1.AddBR("1,@Key 是主表字段传递过来的变量。");
                this.Pub1.AddBR("2,必须并且仅有3个列 M1ID,M2ID,M2Name,顺序不要颠倒。第1列的ID对应列表的ID,第2,3列对应的是列表数据源的ID与名称。");
                //this.Pub1.AddFieldSetEnd();
                Pub1.AddEasyUiPanelInfoEnd();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "字段复制";

            BP.WF.Node  nd  = new BP.WF.Node(this.FK_Node);
            BP.WF.Nodes nds = new BP.WF.Nodes(nd.FK_Flow);

            Node sNd = new Node(this.NodeOfSelect);

            MapAttrs attrs     = new MapAttrs(this.NodeOfSelect);
            MapAttrs attrsCopy = new MapAttrs(this.FK_Node);


            this.Pub1.AddFieldSet("选择节点");
            this.Pub1.AddUL("Main");
            foreach (BP.WF.Node en in nds)
            {
                if (this.NodeOfSelect == en.NodeID.ToString())
                {
                    this.Pub1.AddLiB("CopyFieldFromNode.aspx?FK_Node=" + this.FK_Node + "&NodeOfSelect=ND" + en.NodeID, "步骤:" + en.Step + ",名称:" + en.Name);
                }
                else
                {
                    this.Pub1.AddLi("CopyFieldFromNode.aspx?FK_Node=" + this.FK_Node + "&NodeOfSelect=ND" + en.NodeID, "步骤:" + en.Step + ",名称:" + en.Name);
                }
            }
            this.Pub1.AddULEnd();
            this.Pub1.AddFieldSetEnd();

            this.Pub2.AddTable("width='500px'");

            //this.Pub2.AddTR();
            //this.Pub2.AddTDTitle(this.ToE("Field", "字段"));
            ////this.Pub2.AddTDTitle("描述");
            ////this.Pub2.AddTDTitle("类型");
            ////this.Pub2.AddTDTitle(this.ToE("Show", "显示"));
            //this.Pub2.AddTREnd();

            GroupFields gfs  = new GroupFields(this.NodeOfSelect);
            MapDtls     dtls = new MapDtls(this.NodeOfSelect);
            MapM2Ms     m2ms = new MapM2Ms(this.NodeOfSelect);
            MapFrames   frms = new MapFrames(this.NodeOfSelect);

            bool isHave = false;

            foreach (GroupField gf in gfs)
            {
                this.Pub2.AddTRSum();
                CheckBox cb = new CheckBox();
                cb.ID   = "CB" + gf.OID;
                cb.Text = "<b>" + gf.Lab + "</b>";
                this.Pub2.AddTD(cb);
                this.Pub2.AddTREnd();

                foreach (MapDtl dtl in dtls)
                {
                    if (dtl.GroupID != gf.OID)
                    {
                        continue;
                    }

                    this.Pub2.AddTR();
                    cb      = new CheckBox();
                    cb.ID   = "CB" + dtl.No + "_" + dtl.GroupID;
                    cb.Text = "从表:" + dtl.Name;
                    this.Pub2.AddTD(cb);
                    this.Pub2.AddTREnd();
                }

                foreach (MapM2M m2m in m2ms)
                {
                    if (m2m.GroupID != gf.OID)
                    {
                        continue;
                    }
                    this.Pub2.AddTR();
                    cb      = new CheckBox();
                    cb.ID   = "CB" + m2m.MyPK + "_" + m2m.GroupID;
                    cb.Text = "多选" + ":" + m2m.Name;
                    this.Pub2.AddTD(cb);
                    this.Pub2.AddTREnd();
                }

                foreach (MapFrame frm in frms)
                {
                    if (frm.GroupID != gf.OID)
                    {
                        continue;
                    }
                    this.Pub2.AddTR();
                    cb      = new CheckBox();
                    cb.ID   = "CB" + frm.MyPK + "_" + frm.GroupID;
                    cb.Text = "框架" + ":" + frm.Name;
                    this.Pub2.AddTD(cb);
                    this.Pub2.AddTREnd();
                }


                this.Pub2.AddTR();
                this.Pub2.AddTDBigDocBegain();
                foreach (MapAttr attr in attrs)
                {
                    if (gf.OID != attr.GroupID)
                    {
                        continue;
                    }

                    switch (attr.KeyOfEn)
                    {
                    case BP.WF.GEStartWorkAttr.CDT:
                    case BP.WF.GEStartWorkAttr.Emps:
                    case BP.WF.GEStartWorkAttr.FID:
                    case BP.WF.GEStartWorkAttr.OID:
                    case BP.WF.GEStartWorkAttr.RDT:
                    case BP.WF.GEStartWorkAttr.Rec:
                    case BP.WF.GEStartWorkAttr.FK_NY:
                    case BP.WF.GEStartWorkAttr.WFState:
                    case BP.WF.GEStartWorkAttr.MyNum:
                    case BP.WF.GEStartWorkAttr.FK_Dept:
                    case BP.WF.GEStartWorkAttr.FK_DeptText:
                        continue;

                    default:
                        break;
                    }

                    cb      = new CheckBox();
                    cb.ID   = attr.KeyOfEn;
                    cb.Text = attr.KeyOfEn + " " + attr.Name;

                    if (attrsCopy.Contains(MapAttrAttr.KeyOfEn, attr.KeyOfEn))
                    {
                        cb.Enabled = false;
                    }
                    else
                    {
                        cb.Enabled = true;
                    }

                    isHave = true;
                    this.Pub2.Add(cb);
                }
                this.Pub2.AddTDEnd();
                this.Pub2.AddTREnd();
            }

            this.Pub2.AddTableEndWithBR();
            Button btn = new Button();

            btn.CssClass = "Btn";
            if (isHave == false)
            {
                return;
            }
            this.Pub2.Add("到分组:");
            gfs = new GroupFields(this.FK_Node);
            BP.Web.Controls.DDL ddl = new BP.Web.Controls.DDL();
            ddl.ID = "DDL_GroupField";
            ddl.Bind(gfs, GroupFieldAttr.OID, GroupFieldAttr.Lab);
            ddl.SetSelectItem(this.GroupField);
            this.Pub2.Add(ddl);
            btn.ID   = "Btn_OK";
            btn.Text = " 复制 ";

            btn.UseSubmitBehavior = false;
            btn.OnClientClick     = "this.disabled=true;";
            //this.disabled='disabled'; return true;";
            // btn.Attributes["onclick"] = " return confirm('您确定要复制选择的字段到 [" + nd.Name + "]表单中吗?');";
            // btn.Attributes["onclick"] = " return confirm('" + this.ToE("AYS", "您确定要复制选择的字段到 [" + nd.Name + "]表单中吗?") + "');";

            btn.Click += new EventHandler(btn_Copy_Click);
            this.Pub2.Add(btn);
        }
        void btn_Copy_Click(object sender, EventArgs e)
        {
            BP.WF.Node nd  = new BP.WF.Node(this.FK_Node);
            Node       sNd = new Node(this.NodeOfSelect);

            BP.En.Attrs attrs     = sNd.HisWork.EnMap.Attrs;
            BP.En.Attrs attrsCopy = nd.HisWork.EnMap.Attrs;

            // 开始copy 分组的节点。
            GroupFields gfs  = new GroupFields(this.NodeOfSelect);
            MapDtls     dtls = new MapDtls(this.NodeOfSelect);
            MapM2Ms     m2ms = new MapM2Ms(this.NodeOfSelect);
            MapFrames   frms = new MapFrames(this.NodeOfSelect);

            foreach (GroupField gf in gfs)
            {
                CheckBox cb = this.Pub2.GetCBByID("CB" + gf.OID);
                if (cb.Checked == false)
                {
                    continue;
                }

                // 生成一个分组实体.
                GroupField mygf = new GroupField();
                mygf.Lab    = gf.Lab;
                mygf.EnName = this.FK_Node;
                mygf.Idx    = gf.Idx;
                mygf.Insert();

                foreach (MapM2M m2m in m2ms)
                {
                    if (m2m.GroupID != gf.OID)
                    {
                        continue;
                    }

                    MapM2M mym2m = new MapM2M();
                    mym2m.MyPK = m2m.MyPK.Replace(this.NodeOfSelect, this.FK_Node);
                    //  mym2m.FK_MapData =this
                    if (mym2m.IsExits)
                    {
                        continue;
                    }

                    mym2m.Copy(m2m);
                    mym2m.FK_MapData = this.FK_Node;
                    mym2m.GroupID    = mygf.OID;
                    mym2m.MyPK       = m2m.MyPK.Replace(this.NodeOfSelect, this.FK_Node);
                    mym2m.Insert();
                }

                foreach (MapFrame frm in frms)
                {
                    if (frm.GroupID != gf.OID)
                    {
                        continue;
                    }

                    MapFrame myen = new MapFrame();
                    myen.MyPK = frm.MyPK.Replace(this.NodeOfSelect, this.FK_Node);
                    if (myen.IsExits)
                    {
                        continue;
                    }

                    myen.Copy(frm);
                    myen.FK_MapData = this.FK_Node;
                    myen.GroupID    = mygf.OID;
                    myen.MyPK       = frm.MyPK.Replace(this.NodeOfSelect, this.FK_Node);
                    myen.Insert();
                }

                // 复制从表.
                foreach (MapDtl dtl in dtls)
                {
                    cb = this.Pub2.GetCBByID("CB_" + dtl.No + gf.OID);
                    MapDtl dtlNew = new MapDtl();
                    dtlNew.No = dtl.No.Replace(this.NodeOfSelect, this.FK_Node);
                    if (dtlNew.IsExits)
                    {
                        continue;
                    }

                    dtlNew.Copy(dtl);
                    dtlNew.FK_MapData = this.FK_Node;
                    dtlNew.No         = dtl.No.Replace(this.NodeOfSelect, this.FK_Node);

                    //  dtlNew.No = this.FK_Node + "Dtl";
                    // dtlNew.No = dtl.No.Replace(this.FK_Node, this.NodeOfSelect);

                    dtlNew.IsInsert = false;
                    dtlNew.IsUpdate = false;
                    dtlNew.IsDelete = false;

                    dtlNew.GroupID = mygf.OID;
                    dtlNew.PTable  = dtlNew.No;

                    dtlNew.Insert();

                    // 复制从表里面的明细。
                    int      idx    = 0;
                    MapAttrs mattrs = new MapAttrs(dtl.No);
                    foreach (MapAttr attr in mattrs)
                    {
                        MapAttr attrNew = new MapAttr();
                        attrNew.Copy(attr);
                        attrNew.FK_MapData = dtlNew.No;
                        attrNew.UIIsEnable = false;
                        if (attrNew.DefVal.Contains("@"))
                        {
                            attrNew.DefVal = "";
                        }

                        dtlNew.RowIdx       = idx;
                        attrNew.HisEditType = EditType.Edit;
                        attrNew.Insert();
                    }
                }

                // copy his fields.
                MapAttrs willCopyAttrs = new MapAttrs();
                willCopyAttrs.Retrieve(MapAttrAttr.GroupID, gf.OID, MapAttrAttr.Idx);
                int idx1 = 0;
                foreach (MapAttr attr in willCopyAttrs)
                {
                    MapAttr attrNew = new MapAttr();
                    if (attrNew.IsExit(MapAttrAttr.FK_MapData, this.FK_Node,
                                       MapAttrAttr.KeyOfEn, attr.KeyOfEn) == true)
                    {
                        continue;
                    }

                    if (attr.UIVisible == false)
                    {
                        continue;
                    }

                    idx1++;
                    attrNew.Copy(attr);
                    attrNew.GroupID    = mygf.OID;
                    attrNew.FK_MapData = this.FK_Node;
                    attrNew.UIIsEnable = false;
                    attrNew.Idx        = idx1;
                    if (attrNew.KeyOfEn == "Title")
                    {
                        attrNew.HisEditType = EditType.Edit;
                    }

                    attrNew.HisEditType = EditType.Edit;
                    attrNew.DefVal      = "";
                    attrNew.Insert();
                }
            }


            int GroupField = this.Pub2.GetDDLByID("DDL_GroupField").SelectedItemIntVal;

            foreach (Attr attr in attrs)
            {
                if (this.Pub2.IsExit(attr.Key) == false)
                {
                    continue;
                }
                CheckBox cb = this.Pub2.GetCBByID(attr.Key);
                if (cb.Checked == false)
                {
                    continue;
                }

                BP.Sys.MapAttr ma = new BP.Sys.MapAttr();
                int            i  = ma.Retrieve(BP.Sys.MapAttrAttr.KeyOfEn, attr.Key,
                                                BP.Sys.MapAttrAttr.FK_MapData, this.NodeOfSelect);

                BP.Sys.MapAttr ma1     = new BP.Sys.MapAttr();
                bool           ishavle = ma1.IsExit(BP.Sys.MapAttrAttr.KeyOfEn, attr.Key,
                                                    BP.Sys.MapAttrAttr.FK_MapData, this.FK_Node);

                if (ishavle)
                {
                    continue;
                }


                ma1.Copy(ma);

                ma1.FK_MapData = this.FK_Node;
                ma1.KeyOfEn    = ma.KeyOfEn;
                ma1.Name       = ma.Name;
                ma1.GroupID    = GroupField;
                ma1.UIIsEnable = false;

                ma1.HisEditType = EditType.Edit;

                if (ma1.DefVal != null && ma1.DefVal.Contains("@"))
                {
                    ma1.DefVal = "";
                }
                ma1.Insert();
            }

            if (this.Pub2.IsExit("CB_Table"))
            {
                if (this.Pub2.GetCBByID("CB_Table").Checked)
                {
                    MapData md1 = new MapData(this.NodeOfSelect);
                    MapData md2 = new MapData(this.FK_Node);
                    //md2.CellsX = md1.CellsX;
                    //md2.CellsY = md1.CellsY;
                    md2.Update();

                    //MapAttrs ma1 = md1.GenerHisTableCells;
                    // 删除历史数据。

                    //ma1.Delete(MapAttrAttr.FK_MapData, this.FK_Node + "T");
                    //foreach (MapAttr attr in ma1)
                    //{
                    //    MapAttr attr2 = new MapAttr();
                    //    attr2.Copy(attr);
                    //    // attr2.OID = 0;
                    //    attr2.GroupID = 0;
                    //    attr2.Idx = 0;
                    //    attr2.FK_MapData = this.FK_Node + "T";
                    //    attr2.UIIsEnable = false;
                    //    attr2.Insert();
                    //}
                }
            }

            this.WinClose();
            //this.WinCloseWithMsg("复制成功");
            //this.Response.Redirect("MapDef.aspx?PK=" + this.FK_Node + "&NodeOfSelect=" + this.NodeOfSelect);
        }