Beispiel #1
0
        void btn_Go_Click(object sender, EventArgs e)
        {
            MapDtl dtl = new MapDtl(this.FK_MapDtl);

            dtl.IntMapAttrs();
            this.Response.Redirect("MapDtlDe.aspx?DoType=Edit&FK_MapData=" + this.FK_MapData + "&FK_MapDtl=" + this.FK_MapDtl, true);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            MapDtl dtl = new MapDtl();

            dtl.No = this.FK_MapDtl;
            if (dtl.RetrieveFromDBSources() == 0)
            {
                dtl.FK_MapData = this.FK_MapData;
                dtl.Name       = this.FK_MapData;
                dtl.Insert();
                dtl.IntMapAttrs();
            }

            this.Pub1.AddTable("width=100% height='100%'  align=left ");
            this.Pub1.AddTR(" ID='0_0' ");
            this.Pub1.Add("<TD colspan=4 class=TRSum  ><div style='text-align:left; float:left'><a href=\"javascript:EditDtl('" + this.FK_MapData + "','" + dtl.No + "')\" >" + dtl.Name + "</a></div><div style='text-align:right; float:right'><a href=\"javascript:document.getElementById('F" + dtl.No + "').contentWindow.AddF('" + dtl.No + "');\"><img src='/WF/Img/Btn/New.gif' border=0/>插入列</a><a href=\"javascript:document.getElementById('F" + dtl.No + "').contentWindow.AddFGroup('" + dtl.No + "');\"><img src='/WF/Img/Btn/New.gif' border=0/>插入列组</a><a href=\"javascript:document.getElementById('F" + dtl.No + "').contentWindow.CopyF('" + dtl.No + "');\"><img src='/WF/Img/Btn/Copy.gif' border=0/>复制列</a><a href=\"javascript:document.getElementById('F" + dtl.No + "').contentWindow.HidAttr('" + dtl.No + "');\"><img src='/WF/Img/Btn/Copy.gif' border=0/>隐藏列</a><a href=\"javascript:document.getElementById('F" + dtl.No + "').contentWindow.DtlMTR('" + dtl.No + "');\"><img src='/WF/Img/Btn/Copy.gif' border=0/>多表头</a> <a href='Action.aspx?FK_MapData=" + this.FK_MapDtl + "' >从表事件</a><a href=\"javascript:DtlDoUp('" + dtl.No + "')\" ><img src='/WF/Img/Btn/Up.gif' border=0/></a> <a href=\"javascript:DtlDoDown('" + dtl.No + "')\" ><img src='/WF/Img/Btn/Down.gif' border=0/></a></div></td>");
            this.Pub1.AddTREnd();

            this.Pub1.AddTR();
            this.Pub1.Add("<TD colspan=4 ID='TD" + dtl.No + "' height='50px'   align=left>");

            string src = "MapDtlDe.aspx?DoType=Edit&FK_MapData=" + this.FK_MapData + "&FK_MapDtl=" + dtl.No;

            this.Pub1.Add("<iframe ID='F" + dtl.No + "' frameborder=0 style='align:left;padding:0px;border:0px;'  leftMargin='0'  topMargin='0' src='" + src + "' width='100%' height='400'  /></iframe>");

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

            this.Pub1.AddTableEnd();
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "从表设计";

            MapData.IsEditDtlModel = true;
            MapData md  = new MapData(this.FK_MapData);
            MapDtl  dtl = new MapDtl(this.FK_MapDtl);

            if (dtl.IsView == false)
            {
                return;
            }

            MapAttrs attrs      = new MapAttrs(this.MyPK);
            MapAttrs attrs2     = new MapAttrs();
            MapExts  mes        = new MapExts(this.MyPK);
            string   LinkFields = ",";

            if (mes.Count != 0)
            {
                foreach (MapExt me in mes)
                {
                    switch (me.ExtType)
                    {
                    case MapExtXmlList.Link:
                        LinkFields += me.AttrOfOper + ",";
                        break;

                    default:
                        break;
                    }
                }

                this.Page.RegisterClientScriptBlock("s8",
                                                    "<script language='JavaScript' src='../Scripts/jquery-1.4.1.min.js' ></script>");

                this.Page.RegisterClientScriptBlock("b8",
                                                    "<script language='JavaScript' src='../CCForm/MapExt.js' ></script>");

                this.Page.RegisterClientScriptBlock("dCd",
                                                    "<script language='JavaScript' src='/DataUser/JSLibData/" + this.FK_MapDtl + ".js' ></script>");

                this.Pub1.Add("<div id='divinfo' style='width: 155px; position: absolute; color: Lime; display: none;cursor: pointer;align:left'></div>");
            }

            string t = DateTime.Now.ToString("MM-dd-hh:mm:ss");

            if (attrs.Count == 0)
            {
                dtl.IntMapAttrs();
            }


            this.Title = md.Name + " - 设计明细";
            this.Pub1.AddTable("class='Table' border='0' ID='Tab' cellspacing='0' cellpadding='0' ");
            //     this.Pub1.AddCaptionLeftTX("<a href='MapDef.aspx?MyPK=" + md.No + "' ><img src='../Img/Btn/Back.gif' border=0/>" + this.ToE("Back","返回") + ":" + md.Name + "</a> - <img src='../Img/Btn/Table.gif' border=0/>" + dtl.Name + " - <a href=\"javascript:AddF('" + this.MyPK + "');\" ><img src='../Img/Btn/New.gif' border=0/>" + "新建字段" + "</a> ");
            this.Pub1.Add(dtl.MTR);

            #region 输出标题.
            this.Pub1.AddTR();
            if (dtl.IsShowIdx)
            {
                this.Pub1.AddTDTitle("");
            }

            foreach (MapAttr attr in attrs)
            {
                if (attr.UIVisible == false)
                {
                    continue;
                }

                this.Pub1.Add("<TH style='width:" + attr.UIWidthInt + "px'>");
                this.Pub1.Add("<a href=\"javascript:Up('" + this.MyPK + "','" + attr.MyPK + "','" + t + "');\" ><img src='../Img/Btn/Left.gif' class=Arrow alt='向左移动' border=0/></a>");
                if (attr.HisEditType == EditType.UnDel || attr.HisEditType == EditType.Edit)
                {
                    switch (attr.LGType)
                    {
                    case FieldTypeS.Normal:
                        this.Pub1.Add("<a href=\"javascript:Edit('" + this.MyPK + "','" + attr.MyPK + "','" + attr.MyDataType + "');\"  alt='" + attr.KeyOfEn + "'>" + attr.Name + "</a>");
                        break;

                    case FieldTypeS.Enum:
                        this.Pub1.Add("<a href=\"javascript:EditEnum('" + this.MyPK + "','" + attr.MyPK + "');\" alt='" + attr.KeyOfEn + "' >" + attr.Name + "</a>");
                        break;

                    case FieldTypeS.FK:
                        this.Pub1.Add("<a href=\"javascript:EditTable('" + this.MyPK + "','" + attr.MyPK + "','" + attr.MyDataTypeS + "');\"  alt='" + attr.KeyOfEn + "'>" + attr.Name + "</a>");
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    this.Pub1.Add(attr.Name);
                }
                //  this.Pub1.Add("[<a href=\"javascript:Insert('" + this.MyPK + "','" + attr.Idx + "');\" ><img src='../Img/Btn/Insert.gif' border=0/>插入</a>]");
                this.Pub1.Add("<a href=\"javascript:Down('" + this.MyPK + "','" + attr.MyPK + "','" + t + "');\" ><img src='../Img/Btn/Right.gif' class=Arrow alt='向右移动' border=0/></a>");
                this.Pub1.Add("</TH>");
            }

            if (dtl.IsEnableAthM)
            {
                this.Pub1.AddTDTitle("<a href=\"javascript:Attachment('" + dtl.No + "');\"><img src='./../Img/set.gif' border=0 width='16px' /></a>");
            }

            if (dtl.IsEnableM2M)
            {
                this.Pub1.AddTDTitle("<a href=\"javascript:MapM2M('" + dtl.No + "');\"><img src='./../Img/set.gif' border=0 width='16px' /></a>");
            }

            if (dtl.IsEnableM2MM)
            {
                this.Pub1.AddTDTitle("<a href=\"javascript:window.showModalDialog('MapM2MM.aspx?NoOfObj=M2MM&FK_MapData=" + this.FK_MapDtl + "','m2m','dialogHeight: 500px; dialogWidth: 600px;center: yes; help: no')\"><img src='./../Img/set.gif' border=0 width='16px' /></a>");
            }

            if (dtl.IsEnableLink)
            {
                this.Pub1.AddTDTitle(dtl.LinkLabel);
            }

            //Pub1.AddTDTitle("&nbsp;");

            this.Pub1.AddTREnd();
            #endregion 输出标题.

            #region 输出行.
            for (int i = 1; i <= dtl.RowsOfList; i++)
            {
                this.Pub1.AddTR();
                if (dtl.IsShowIdx)
                {
                    this.Pub1.AddTDIdx(i);
                }
                foreach (MapAttr attr in attrs)
                {
                    if (attr.UIVisible == false)
                    {
                        continue;
                    }

                    #region 是否输出超连接.
                    if (attr.UIIsEnable == false && LinkFields.Contains("," + attr.KeyOfEn + ","))
                    {
                        MapExt meLink = mes.GetEntityByKey(MapExtAttr.ExtType, MapExtXmlList.Link) as MapExt;
                        string url    = meLink.Tag;
                        if (url.Contains("?") == false)
                        {
                            url = url + "?a3=2";
                        }
                        url = url + "&WebUserNo=" + WebUser.No + "&SID=" + WebUser.SID + "&EnName=" + this.FK_MapDtl;
                        if (url.Contains("@AppPath"))
                        {
                            url = url.Replace("@AppPath", "http://" + this.Request.Url.Host + this.Request.ApplicationPath);
                        }
                        if (url.Contains("@"))
                        {
                            if (attrs2.Count == 0)
                            {
                                attrs2 = new MapAttrs(this.FK_MapDtl);
                            }
                            foreach (MapAttr item in attrs2)
                            {
                                url = url.Replace("@" + item.KeyOfEn, item.DefVal);
                                if (url.Contains("@") == false)
                                {
                                    break;
                                }
                            }
                        }
                        this.Pub1.AddTD("<a href='" + url + "' target='" + meLink.Tag1 + "' >" + attr.DefVal + "</a>");
                        continue;
                    }
                    #endregion 是否输出超连接.

                    #region 输出字段.
                    switch (attr.LGType)
                    {
                    case FieldTypeS.Normal:
                        if (attr.MyDataType == BP.DA.DataType.AppBoolean)
                        {
                            CheckBox cb = new CheckBox();
                            cb.Checked = attr.DefValOfBool;
                            cb.Enabled = attr.UIIsEnable;
                            cb.Text    = attr.Name;
                            this.Pub1.AddTD(cb);
                            break;
                        }
                        TextBox tb = new TextBox();
                        tb.ID       = "TB_" + attr.KeyOfEn + "_" + i;
                        tb.Text     = attr.DefVal;
                        tb.ReadOnly = !attr.UIIsEnable;
                        this.Pub1.AddTD(tb);
                        switch (attr.MyDataType)
                        {
                        case BP.DA.DataType.AppString:
                            tb.Attributes["style"] = "width:" + attr.UIWidth + "px;border: none;";
                            if (attr.UIHeight > 25)
                            {
                                tb.TextMode             = TextBoxMode.MultiLine;
                                tb.Attributes["Height"] = attr.UIHeight + "px";
                                tb.Rows = attr.UIHeightInt / 25;
                            }
                            break;

                        case BP.DA.DataType.AppDateTime:
                            tb.Attributes["style"] = "width:" + attr.UIWidth + "px;border: none;";
                            if (attr.UIIsEnable)
                            {
                                tb.Attributes["onfocus"] = "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});";
                                //tb.Attributes["class"] = "TBcalendar";
                            }
                            break;

                        case BP.DA.DataType.AppDate:
                            tb.Attributes["style"] = "width:" + attr.UIWidth + "px;border: none;";
                            if (attr.UIIsEnable)
                            {
                                tb.Attributes["onfocus"] = "WdatePicker();";
                                //  tb.Attributes["class"] = "TBcalendar";
                            }
                            break;

                        default:
                            tb.Attributes["style"] = "width:" + attr.UIWidth + "px;border: none;";
                            if (tb.ReadOnly == false)
                            {
                                // OnKeyPress="javascript:return VirtyNum(this);"
                                //tb.Attributes["OnKeyDown"] = "javascript:return VirtyNum(this);";

                                if (attr.MyDataType == DataType.AppInt)
                                {
                                    tb.Attributes["OnKeyDown"] = "javascript:return VirtyInt(this);";
                                }
                                else
                                {
                                    tb.Attributes["OnKeyDown"] = "javascript:return VirtyNum(this);";
                                }

                                tb.Attributes["onkeyup"] += "javascript:C" + i + "();C" + attr.KeyOfEn + "();";
                                tb.Attributes["class"]    = "TBNum";
                            }
                            else
                            {
                                // tb.Attributes["onpropertychange"] += "C" + attr.KeyOfEn + "();";
                                tb.Attributes["class"] = "TBNumReadonly";
                            }
                            break;
                        }
                        break;

                    case FieldTypeS.Enum:
                        DDL ddl = new DDL();
                        ddl.ID = "DDL_" + attr.KeyOfEn + "_" + i;
                        try
                        {
                            ddl.BindSysEnum(attr.KeyOfEn);
                            ddl.SetSelectItem(attr.DefVal);
                        }
                        catch (Exception ex)
                        {
                            BP.Sys.PubClass.Alert(ex.Message);
                        }
                        ddl.Enabled = attr.UIIsEnable;
                        this.Pub1.AddTDCenter(ddl);
                        break;

                    case FieldTypeS.FK:
                        DDL ddl1 = new DDL();
                        ddl1.ID = "DDL_" + attr.KeyOfEn + "_" + i;
                        try
                        {
                            EntitiesNoName ens = attr.HisEntitiesNoName;
                            ens.RetrieveAll();
                            ddl1.BindEntities(ens);
                            if (ddl1.SetSelectItem(attr.DefVal) == false)
                            {
                                ddl1.Items.Insert(0, new ListItem("请选择", attr.DefVal));
                                ddl1.SelectedIndex = 0;
                            }
                        }
                        catch
                        {
                        }
                        ddl1.Enabled = attr.UIIsEnable;
                        this.Pub1.AddTDCenter(ddl1);
                        break;

                    default:
                        break;
                    }
                    #endregion s输出字段.
                }

                #region 输出附件,m2m
                if (dtl.IsEnableAthM)
                {
                    this.Pub1.AddTD("<a href=\"javascript:EnableAthM('" + this.FK_MapDtl + "');\" ><img src='../Img/AttachmentM.png' border=0 width='16px' /></a>");
                }

                if (dtl.IsEnableM2M)
                {
                    this.Pub1.AddTD("<a href=\"javascript:window.showModalDialog('../CCForm/M2M.aspx?NoOfObj=M2M&IsTest=1&OID=0&FK_MapData=" + this.FK_MapDtl + "','m2m','dialogHeight: 500px; dialogWidth: 600px;center: yes; help: no')\"><img src='./../Img/M2M.png' border=0 width='16px' /></a>");
                }

                if (dtl.IsEnableM2MM)
                {
                    this.Pub1.AddTD("<a href=\"javascript:window.showModalDialog('../CCForm/M2MM.aspx?NoOfObj=M2MM&IsTest=1&OID=0&FK_MapData=" + this.FK_MapDtl + "','m2m','dialogHeight: 500px; dialogWidth: 600px;center: yes; help: no')\"><img src='./../Img/M2MM.png' border=0 width='16px' /></a>");
                }

                if (dtl.IsEnableLink)
                {
                    this.Pub1.AddTD("<a href='" + dtl.LinkUrl + "' target='" + dtl.LinkTarget + "' >" + dtl.LinkLabel + "</a>");
                }
                #endregion 输出附件,m2m

                //Pub1.AddTD("&nbsp;");
                this.Pub1.AddTREnd();
            }
            #endregion 输出行.

            #region 合计.
            if (dtl.IsShowSum)
            {
                this.Pub1.AddTRSum();
                if (dtl.IsShowIdx)
                {
                    this.Pub1.AddTD("合计");
                }

                foreach (MapAttr attr in attrs)
                {
                    if (attr.UIVisible == false)
                    {
                        continue;
                    }
                    if (attr.IsNum && attr.LGType == FieldTypeS.Normal)
                    {
                        TB tb = new TB();
                        tb.ID                  = "TB_" + attr.KeyOfEn;
                        tb.Text                = attr.DefVal;
                        tb.ShowType            = attr.HisTBType;
                        tb.ReadOnly            = true;
                        tb.Font.Bold           = true;
                        tb.BackColor           = System.Drawing.Color.FromName("#FFFFFF");
                        tb.Attributes["class"] = "TBNumReadonly";
                        this.Pub1.AddTD(tb);
                    }
                    else
                    {
                        this.Pub1.AddTD();
                    }
                }
                if (dtl.IsEnableAthM)
                {
                    this.Pub1.AddTD();
                }

                if (dtl.IsEnableM2M)
                {
                    this.Pub1.AddTD();
                }

                if (dtl.IsEnableM2MM)
                {
                    this.Pub1.AddTD();
                }

                if (dtl.IsEnableLink)
                {
                    this.Pub1.AddTD();
                }

                //    Pub1.AddTD("&nbsp;");
                this.Pub1.AddTREnd();
            }
            this.Pub1.AddTableEnd();
            #endregion 合计.

            #region 处理设计时自动填充从表.
            if (this.Key != null)
            {
                MapExt   me   = new MapExt(this.FK_MapExt);
                string[] strs = me.Tag1.Split('$');
                foreach (string str in strs)
                {
                    if (str.Contains(this.FK_MapDtl) == false)
                    {
                        continue;
                    }

                    string[] ss = str.Split(':');

                    string sql = ss[1];
                    sql = sql.Replace("@Key", this.Key);
                    sql = sql.Replace("@key", this.Key);
                    sql = sql.Replace("@val", this.Key);
                    sql = sql.Replace("@Val", this.Key);

                    DataTable dt  = DBAccess.RunSQLReturnTable(sql);
                    int       idx = 0;
                    foreach (DataRow dr in dt.Rows)
                    {
                        idx++;
                        foreach (DataColumn dc in dt.Columns)
                        {
                            string val = dr[dc.ColumnName].ToString();
                            try
                            {
                                this.Pub1.GetTextBoxByID("TB_" + dc.ColumnName + "_" + idx).Text = val;
                            }
                            catch
                            {
                            }

                            try
                            {
                                this.Pub1.GetDDLByID("DDL_" + dc.ColumnName + "_" + idx).SetSelectItem(val);
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }
            #endregion 处理设计时自动填充从表.

            #region 处理拓展属性.
            for (int i = 1; i <= dtl.RowsOfList; i++)
            {
                foreach (MapExt me in mes)
                {
                    switch (me.ExtType)
                    {
                    case MapExtXmlList.DDLFullCtrl:     // 自动填充.
                        DDL ddlOper = this.Pub1.GetDDLByID("DDL_" + me.AttrOfOper);
                        if (ddlOper == null)
                        {
                            continue;
                        }
                        ddlOper.Attributes["onchange"] = "DDLFullCtrl(this.value,\'" + ddlOper.ClientID + "\', \'" + me.MyPK + "\')";
                        break;

                    case MapExtXmlList.ActiveDDL:
                        DDL ddlPerant = this.Pub1.GetDDLByID("DDL_" + me.AttrOfOper + "_" + i);
                        if (ddlPerant == null)
                        {
                            me.Delete();
                            continue;
                        }

                        DDL ddlChild = this.Pub1.GetDDLByID("DDL_" + me.AttrsOfActive + "_" + i);
                        if (ddlChild == null)
                        {
                            me.Delete();
                            continue;
                        }

                        ddlPerant.Attributes["onchange"] = "DDLAnsc(this.value,\'" + ddlChild.ClientID + "\', \'" + me.MyPK + "\')";
                        if (ddlPerant.Items.Count == 0)
                        {
                            continue;
                        }

                        string val = ddlPerant.SelectedItemStringVal;

                        string valC1 = ddlChild.SelectedItemStringVal;


                        DataTable dt = DBAccess.RunSQLReturnTable(me.Doc.Replace("@Key", val));

                        ddlChild.Items.Clear();
                        foreach (DataRow dr in dt.Rows)
                        {
                            ddlChild.Items.Add(new ListItem(dr[1].ToString(), dr[0].ToString()));
                        }
                        ddlChild.SetSelectItem(valC1);
                        break;

                    case MapExtXmlList.AutoFullDLL:     //自动填充下拉框的范围.
                        DDL ddlFull = this.Pub1.GetDDLByID("DDL_" + me.AttrOfOper + "_" + i);
                        if (ddlFull == null)
                        {
                            me.Delete();
                            continue;
                        }

                        string valOld = ddlFull.SelectedItemStringVal;
                        ddlFull.Items.Clear();
                        string fullSQL = me.Doc.Replace("@WebUser.No", WebUser.No);
                        fullSQL = fullSQL.Replace("@WebUser.FK_Dept", WebUser.FK_Dept);
                        fullSQL = fullSQL.Replace("@WebUser.Name", WebUser.Name);

                        if (fullSQL.Contains("@"))
                        {
                            //Attrs attrsFull = mydtl.EnMap.Attrs;
                            //foreach (Attr attr in attrsFull)
                            //{
                            //    if (fullSQL.Contains("@") == false)
                            //        break;
                            //    fullSQL = fullSQL.Replace("@" + attr.Key, mydtl.GetValStrByKey(attr.Key));
                            //}
                        }
                        ddlFull.Bind(DBAccess.RunSQLReturnTable(fullSQL), "No", "Name");
                        ddlFull.SetSelectItem(valOld);
                        break;

                    case MapExtXmlList.TBFullCtrl:     // 自动填充.
                        TextBox tbAuto = this.Pub1.GetTextBoxByID("TB_" + me.AttrOfOper + "_" + i);
                        if (tbAuto == null)
                        {
                            me.Delete();
                            continue;
                        }
                        tbAuto.Attributes["onkeyup"]      = "DoAnscToFillDiv(this,this.value,\'" + tbAuto.ClientID + "\', \'" + me.MyPK + "\');";
                        tbAuto.Attributes["AUTOCOMPLETE"] = "OFF";
                        if (me.Tag != "")
                        {
                            /* 处理下拉框的选择范围的问题 */
                            string[] strs = me.Tag.Split('$');
                            foreach (string str in strs)
                            {
                                string[] myCtl = str.Split(':');
                                string   ctlID = myCtl[0];
                                DDL      ddlC  = this.Pub1.GetDDLByID("DDL_" + ctlID + "_" + i);
                                if (ddlC == null)
                                {
                                    continue;
                                }

                                string sql = myCtl[1].Replace("~", "'");
                                sql = sql.Replace("@WebUser.No", WebUser.No);
                                sql = sql.Replace("@WebUser.Name", WebUser.Name);
                                sql = sql.Replace("@WebUser.FK_Dept", WebUser.FK_Dept);
                                sql = sql.Replace("@Key", tbAuto.Text.Trim());
                                dt  = DBAccess.RunSQLReturnTable(sql);
                                string valC = ddlC.SelectedItemStringVal;
                                ddlC.Items.Clear();
                                foreach (DataRow dr in dt.Rows)
                                {
                                    ddlC.Items.Add(new ListItem(dr[1].ToString(), dr[0].ToString()));
                                }
                                ddlC.SetSelectItem(valC);
                            }
                        }
                        // tbAuto.Attributes["onkeyup"] = "DoAnscToFillDiv(this,this.value);";
                        // tbAuto.Attributes["onkeyup"] = "DoAnscToFillDiv(this,this.value,\'" + tbAuto.ClientID + "\', \'" + me.MyPK + "\');";
                        break;

                    case MapExtXmlList.InputCheck:
                        TextBox tbCheck = this.Pub1.GetTextBoxByID("TB_" + me.AttrOfOper + "_" + i);
                        if (tbCheck != null)
                        {
                            tbCheck.Attributes[me.Tag2] += " rowPK=" + i + ";" + me.Tag1 + "(this);";
                        }
                        else
                        {
                            me.Delete();
                        }
                        break;

                    case MapExtXmlList.PopVal:     //弹出窗.
                        TextBox tb = this.Pub1.GetTextBoxByID("TB_" + me.AttrOfOper + "_" + i);
                        if (tb == null)
                        {
                            continue;
                        }
                        //tb.Attributes["ondblclick"] = "return ReturnValCCFormPopVal(this,'" + me.MyPK + "','33');";
                        tb.Attributes["ondblclick"] = "ReturnValCCFormPopVal(this,'" + me.MyPK + "','33');";
                        //    throw new Exception("ssssrrrss");
                        break;

                    default:
                        break;
                    }
                }
            }
            #endregion 处理拓展属性.

            #region 输出自动计算公式
            this.Pub1.Add("\n <script language='JavaScript'>");
            MapExts exts = new MapExts(dtl.No);
            foreach (MapExt ext in exts)
            {
                if (ext.ExtType != MapExtXmlList.AutoFull)
                {
                    continue;
                }

                for (int i = 1; i <= dtl.RowsOfList; i++)
                {
                    string top    = "\n function C" + i + "() { \n ";
                    string script = "";
                    foreach (MapAttr attr in attrs)
                    {
                        if (attr.UIVisible == false)
                        {
                            continue;
                        }
                        if (attr.IsNum == false)
                        {
                            continue;
                        }

                        if (attr.LGType != FieldTypeS.Normal)
                        {
                            continue;
                        }

                        if (ext.Tag == "1" && ext.Doc != "")
                        {
                            script += this.GenerAutoFull(i.ToString(), attrs, ext);
                        }
                    }
                    string end = " \n  } ";
                    this.Pub1.Add(top + script + end);
                }
            }
            this.Pub1.Add("\n</script>");

            // 输出合计算计公式
            foreach (MapAttr attr in attrs)
            {
                if (attr.UIVisible == false)
                {
                    continue;
                }

                if (attr.LGType != FieldTypeS.Normal)
                {
                    continue;
                }

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

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

                string top = "\n<script language='JavaScript'> function C" + attr.KeyOfEn + "() { \n ";
                string end = "\n } </script>";
                this.Pub1.Add(top + this.GenerSum(attr, dtl) + " ; \t\n" + end);
            }
            #endregion 输出自动计算公式
        }
Beispiel #4
0
        public string DoType(string dotype, string v1, string v2, string v3, string v4, string v5)
        {
            string sql = "";

            try
            {
                switch (dotype)
                {
                case "CreateCheckGroup":
                    string gKey    = v1;
                    string gName   = v2;
                    string enName1 = v3;

                    MapAttr attrN = new MapAttr();
                    int     i     = attrN.Retrieve(MapAttrAttr.FK_MapData, enName1, MapAttrAttr.KeyOfEn, gKey + "_Note");
                    i += attrN.Retrieve(MapAttrAttr.FK_MapData, enName1, MapAttrAttr.KeyOfEn, gKey + "_Checker");
                    i += attrN.Retrieve(MapAttrAttr.FK_MapData, enName1, MapAttrAttr.KeyOfEn, gKey + "_RDT");
                    if (i > 0)
                    {
                        return("前缀已经使用:" + gKey + " , 请确认您是否增加了这个审核分组或者,请您更换其他的前缀。");
                    }

                    GroupField gf = new GroupField();
                    gf.Lab    = gName;
                    gf.EnName = enName1;
                    gf.Insert();

                    attrN               = new MapAttr();
                    attrN.FK_MapData    = enName1;
                    attrN.KeyOfEn       = gKey + "_Note";
                    attrN.Name          = "审核意见";
                    attrN.MyDataType    = DataType.AppString;
                    attrN.UIContralType = UIContralType.TB;
                    attrN.UIIsEnable    = true;
                    attrN.UIIsLine      = true;
                    attrN.MaxLen        = 4000;
                    attrN.GroupID       = gf.OID;
                    attrN.UIHeight      = 23 * 3;
                    attrN.IDX           = 1;
                    attrN.Insert();

                    attrN               = new MapAttr();
                    attrN.FK_MapData    = enName1;
                    attrN.KeyOfEn       = gKey + "_Checker";
                    attrN.Name          = "审核人";// "审核人";
                    attrN.MyDataType    = DataType.AppString;
                    attrN.UIContralType = UIContralType.TB;
                    attrN.MaxLen        = 50;
                    attrN.MinLen        = 0;
                    attrN.UIIsEnable    = true;
                    attrN.UIIsLine      = false;
                    attrN.DefVal        = "@WebUser.Name";
                    attrN.UIIsEnable    = false;
                    attrN.GroupID       = gf.OID;
                    attrN.IsSigan       = true;
                    attrN.IDX           = 2;
                    attrN.Insert();

                    attrN               = new MapAttr();
                    attrN.FK_MapData    = enName1;
                    attrN.KeyOfEn       = gKey + "_RDT";
                    attrN.Name          = "审核日期"; // "审核日期";
                    attrN.MyDataType    = DataType.AppDateTime;
                    attrN.UIContralType = UIContralType.TB;
                    attrN.UIIsEnable    = true;
                    attrN.UIIsLine      = false;
                    attrN.DefVal        = "@RDT";
                    attrN.UIIsEnable    = false;
                    attrN.GroupID       = gf.OID;
                    attrN.IDX           = 3;
                    attrN.Insert();
                    return(null);

                case "NewDtl":
                    MapDtl dtlN = new MapDtl();
                    dtlN.No = v1;
                    if (dtlN.RetrieveFromDBSources() != 0)
                    {
                        return("从表已存在");
                    }
                    dtlN.Name       = v1;
                    dtlN.FK_MapData = v2;
                    dtlN.PTable     = v1;
                    dtlN.Insert();
                    dtlN.IntMapAttrs();
                    return(null);

                case "DelM2M":
                    MapM2M m2mDel = new MapM2M();
                    m2mDel.MyPK = v1;
                    m2mDel.Delete();
                    //M2M m2mData = new M2M();
                    //m2mData.Delete(M2MAttr.FK_MapData, v1);
                    return(null);

                case "NewAthM":     // 新建 NewAthM.
                    string fk_mapdataAth = v1;
                    string athName       = v2;

                    BP.Sys.FrmAttachment athM = new FrmAttachment();
                    athM.MyPK = athName;
                    if (athM.IsExits)
                    {
                        return("多选名称:" + athName + ",已经存在。");
                    }

                    athM.X          = float.Parse(v3);
                    athM.Y          = float.Parse(v4);
                    athM.Name       = "多文件上传";
                    athM.FK_MapData = fk_mapdataAth;
                    athM.Insert();
                    return(null);

                case "NewM2M":
                    string fk_mapdataM2M = v1;
                    string m2mName       = v2;
                    MapM2M m2m           = new MapM2M();
                    m2m.FK_MapData = v1;
                    m2m.NoOfObj    = v2;
                    if (v3 == "0")
                    {
                        m2m.HisM2MType = M2MType.M2M;
                        m2m.Name       = "新建一对多";
                    }
                    else
                    {
                        m2m.HisM2MType = M2MType.M2MM;
                        m2m.Name       = "新建一对多多";
                    }

                    m2m.X    = float.Parse(v4);
                    m2m.Y    = float.Parse(v5);
                    m2m.MyPK = m2m.FK_MapData + "_" + m2m.NoOfObj;
                    if (m2m.IsExits)
                    {
                        return("多选名称:" + m2mName + ",已经存在。");
                    }
                    m2m.Insert();
                    return(null);

                case "DelEnum":
                    // 检查这个物理表是否被使用。
                    sql = "SELECT  * FROM Sys_MapAttr WHERE UIBindKey='" + v1 + "'";
                    DataTable dtEnum     = DBAccess.RunSQLReturnTable(sql);
                    string    msgDelEnum = "";
                    foreach (DataRow dr in dtEnum.Rows)
                    {
                        msgDelEnum += "\n 表单编号:" + dr["FK_MapData"] + " , 字段:" + dr["KeyOfEn"] + ", 名称:" + dr["Name"];
                    }

                    if (msgDelEnum != "")
                    {
                        return("该枚举已经被如下字段所引用,您不能删除它。" + msgDelEnum);
                    }

                    sql  = "DELETE FROM Sys_EnumMain WHERE No='" + v1 + "'";
                    sql += "@DELETE FROM Sys_Enum WHERE EnumKey='" + v1 + "' ";
                    DBAccess.RunSQLs(sql);
                    return(null);

                case "DelSFTable":     /* 删除自定义的物理表. */
                    // 检查这个物理表是否被使用。
                    sql = "SELECT  * FROM Sys_MapAttr WHERE UIBindKey='" + v1 + "'";
                    DataTable dt     = DBAccess.RunSQLReturnTable(sql);
                    string    msgDel = "";
                    foreach (DataRow dr in dt.Rows)
                    {
                        msgDel += "\n 表单编号:" + dr["FK_MapData"] + " , 字段:" + dr["KeyOfEn"] + ", 名称:" + dr["Name"];
                    }

                    if (msgDel != "")
                    {
                        return("该数据表已经被如下字段所引用,您不能删除它。" + msgDel);
                    }

                    SFTable sfDel = new SFTable();
                    sfDel.No = v1;
                    sfDel.DirectDelete();
                    return(null);

                case "SaveSFTable":
                    string enName = v2;
                    string chName = v1;
                    if (string.IsNullOrEmpty(v1) || string.IsNullOrEmpty(v2))
                    {
                        return("视图中的中英文名称不能为空。");
                    }

                    SFTable sf = new SFTable();
                    sf.No   = enName;
                    sf.Name = chName;

                    sf.No   = enName;
                    sf.Name = chName;

                    sf.FK_Val = enName;
                    sf.Save();
                    if (DBAccess.IsExitsObject(enName) == true)
                    {
                        /*已经存在此对象,检查一下是否有No,Name列。*/
                        sql = "SELECT No,Name FROM " + enName;
                        try
                        {
                            DBAccess.RunSQLReturnTable(sql);
                        }
                        catch (Exception ex)
                        {
                            return("您指定的表或视图(" + enName + "),不包含No,Name两列,不符合ccflow约定的规则。技术信息:" + ex.Message);
                        }
                        return(null);
                    }
                    else
                    {
                        /*创建这个表,并且插入基础数据。*/
                        try
                        {
                            // 如果没有该表或者视图,就要创建它。
                            sql = "CREATE TABLE " + enName + "(No varchar(30) NOT NULL,Name varchar(50) NULL)";
                            DBAccess.RunSQL(sql);
                            DBAccess.RunSQL("INSERT INTO " + enName + " (No,Name) VALUES('001','Item1')");
                            DBAccess.RunSQL("INSERT INTO " + enName + " (No,Name) VALUES('002','Item2')");
                            DBAccess.RunSQL("INSERT INTO " + enName + " (No,Name) VALUES('003','Item3')");
                        }
                        catch (Exception ex)
                        {
                            sf.DirectDelete();
                            return("创建物理表期间出现错误,可能是非法的物理表名.技术信息:" + ex.Message);
                        }
                    }
                    return(null);      /*创建成功后返回空值*/

                case "FrmTempleteExp": //导出表单.
                    MapData mdfrmtem = new MapData();
                    mdfrmtem.No = v1;
                    if (mdfrmtem.RetrieveFromDBSources() == 0)
                    {
                        if (v1.Contains("ND"))
                        {
                            int  nodeId = int.Parse(v1.Replace("ND", ""));
                            Node nd     = new Node(nodeId);
                            mdfrmtem.Name   = nd.Name;
                            mdfrmtem.PTable = v1;
                            mdfrmtem.EnPK   = "OID";
                            mdfrmtem.Insert();
                        }
                    }

                    DataSet ds   = mdfrmtem.GenerHisDataSet();
                    string  file = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "\\Temp\\" + v1 + ".xml";
                    if (System.IO.File.Exists(file))
                    {
                        System.IO.File.Delete(file);
                    }
                    ds.WriteXml(file);

                    // BP.PubClass.DownloadFile(file, mdfrmtem.Name + ".xml");
                    //this.DownLoadFile(System.Web.HttpContext.Current, file, mdfrmtem.Name);
                    return(null);

                case "FrmTempleteImp":     //导入表单.
                    DataSet dsImp   = new DataSet();
                    string  fileImp = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "\\Temp\\" + v1 + ".xml";
                    dsImp.ReadXml(fileImp);     //读取文件.
                    MapData.ImpMapData(v1, dsImp, true);
                    return(null);

                case "NewHidF":
                    string  fk_mapdataHid = v1;
                    string  key           = v2;
                    string  name          = v3;
                    int     dataType      = int.Parse(v4);
                    MapAttr mdHid         = new MapAttr();
                    mdHid.MyPK        = fk_mapdataHid + "_" + key;
                    mdHid.FK_MapData  = fk_mapdataHid;
                    mdHid.KeyOfEn     = key;
                    mdHid.Name        = name;
                    mdHid.MyDataType  = dataType;
                    mdHid.HisEditType = EditType.Edit;
                    mdHid.MaxLen      = 100;
                    mdHid.MinLen      = 0;
                    mdHid.LGType      = FieldTypeS.Normal;
                    mdHid.UIVisible   = false;
                    mdHid.UIIsEnable  = false;
                    mdHid.Insert();
                    return(null);

                case "DelDtl":
                    MapDtl dtl = new MapDtl(v1);
                    dtl.Delete();
                    return(null);

                case "DeleteFrm":
                    string  delFK_Frm = v1;
                    MapData mdDel     = new MapData(delFK_Frm);
                    mdDel.Delete();
                    sql = "@DELETE FROM Sys_MapData WHERE No='" + delFK_Frm + "'";
                    sql = "@DELETE FROM WF_FrmNode WHERE FK_Frm='" + delFK_Frm + "'";
                    DBAccess.RunSQLs(sql);
                    return(null);

                case "FrmUp":
                case "FrmDown":
                    FrmNode myfn = new FrmNode();
                    myfn.Retrieve(FrmNodeAttr.FK_Node, v1, FrmNodeAttr.FK_Frm, v2);
                    if (dotype == "FrmUp")
                    {
                        myfn.DoUp();
                    }
                    else
                    {
                        myfn.DoDown();
                    }
                    return(null);

                case "SaveFlowFrm":
                    // 转化参数意义.
                    string vals    = v1;
                    string fk_Node = v2;
                    string fk_flow = v3;
                    bool   isPrint = false;
                    if (v5 == "1")
                    {
                        isPrint = true;
                    }

                    bool isReadonly = false;
                    if (v4 == "1")
                    {
                        isReadonly = true;
                    }

                    string msg = this.SaveEn(vals);
                    if (msg.Contains("Error"))
                    {
                        return(msg);
                    }

                    string fk_frm = msg;
                    Frm    fm     = new Frm();
                    fm.No = fk_frm;
                    fm.Retrieve();

                    FrmNode fn = new FrmNode();
                    if (fn.Retrieve(FrmNodeAttr.FK_Frm, fk_frm,
                                    FrmNodeAttr.FK_Node, fk_Node) == 1)
                    {
                        fn.IsEdit  = !isReadonly;
                        fn.IsPrint = isPrint;
                        fn.FK_Flow = fk_flow;
                        fn.Update();
                        BP.DA.DBAccess.RunSQL("UPDATE Sys_MapData SET FK_FrmSort='01',AppType=1  WHERE No='" + fk_frm + "'");
                        return(fk_frm);
                    }

                    fn.FK_Frm  = fk_frm;
                    fn.FK_Flow = fk_flow;
                    fn.FK_Node = int.Parse(fk_Node);
                    fn.IsEdit  = !isReadonly;
                    fn.IsPrint = isPrint;
                    fn.Idx     = 100;
                    fn.FK_Flow = fk_flow;
                    fn.Insert();

                    MapData md = new MapData();
                    md.No = fm.No;
                    if (md.RetrieveFromDBSources() == 0)
                    {
                        md.Name = fm.Name;
                        md.EnPK = "OID";
                        md.Insert();
                    }

                    MapAttr attr = new MapAttr();
                    attr.FK_MapData    = md.No;
                    attr.KeyOfEn       = "OID";
                    attr.Name          = "WorkID";
                    attr.MyDataType    = BP.DA.DataType.AppInt;
                    attr.UIContralType = UIContralType.TB;
                    attr.LGType        = FieldTypeS.Normal;
                    attr.UIVisible     = false;
                    attr.UIIsEnable    = false;
                    attr.DefVal        = "0";
                    attr.HisEditType   = BP.En.EditType.Readonly;
                    attr.Insert();

                    attr               = new MapAttr();
                    attr.FK_MapData    = md.No;
                    attr.KeyOfEn       = "FID";
                    attr.Name          = "FID";
                    attr.MyDataType    = BP.DA.DataType.AppInt;
                    attr.UIContralType = UIContralType.TB;
                    attr.LGType        = FieldTypeS.Normal;
                    attr.UIVisible     = false;
                    attr.UIIsEnable    = false;
                    attr.DefVal        = "0";
                    attr.HisEditType   = BP.En.EditType.Readonly;
                    attr.Insert();

                    attr               = new MapAttr();
                    attr.FK_MapData    = md.No;
                    attr.KeyOfEn       = "RDT";
                    attr.Name          = "记录日期";
                    attr.MyDataType    = BP.DA.DataType.AppDateTime;
                    attr.UIContralType = UIContralType.TB;
                    attr.LGType        = FieldTypeS.Normal;
                    attr.UIVisible     = false;
                    attr.UIIsEnable    = false;
                    attr.DefVal        = "@RDT";
                    attr.HisEditType   = BP.En.EditType.Readonly;
                    attr.Insert();
                    return(fk_frm);

                default:
                    return("Error:" + dotype + " , 未设置此标记.");
                }
            }
            catch (Exception ex)
            {
                return("Error:" + ex.Message);
            }
        }