Exemplo n.º 1
0
        public void RegIt(string EnumKey, string vals)
        {
            try
            {
                string[] strs = vals.Split('@');
                SysEnums ens  = new SysEnums();
                ens.Delete(SysEnumAttr.EnumKey, EnumKey);
                this.Clear();

                foreach (string s in strs)
                {
                    if (s == "" || s == null)
                    {
                        continue;
                    }

                    string[] vk = s.Split('=');
                    SysEnum  se = new SysEnum();
                    se.IntKey  = int.Parse(vk[0]);
                    se.Lab     = vk[1];
                    se.EnumKey = EnumKey;
                    se.Lang    = BP.Web.WebUser.SysLang;
                    se.Insert();
                    this.AddEntity(se);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + " - " + vals);
            }
            //  this.Full(EnumKey);
        }
Exemplo n.º 2
0
        public string GenerCaseWhenForOracle(string mTable, string key, string field, string enumKey, int def)
        {
            if (this.Count == 0)
            {
                throw new Exception("@枚举值(" + enumKey + ")已被删除,无法形成期望的SQL。");
            }

            string sql = "";

            sql = " CASE " + mTable + field;
            foreach (SysEnum se1 in this)
            {
                sql += " WHEN " + se1.IntKey + " THEN '" + se1.Lab + "'";
            }

            SysEnum se = (SysEnum)this.GetEntityByKey(SysEnumAttr.IntKey, def);

            if (se == null)
            {
                sql += " END " + key + "Text";
            }
            else
            {
                sql += " WHEN NULL THEN '" + se.Lab + "' END " + key + "TEXT";
            }

            // Cash.AddObj("ESQL" + enName + key + "_" + enumKey, Depositary.Application, sql);
            return(sql);
        }
Exemplo n.º 3
0
        public string GenerCaseWhenForOracle(string enName, string mTable, string key, string field, string enumKey, int def)
        {
            string sql = (string)Cash.GetObjFormApplication("ESQL" + enName + mTable + key + "_" + enumKey, null);

            // string sql = "";
            if (sql != null)
            {
                return(sql);
            }

            if (this.Count == 0)
            {
                throw new Exception("@枚举值" + enumKey + "已被删除。");
            }

            sql = " CASE NVL(" + mTable + field + "," + def + ")";
            foreach (SysEnum se1 in this)
            {
                sql += " WHEN " + se1.IntKey + " THEN '" + se1.Lab + "'";
            }

            SysEnum se = (SysEnum)this.GetEntityByKey(SysEnumAttr.IntKey, def);

            if (se == null)
            {
                sql += " END " + key + "Text";
            }
            else
            {
                sql += " WHEN NULL THEN '" + se.Lab + "' END " + key + "TEXT";
            }

            Cash.AddObj("ESQL" + enName + mTable + key + "_" + enumKey, Depositary.Application, sql);
            return(sql);
        }
Exemplo n.º 4
0
        public void RegIt(string EnumKey, string vals)
        {
            try
            {
                string[] strs = vals.Split('@');
                SysEnums ens  = new SysEnums();
                ens.Delete(SysEnumAttr.EnumKey, EnumKey);
                this.Clear();

                foreach (string s in strs)
                {
                    if (s == "" || s == null)
                    {
                        continue;
                    }

                    string[] vk = s.Split('=');
                    SysEnum  se = new SysEnum();
                    se.IntKey = int.Parse(vk[0]);
                    //杨玉慧
                    //解决当  枚举值含有 ‘=’号时,保存不进去的方法
                    string[] kvsValues = new string[vk.Length - 1];
                    for (int i = 0; i < kvsValues.Length; i++)
                    {
                        kvsValues[i] = vk[i + 1];
                    }
                    se.Lab     = string.Join("=", kvsValues);
                    se.EnumKey = EnumKey;
                    se.Lang    = BP.Web.WebUser.SysLang;
                    se.Insert();
                    this.AddEntity(se);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + " - " + vals);
            }
            //  this.Full(EnumKey);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个String By LabKey.
        /// </summary>
        /// <param name="EnumKey"></param>
        /// <param name="intKey"></param>
        /// <returns></returns>
        public static string GetLabByPK(string EnumKey, int intKey)
        {
            SysEnum en = new SysEnum(EnumKey, intKey);

            return(en.Lab);
        }
Exemplo n.º 6
0
        public void BindAttrs(Attrs attrs)
        {
            //this.HisEn =en;
            bool isReadonly = false;

            this.IsReadonly = false;
            this.IsShowDtl  = false;
            this.Attributes["visibility"] = "hidden";
            this.Add("<table width='100%' id='a1' border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' >");
            bool   isLeft  = true;
            object val     = null;
            bool   isAddTR = true;

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

                if (attr.Key == "MyNum")
                {
                    continue;
                }

                if (isLeft)
                {
                    isAddTR = true;
                    this.AddTR();
                }

                val = attr.DefaultVal;
                if (attr.UIContralType == UIContralType.TB)
                {
                    if (attr.MyFieldType == FieldType.RefText)
                    {
                        this.SetValByKey(attr.Key, val.ToString());
                        continue;
                    }
                    else if (attr.MyFieldType == FieldType.MultiValues)
                    {
                        /* 如果是多值的.*/
                        LB lb = new LB(attr);
                        lb.Visible       = true;
                        lb.Height        = 128;
                        lb.SelectionMode = ListSelectionMode.Multiple;
                        Entities ens = ClassFactory.GetEns(attr.UIBindKey);
                        ens.RetrieveAll();
                        this.Controls.Add(lb);
                    }
                    else
                    {
                        if (attr.UIVisible == false)
                        {
                            //不可见控件
                            TB tb = new TB();
                            tb.LoadMapAttr(attr);
                            tb.ID = "TB_" + attr.Key;
                            tb.Attributes["Visible"] = "false";
                            this.Controls.Add(tb);
                            continue;
                        }
                        else
                        {
                            if (attr.UIHeight != 0)
                            {
                                TB area = new TB();
                                area.LoadMapAttr(attr);
                                area.ID       = "TB_" + attr.Key;
                                area.Text     = val.ToString();
                                area.Rows     = 8;
                                area.TextMode = TextBoxMode.MultiLine;
                                area.Attributes["onchange"] += "Change('TB_" + attr.Key + "');";
                                if (isReadonly)
                                {
                                    area.Enabled = false;
                                }
                                this.AddContral(attr.Desc, area);
                            }
                            else
                            {
                                TB tb = new TB();
                                tb.LoadMapAttr(attr);

                                tb.ID = "TB_" + attr.Key;
                                if (isReadonly)
                                {
                                    tb.Enabled = false;
                                }
                                switch (attr.MyDataType)
                                {
                                case DataType.AppMoney:
                                    tb.Text = decimal.Parse(val.ToString()).ToString("0.00");
                                    break;

                                default:
                                    tb.Text = val.ToString();
                                    break;
                                }
                                tb.Attributes["width"]     = "100%";
                                tb.Attributes["onchange"] += "Change('TB_" + attr.Key + "');";
                                this.AddContral(attr.Desc, tb);
                            }
                        }
                    }
                }
                else if (attr.UIContralType == UIContralType.CheckBok)
                {
                    CheckBox cb = new CheckBox();
                    if (attr.DefaultVal.ToString() == "1")
                    {
                        cb.Checked = true;
                    }
                    else
                    {
                        cb.Checked = false;
                    }

                    if (isReadonly)
                    {
                        cb.Enabled = false;
                    }
                    else
                    {
                        cb.Enabled = attr.UIVisible;
                    }

                    cb.ID = "CB_" + attr.Key;
                    cb.Attributes["onmousedown"] = "Change('CB_" + attr.Key + "')";
                    this.AddContral(attr.Desc, cb);
                }
                else if (attr.UIContralType == UIContralType.DDL)
                {
                    if (isReadonly || !attr.UIIsReadonly)
                    {
                        /* 如果是 DDLIsEnable 的, 就要找到. */
                        if (attr.MyFieldType == FieldType.Enum)
                        {
                            /* 如果是 enum 类型 */
                            int enumKey = 0;
                            try
                            {
                                enumKey = int.Parse(val.ToString());
                            }
                            catch
                            {
                                throw new Exception("默认值错误:" + attr.Key + " = " + val.ToString());
                            }

                            BP.Sys.SysEnum enEnum = new BP.Sys.SysEnum(attr.UIBindKey, "CH", enumKey);

                            //DDL ddl = new DDL(attr,text,en.Lab,false);
                            DDL ddl = new DDL();
                            ddl.Items.Add(new ListItem(enEnum.Lab, val.ToString()));
                            ddl.Items[0].Selected = true;
                            ddl.Enabled           = false;
                            ddl.ID = "DDL_" + attr.Key;

                            this.AddContral(attr.Desc, ddl, true);
                        }
                        else
                        {
                            /* 如果是 ens 类型 */
                            Entities ens = ClassFactory.GetEns(attr.UIBindKey);
                            Entity   en1 = ens.GetNewEntity;
                            en1.SetValByKey(attr.UIRefKeyValue, val.ToString());
                            string lab = "";
                            try
                            {
                                en1.Retrieve();
                                lab = en1.GetValStringByKey(attr.UIRefKeyText);
                            }
                            catch
                            {
                                if (SystemConfig.IsDebug == false)
                                {
                                    lab = "" + val.ToString();
                                }
                                else
                                {
                                    lab = "" + val.ToString();
                                }
                            }

                            DDL ddl = new DDL(attr, val.ToString(), lab, false,
                                              this.Page.Request.ApplicationPath);

                            ddl.ID = "DDL_" + attr.Key;
                            this.AddContral(attr.Desc, ddl, true);
                        }
                    }
                    else
                    {
                        /* 可以使用的情况. */
                        DDL ddl1 = new DDL(attr, val.ToString(), "enumLab", true, this.Page.Request.ApplicationPath);
                        ddl1.ID = "DDL_" + attr.Key;
                        ddl1.Attributes["onchange"] = "Change('DDL_" + attr.Key + "')";
                        this.AddContral(attr.Desc, ddl1, true);
                    }
                }
                else if (attr.UIContralType == UIContralType.RadioBtn)
                {
                    //					Sys.SysEnums enums = new BP.Sys.SysEnums(attr.UIBindKey);
                    //					foreach(SysEnum en in enums)
                    //					{
                    //						return ;
                    //					}
                }

                if (isLeft == false)
                {
                    isAddTR = false;
                    this.AddTREnd();
                }

                isLeft = !isLeft;
            } // 结束循环.
            //补充TR
            if (isAddTR == true)
            {
                this.AddTD("");
                this.AddTD("");
                this.AddTREnd();
            }
            this.Add("</TABLE>");
        }
Exemplo n.º 7
0
        /// <summary>
        /// 绑定数据返回只读,不包含TB控件
        /// </summary>
        /// <param name="attrs"></param>
        /// <param name="pa"></param>
        public void BindAttrsForHtml(Attrs attrs, AtPara pa)
        {
            this.Add("<table width='100%' id='a1' border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' >");
            bool   isLeft  = true;
            object val     = null;
            bool   isAddTR = true;

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

                if (attr.Key == "MyNum")
                {
                    continue;
                }

                if (isLeft)
                {
                    isAddTR = true;
                    this.AddTR();
                }

                val = pa.GetValStrByKey(attr.Key);
                if (attr.UIContralType == UIContralType.TB)
                {
                    if (attr.MyFieldType == FieldType.RefText)
                    {
                        //this.SetValByKey(attr.Key, val.ToString());
                        continue;
                    }
                    else if (attr.MyFieldType == FieldType.MultiValues)
                    {
                        /* 如果是多值的.*/
                        LB lb = new LB(attr);
                        lb.Visible       = true;
                        lb.Height        = 128;
                        lb.SelectionMode = ListSelectionMode.Multiple;
                        Entities ens = ClassFactory.GetEns(attr.UIBindKey);
                        ens.RetrieveAll();
                        this.Controls.Add(lb);
                    }
                    else
                    {
                        if (attr.UIVisible == false)
                        {
                            continue;
                        }
                        else
                        {
                            switch (attr.MyDataType)
                            {
                            case DataType.AppMoney:
                                val = decimal.Parse(val.ToString()).ToString("0.00");
                                break;

                            default:
                                val = val.ToString();
                                break;
                            }

                            this.Add("<td class='FDesc' nowrap width=1% > " + attr.Desc + "</td>");
                            this.Add("<td class='TD' nowrap width='30%'>");
                            this.Add(val.ToString());
                            this.Add("</td>");
                        }
                    }
                }
                else if (attr.UIContralType == UIContralType.CheckBok)
                {
                    CheckBox cb = new CheckBox();
                    if (attr.DefaultVal.ToString() == "1")
                    {
                        cb.Checked = true;
                    }
                    else
                    {
                        cb.Checked = false;
                    }

                    cb.ID = "CB_RD_" + attr.Key;
                    this.AddContral(attr.Desc, cb);
                }
                else if (attr.UIContralType == UIContralType.DDL)
                {
                    /* 如果是 DDLIsEnable 的, 就要找到. */
                    if (attr.MyFieldType == FieldType.Enum)
                    {
                        /* 如果是 enum 类型 */
                        int enumKey = 0;
                        try
                        {
                            enumKey = int.Parse(val.ToString());
                        }
                        catch
                        {
                            throw new Exception("默认值错误:" + attr.Key + " = " + val.ToString());
                        }

                        BP.Sys.SysEnum enEnum = new BP.Sys.SysEnum(attr.UIBindKey, "CH", enumKey);

                        this.Add("<td class='FDesc' nowrap width=1% > " + attr.Desc + "</td>");
                        this.Add("<td class='TD' nowrap width='30%'>");
                        this.Add(enEnum.Lab);
                        this.Add("</td>");
                    }
                    else
                    {
                        /* 如果是 ens 类型 */
                        Entities ens = ClassFactory.GetEns(attr.UIBindKey);
                        Entity   en1 = ens.GetNewEntity;
                        en1.SetValByKey(attr.UIRefKeyValue, val.ToString());
                        string lab = "";
                        try
                        {
                            en1.Retrieve();
                            lab = en1.GetValStringByKey(attr.UIRefKeyText);
                        }
                        catch
                        {
                            if (SystemConfig.IsDebug == false)
                            {
                                lab = "" + val.ToString();
                            }
                            else
                            {
                                lab = "" + val.ToString();
                            }
                        }

                        this.Add("<td class='FDesc' nowrap width=1% > " + attr.Desc + "</td>");
                        this.Add("<td class='TD' nowrap width='30%'>");
                        this.Add(lab);
                        this.Add("</td>");
                    }
                }
                else if (attr.UIContralType == UIContralType.RadioBtn)
                {
                    //					Sys.SysEnums enums = new BP.Sys.SysEnums(attr.UIBindKey);
                    //					foreach(SysEnum en in enums)
                    //					{
                    //						return ;
                    //					}
                }

                if (isLeft == false)
                {
                    isAddTR = false;
                    this.AddTREnd();
                }

                isLeft = !isLeft;
            } // 结束循环.
            //补充TR
            if (isAddTR == true)
            {
                this.AddTD("");
                this.AddTD("");
                this.AddTREnd();
            }
            this.Add("</TABLE>");
        }