Пример #1
0
 /// <summary>
 /// 加入
 /// </summary>
 /// <param name="attr">attr</param>
 public void Add(RefMethod en)
 {
     if (this.IsExits(en))
     {
         return;
     }
     en.Index = this.InnerList.Count;
     this.InnerList.Add(en);
 }
Пример #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string   ensName = this.Request.QueryString["EnsName"];
            int      index   = int.Parse(this.Request.QueryString["Index"]);
            Entities ens     = BP.En.ClassFactory.GetEns(ensName);
            Entity   en      = ens.GetNewEntity;

            BP.En.RefMethod rm = en.EnMap.HisRefMethods[index];

            if (rm.HisAttrs == null || rm.HisAttrs.Count == 0)
            {
                string pk = this.RefEnKey;
                if (pk == null)
                {
                    pk = this.Request.QueryString[en.PK];
                }

                en.PKVal = pk;
                en.Retrieve();
                rm.HisEn = en;

                // 如果是link.
                if (rm.RefMethodType == RefMethodType.LinkModel)
                {
                    string url = rm.Do(null) as string;
                    if (string.IsNullOrEmpty(url))
                    {
                        throw new Exception("@应该返回的url.");
                    }
                    this.Response.Redirect(url, true);
                    return;
                }

                object obj = rm.Do(null);
                if (obj == null)
                {
                    this.WinClose();
                    return;
                }

                string info = obj.ToString();
                info = info.Replace("@", "<br>@");
                if (info.Contains("<"))
                {
                    this.ToWFMsgPage(info);
                }
                else
                {
                    this.WinCloseWithMsg(info);
                }
                return;
            }
            this.Bind(rm);
            this.Label1.Text = this.GenerCaption(en.EnMap.EnDesc + "=>" + rm.GetIcon(this.Request.ApplicationPath) + rm.Title);
        }
Пример #3
0
 /// <summary>
 /// 是不是存在集合里面
 /// </summary>
 /// <param name="en">要检查的RefMethod</param>
 /// <returns>true/false</returns>
 public bool IsExits(RefMethod en)
 {
     foreach (RefMethod dtl in this)
     {
         if (dtl.ClassMethodName == en.ClassMethodName)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #4
0
        void btn_Click(object sender, EventArgs e)
        {
            string msg = "";
            Button btn = sender as Button;
            Entity en  = this.HisEns.GetNewEntity;

            if (btn.ID == "Btn_Del")
            {
                foreach (Control ctl in this.UCSys1.Controls)
                {
                    if (ctl == null || ctl.ID == null || ctl.ID == "")
                    {
                        continue;
                    }
                    if (ctl.ID.Contains("CB_") == false)
                    {
                        continue;
                    }
                    CheckBox cb = ctl as CheckBox;
                    if (cb == null)
                    {
                        continue;
                    }
                    if (cb.Checked == false)
                    {
                        continue;
                    }
                    string id = ctl.ID.Substring(3);
                    try
                    {
                        en.PKVal = id;
                        en.Delete();
                        msg += "<hr>删除成功:<font color=green>" + en.PKVal + "</font>";
                    }
                    catch (Exception ex)
                    {
                        msg += "<hr>删除错误:<font color=red>" + en.PKVal + ", 异常信息:" + ex.Message + "</font>";
                    }
                }
            }
            else
            {
                int idx = int.Parse(btn.ID.Replace("Btn_", ""));
                foreach (Control ctl in this.UCSys1.Controls)
                {
                    if (ctl == null || ctl.ID == null || ctl.ID == "")
                    {
                        continue;
                    }
                    if (ctl.ID.Contains("CB_") == false)
                    {
                        continue;
                    }

                    CheckBox cb = ctl as CheckBox;
                    if (cb == null)
                    {
                        continue;
                    }
                    if (cb.Checked == false)
                    {
                        continue;
                    }

                    string id = ctl.ID.Substring(3);
                    try
                    {
                        en.PKVal = id;
                        en.Retrieve();
                        BP.En.RefMethod rm = en.EnMap.HisRefMethods[idx];
                        rm.HisEn = en;
                        msg     += "<hr>执行:" + en.PKVal + " 信息:<br>" + rm.Do(null);
                    }
                    catch (Exception ex)
                    {
                        msg += "<hr>执行错误:<font color=red>主键值:" + en.PKVal + "<br>" + ex.Message + "</font>";
                    }
                }
            }
            if (msg == "")
            {
                msg = "您没有选择行...";
            }

            this.Session["Info"] = msg;
            this.Response.Redirect("Batch.aspx?EnsName=" + this.EnsName, true);
            // this.Response.Redirect(this.Request.RawUrl, true);
        }
Пример #5
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            this.BPToolBar1.ButtonClick += new EventHandler(BPToolBar1_ButtonClick);

            string   ensName = this.Request.QueryString["EnsName"];
            int      index   = int.Parse(this.Request.QueryString["Index"]);
            Entities ens     = BP.DA.ClassFactory.GetEns(ensName);
            Entity   en      = ens.GetNewEntity;

            BP.En.RefMethod rm = en.EnMap.HisRefMethods[index];

            //			Attrs attrs =en.EnMap.Attrs;
            //			foreach(Attr attr in attrs)
            //			{
            //				en.SetValByKey(attr.Key, this.Request.QueryString[attr.Key]);
            //			}

            //			string pk=this.Request.QueryString["PK"];
            //			if (pk==null)
            //				pk=this.Request.QueryString[en.PK];

            //rm.PK=pk;

            if (rm.HisAttrs == null || rm.HisAttrs.Count == 0)
            {
                string pk = this.Request.QueryString["RefEnKey"];
                if (pk == null)
                {
                    pk = this.Request.QueryString[en.PK];
                }

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

                rm.HisEn = en;
                object obj = rm.Do(null);
                if (obj == null)
                {
                    this.WinClose();
                    return;
                }

                string info = obj.ToString();
                if (info.Contains("<"))
                {
                    this.ToMsgPage(obj.ToString().Replace("@", "<BR>@"));
                }
                else
                {
                    this.WinCloseWithMsg(info);
                }
                return;
            }
            this.Bind(rm);

            if (this.IsPostBack == false)
            {
                this.BPToolBar1.AddBtn(NamesOfBtn.Do, rm.Title);
                this.BPToolBar1.AddSpt("sd");
                this.BPToolBar1.AddBtn(NamesOfBtn.Close);
                //  this.BPToolBar1.AddBtn(NamesOfBtn.Help);
            }

            // this.Label1.Text = this.GenerCaption(this.HisEn.EnMap.EnDesc + "" + this.HisEn.EnMap.TitleExt);
            this.UCEn2.Add(en.EnMap.EnDesc + "=>" + rm.GetIcon(this.Request.ApplicationPath) + rm.Title);
        }
Пример #6
0
        private void BPToolBar1_ButtonClick(object sender, EventArgs e)
        {
            ToolbarBtn btn = (ToolbarBtn)sender;

            switch (btn.ID)
            {
            case NamesOfBtn.Do:
                string   ensName = this.Request.QueryString["EnsName"];
                int      index   = int.Parse(this.Request.QueryString["Index"]);
                Entities ens     = BP.DA.ClassFactory.GetEns(ensName);
                Entity   en      = ens.GetNewEntity;
                en.PKVal = this.Request.QueryString[en.PK];
                en.Retrieve();

                BP.En.RefMethod rm = en.EnMap.HisRefMethods[index];
                rm.HisEn = en;
                int mynum = 0;
                foreach (Attr attr in rm.HisAttrs)
                {
                    if (attr.MyFieldType == FieldType.RefText)
                    {
                        continue;
                    }
                    mynum++;
                }
                //	object[] objs =new object[rm.HisAttrs.Count];
                object[] objs = new object[mynum];

                int idx = 0;
                foreach (Attr attr in rm.HisAttrs)
                {
                    if (attr.MyFieldType == FieldType.RefText)
                    {
                        continue;
                    }

                    switch (attr.UIContralType)
                    {
                    case UIContralType.TB:
                        switch (attr.MyDataType)
                        {
                        case BP.DA.DataType.AppString:
                        case BP.DA.DataType.AppDate:
                        case BP.DA.DataType.AppDateTime:
                            string str1 = this.UCEn1.GetTBByID("TB_" + attr.Key).Text;
                            objs[idx] = str1;
                            //attr.DefaultVal=str1;
                            break;

                        case BP.DA.DataType.AppInt:
                            int myInt = int.Parse(this.UCEn1.GetTBByID("TB_" + attr.Key).Text);
                            objs[idx] = myInt;
                            //attr.DefaultVal=myInt;
                            break;

                        case BP.DA.DataType.AppFloat:
                            float myFloat = float.Parse(this.UCEn1.GetTBByID("TB_" + attr.Key).Text);
                            objs[idx] = myFloat;
                            //attr.DefaultVal=myFloat;
                            break;

                        case BP.DA.DataType.AppDouble:
                        case BP.DA.DataType.AppMoney:
                        case BP.DA.DataType.AppRate:
                            decimal myDoub = decimal.Parse(this.UCEn1.GetTBByID("TB_" + attr.Key).Text);
                            objs[idx] = myDoub;
                            //attr.DefaultVal=myDoub;
                            break;

                        case BP.DA.DataType.AppBoolean:
                            int myBool = int.Parse(this.UCEn1.GetTBByID("TB_" + attr.Key).Text);
                            if (myBool == 0)
                            {
                                objs[idx]       = false;
                                attr.DefaultVal = false;
                            }
                            else
                            {
                                objs[idx]       = true;
                                attr.DefaultVal = true;
                            }
                            break;

                        default:
                            throw new Exception("没有判断的数据类型.");
                        }
                        break;

                    case UIContralType.DDL:
                        try
                        {
                            string str = this.UCEn1.GetDDLByKey("DDL_" + attr.Key).SelectedItemStringVal;
                            objs[idx]       = str;
                            attr.DefaultVal = str;
                        }
                        catch (Exception ex)
                        {
                            // this.ToErrorPage("获取:[" + attr.Desc + "] 期间出现错误,可能是该下拉框中没有选择项目,错误技术信息:" + ex.Message);

                            objs[idx] = null;
                            // attr.DefaultVal = "";
                        }
                        break;

                    case UIContralType.CheckBok:
                        if (this.UCEn1.GetCBByKey("CB_" + attr.Key).Checked)
                        {
                            objs[idx] = "1";
                        }
                        else
                        {
                            objs[idx] = "0";
                        }
                        attr.DefaultVal = objs[idx].ToString();
                        break;

                    default:
                        break;
                    }
                    idx++;
                }

                //					string pk=this.Request.QueryString["PK"];
                //					if (pk==null)
                //						pk=this.Request.QueryString[ en.PK ];
                //					rm.PK=pk;

                try
                {
                    object obj = rm.Do(objs);
                    if (obj != null)
                    {
                        this.ToMsgPage(obj.ToString());
                    }
                    this.WinClose();
                }
                catch (Exception ex)
                {
                    string msg = "";
                    foreach (object obj in objs)
                    {
                        msg += "@" + obj.ToString();
                    }

                    throw new Exception("@执行[" + ensName + "]期间出现错误:" + ex.Message + "[参数为:]" + msg);
                }
                return;

            case NamesOfBtn.Help:
                //this.Helper();
                break;

            case NamesOfBtn.Close:
                this.WinClose();
                break;

            case NamesOfBtn.Cancel:
                this.WinClose();
                break;

            default:
                throw new Exception("error id" + btn.ID);
            }
        }