示例#1
0
        public void BindNumType(MapAttr mattr)
        {
            this.Pub1.AddTable("align=left");
            this.Pub1.AddCaptionLeft("数据获取 - 当一个字段值需要从其它表中得到时,请设置此功能。");
            this.Pub1.AddTR();
            this.Pub1.Add("<TD>");
            RadioBtn rb = new RadioBtn();

            rb.GroupName = "s";
            rb.Text      = "方式0:不做任何设置。";
            rb.ID        = "RB_Way_0";
            if (mattr.HisAutoFull == AutoFullWay.Way0)
            {
                rb.Checked = true;
            }
            this.Pub1.AddFieldSet(rb);
            this.Pub1.Add("不做任何设置。");
            this.Pub1.AddFieldSetEnd();

            this.Pub1.AddTDEnd();
            this.Pub1.AddTREnd();

            this.Pub1.AddTR();
            this.Pub1.Add("<TD>");

            rb           = new RadioBtn();
            rb.GroupName = "s";
            rb.Text      = "方式1:本表单中数据计算。"; //"";
            rb.ID        = "RB_Way_1";
            if (mattr.HisAutoFull == AutoFullWay.Way1_JS)
            {
                rb.Checked = true;
            }
            this.Pub1.AddFieldSet(rb);
            this.Pub1.Add("比如:@单价*@数量");
            this.Pub1.AddBR();

            TextBox tb = new TextBox();

            tb.ID       = "TB_JS";
            tb.Width    = 450;
            tb.TextMode = TextBoxMode.MultiLine;
            tb.Rows     = 5;
            if (mattr.HisAutoFull == AutoFullWay.Way1_JS)
            {
                tb.Text = mattr.AutoFullDoc;
            }
            this.Pub1.Add(tb);
            this.Pub1.AddFieldSetEnd();
            this.Pub1.AddTDEnd();
            this.Pub1.AddTREnd();

            // 方式2 利用SQL自动填充
            this.Pub1.AddTR();
            this.Pub1.Add("<TD>");

            rb           = new RadioBtn();
            rb.GroupName = "s";
            rb.Text      = "方式2:利用SQL自动填充。";
            rb.ID        = "RB_Way_2";
            if (mattr.HisAutoFull == AutoFullWay.Way2_SQL)
            {
                rb.Checked = true;
            }

            this.Pub1.AddFieldSet(rb);
            this.Pub1.Add("比如:Select Addr From 商品表 WHERE No=@FK_Pro  FK_Pro是本表中的任意字段名<BR>");

            tb          = new TextBox();
            tb.ID       = "TB_SQL";
            tb.Width    = 450;
            tb.TextMode = TextBoxMode.MultiLine;
            tb.Rows     = 5;
            if (mattr.HisAutoFull == AutoFullWay.Way2_SQL)
            {
                tb.Text = mattr.AutoFullDoc;
            }

            this.Pub1.Add(tb);

            this.Pub1.AddFieldSetEnd();
            this.Pub1.AddTDEnd();
            this.Pub1.AddTREnd();

            // 方式3 本表单中外键列
            this.Pub1.AddTR();
            this.Pub1.Add("<TD>");
            rb           = new RadioBtn();
            rb.GroupName = "s";
            rb.Text      = "方式3:本表单中外键列。";
            // rb.Text = "方式3:本表单中外键列</font></b>";
            rb.ID = "RB_Way_3";
            if (mattr.HisAutoFull == AutoFullWay.Way3_FK)
            {
                rb.Checked = true;
            }

            this.Pub1.AddFieldSet(rb);
            this.Pub1.Add("比如:表单中有商品编号列,需要填充商品地址、供应商电话。");
            this.Pub1.AddBR();


            // 让它等于外键表的一个值。
            Attrs   attrs = null;
            MapData md    = new MapData();

            md.No = mattr.FK_MapData;
            if (md.RetrieveFromDBSources() == 0)
            {
                attrs = md.GenerHisMap().HisFKAttrs;
            }
            else
            {
                MapDtl mdtl = new MapDtl();
                mdtl.No = mattr.FK_MapData;
                attrs   = mdtl.GenerMap().HisFKAttrs;
            }

            if (attrs.Count > 0)
            {
            }
            else
            {
                rb.Enabled = false;
                if (rb.Checked)
                {
                    rb.Checked = false;
                }
                this.Pub1.Add("@本表没有外键字段。");
            }

            foreach (Attr attr in attrs)
            {
                if (attr.IsRefAttr)
                {
                    continue;
                }

                rb           = new RadioBtn();
                rb.Text      = attr.Desc;
                rb.ID        = "RB_FK_" + attr.Key;
                rb.GroupName = "sd";

                if (mattr.AutoFullDoc.Contains(attr.Key))
                {
                    rb.Checked = true;
                }

                this.Pub1.Add(rb);
                DDL ddl = new DDL();
                ddl.ID = "DDL_" + attr.Key;

                string sql = "";
                switch (BP.SystemConfig.AppCenterDBType)
                {
                case DBType.Oracle:
                case DBType.Informix:
                    continue;
                    sql = "Select fname as 'No' ,fDesc as 'Name' FROM Sys_FieldDesc WHERE tableName='" + attr.HisFKEn.EnMap.PhysicsTable + "'";
                    break;

                default:
                    sql = "Select name as 'No' ,Name as 'Name' from syscolumns WHERE ID=OBJECT_ID('" + attr.HisFKEn.EnMap.PhysicsTable + "')";
                    break;
                }

                //  string sql = "Select fname as 'No' ,fDesc as 'Name' FROM Sys_FieldDesc WHERE tableName='" + attr.HisFKEn.EnMap.PhysicsTable + "'";
                //string sql = "Select NO , NAME  FROM Port_Emp ";

                DataTable dt = DBAccess.RunSQLReturnTable(sql);
                foreach (DataRow dr in dt.Rows)
                {
                    //  ddl.Items.Add(new ListItem(this.ToE("Field") + dr[0].ToString() + " " + this.ToE("Desc") + " " + dr[1].ToString(), dr[0].ToString()));
                    ListItem li = new ListItem(dr[0].ToString() + ";" + dr[1].ToString(), dr[0].ToString());
                    if (mattr.AutoFullDoc.Contains(dr[0].ToString()))
                    {
                        li.Selected = true;
                    }

                    ddl.Items.Add(li);
                }

                this.Pub1.Add(ddl);
                this.Pub1.AddBR();
            }

            this.Pub1.AddFieldSetEnd();
            this.Pub1.AddTDEnd();
            this.Pub1.AddTREnd();

            // 方式3 本表单中外键列
            this.Pub1.AddTR();
            this.Pub1.Add("<TD>");
            rb           = new RadioBtn();
            rb.GroupName = "s";
            rb.Text      = "方式4:对一个从表的列求值。";
            rb.ID        = "RB_Way_4";
            if (mattr.HisAutoFull == AutoFullWay.Way4_Dtl)
            {
                rb.Checked = true;
            }

            this.Pub1.AddFieldSet(rb);
            this.Pub1.Add("比如:对从表中的列求值。");
            this.Pub1.AddBR();

            // 让它对一个从表求和、求平均、求最大、求最小值。
            MapDtls dtls = new MapDtls(mattr.FK_MapData);

            if (dtls.Count > 0)
            {
            }
            else
            {
                rb.Enabled = false;
                if (rb.Checked)
                {
                    rb.Checked = false;
                }
                // this.Pub1.Add("@没有从表。");
            }
            foreach (MapDtl dtl in dtls)
            {
                DDL ddlF = new DDL();
                ddlF.ID = "DDL_" + dtl.No + "_F";
                MapAttrs mattrs1 = new MapAttrs(dtl.No);
                int      count   = 0;
                foreach (MapAttr mattr1 in mattrs1)
                {
                    if (mattr1.LGType != FieldTypeS.Normal)
                    {
                        continue;
                    }

                    if (mattr1.KeyOfEn == MapAttrAttr.MyPK)
                    {
                        continue;
                    }

                    if (mattr1.IsNum == false)
                    {
                        continue;
                    }
                    switch (mattr1.KeyOfEn)
                    {
                    case "OID":
                    case "RefOID":
                    case "FID":
                        continue;

                    default:
                        break;
                    }
                    count++;
                    ListItem li = new ListItem(mattr1.Name, mattr1.KeyOfEn);
                    if (mattr.HisAutoFull == AutoFullWay.Way4_Dtl)
                    {
                        if (mattr.AutoFullDoc.Contains("=" + mattr1.KeyOfEn))
                        {
                            li.Selected = true;
                        }
                    }
                    ddlF.Items.Add(li);
                }
                if (count == 0)
                {
                    continue;
                }

                rb           = new RadioBtn();
                rb.Text      = dtl.Name;
                rb.ID        = "RB_" + dtl.No;
                rb.GroupName = "dtl";
                if (mattr.AutoFullDoc.Contains(dtl.No))
                {
                    rb.Checked = true;
                }

                this.Pub1.Add(rb);

                DDL ddl = new DDL();
                ddl.ID = "DDL_" + dtl.No + "_Way";
                ddl.Items.Add(new ListItem("求合计", "SUM"));
                ddl.Items.Add(new ListItem("求平均", "AVG"));
                ddl.Items.Add(new ListItem("求最大", "MAX"));
                ddl.Items.Add(new ListItem("求最小", "MIN"));
                this.Pub1.Add(ddl);

                if (mattr.HisAutoFull == AutoFullWay.Way4_Dtl)
                {
                    if (mattr.AutoFullDoc.Contains("SUM"))
                    {
                        ddl.SetSelectItem("SUM");
                    }
                    if (mattr.AutoFullDoc.Contains("AVG"))
                    {
                        ddl.SetSelectItem("AVG");
                    }
                    if (mattr.AutoFullDoc.Contains("MAX"))
                    {
                        ddl.SetSelectItem("MAX");
                    }
                    if (mattr.AutoFullDoc.Contains("MIN"))
                    {
                        ddl.SetSelectItem("MIN");
                    }
                }

                this.Pub1.Add(ddlF);
                this.Pub1.AddBR();
            }

            this.Pub1.AddFieldSetEnd();
            this.Pub1.AddTDEnd();
            this.Pub1.AddTREnd();


            #region 方式5
            //this.Pub1.AddTD();
            //this.Pub1.AddTR();

            //this.Pub1.AddFieldSet(rb);
            //this.Pub1.Add(this.ToE("Way2D", "嵌入的JS"));
            //tb = new TextBox();
            //tb.ID = "TB_JS";
            //tb.Width = 450;
            //tb.TextMode = TextBoxMode.MultiLine;
            //tb.Rows = 5;
            //if (mattr.HisAutoFull == AutoFullWay.Way5_JS)
            //    tb.Text = mattr.AutoFullDoc;
            //this.Pub1.Add(tb);
            //this.Pub1.AddFieldSetEnd();

            //this.Pub1.AddTDEnd();
            //this.Pub1.AddTREnd();
            #endregion 方式5



            this.Pub1.AddTRSum();
            this.Pub1.AddTDBegin("aligen=center");
            Button btn = new Button();
            btn.ID       = "Btn_Save";
            btn.CssClass = "Btn";
            btn.Text     = " 保存 ";
            btn.Click   += new EventHandler(btn_Click);
            this.Pub1.Add(btn);

            btn          = new Button();
            btn.ID       = "Btn_SaveAndClose";
            btn.CssClass = "Btn";
            btn.Text     = " 保存并关闭 ";
            btn.Click   += new EventHandler(btn_Click);
            this.Pub1.Add(btn);
            this.Pub1.AddTREnd();
            this.Pub1.AddTableEnd();
            return;
        }