示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        public BPAttachment(string NoOfObj, string name, string exts, double tbWidth, string _saveTo)
        {
            if (tbWidth < 20)
            {
                tbWidth = 20;
            }

            this.Name = NoOfObj;
            StackPanel sp = new StackPanel();

            sp.Name          = "sp" + NoOfObj;
            sp.Orientation   = Orientation.Horizontal;
            this.HisTB       = new BPTextBox();
            this.HisTB.Name  = "No" + NoOfObj;
            this.HisTB.Width = tbWidth;
            this.Exts        = exts;
            this.SaveTo      = _saveTo;
            sp.Children.Add(this.HisTB);
            Button btn = new Button();

            btn.Name    = "btns" + NoOfObj;
            btn.Content = "浏览-上传-删除";
            sp.Children.Add(btn);
            this.Content = sp;
        }
示例#2
0
        /// <summary>
        /// 获取页面的数据
        /// </summary>
        /// <returns></returns>
        public DataSet GenerFrmDataSet()
        {
            #region  创建数据表.
            DataTable dtMain = new DataTable();
            dtMain.TableName = "Main";
            dtMain.Columns.Add(new DataColumn("KeyOfEn", typeof(string)));
            dtMain.Columns.Add(new DataColumn("Val", typeof(string)));
            #endregion 创建数据表.

            #region 获取主表的值.
            foreach (DataRow dr in dtMapAttrs.Rows)
            {
                if (dr["UIVisible"] == "0")
                {
                    continue;
                }

                if (dr["FK_MapData"] != Glo.FK_MapData)
                {
                    continue;
                }
                DataRow drNew = dtMain.NewRow();

                string keyOfEn = dr["KeyOfEn"];

                UIElement ctl = this.canvasMain.FindName(keyOfEn) as UIElement;
                BPTextBox tb  = ctl as BPTextBox;
                if (tb != null)
                {
                    drNew[0] = keyOfEn;
                    drNew[1] = tb.Text;
                    dtMain.Rows.Add(drNew);
                    continue;
                }

                BPDDL ddl = ctl as BPDDL;
                if (ddl != null)
                {
                    ListBoxItem li = ddl.SelectedItem as ListBoxItem;
                    if (li == null)
                    {
                        throw new Exception("@没有找到选择的item.");
                    }
                    drNew[0] = keyOfEn;
                    drNew[1] = li.Tag.ToString();
                    dtMain.Rows.Add(drNew);
                    continue;
                }

                BPCheckBox cb = ctl as BPCheckBox;
                if (cb != null)
                {
                    drNew[0] = keyOfEn;
                    if (cb.IsChecked == true)
                    {
                        drNew[1] = "1";
                    }
                    else
                    {
                        drNew[1] = "0";
                    }
                    dtMain.Rows.Add(drNew);
                    continue;
                }
            }
            #endregion 获取从表的值.

            DataSet dsNodeData = new DataSet();
            dsNodeData.Tables.Add(dtMain);

#warning 这里仅仅处理了主表的保存,多从表,多m2m,附件,图片。都没有处理。
            return(dsNodeData);
        }
示例#3
0
        /// <summary>
        /// 绑定表单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void BindFrm(object sender, FF.GenerWorkNodeCompletedEventArgs e)
        {
            #region 初始化数据.
            this.canvasMain.Children.Clear();
            this.FrmDS = new DataSet();
            try
            {
                if (e.Result.Length < 200)
                {
                    throw new Exception(e.Result);
                }
                this.FrmDS.FromXml(e.Result);
                loadingWindow.DialogResult = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Err", MessageBoxButton.OK);
                loadingWindow.DialogResult = true;
                return;
            }
            #endregion 初始化数据.

            this.InitToolbar();

            string table = "";
            try
            {
                this.dtMapAttrs = this.FrmDS.Tables["Sys_MapAttr"];
                foreach (DataTable dt in this.FrmDS.Tables)
                {
                    Glo.TempVal = dt.TableName;
                    table       = dt.TableName;
                    switch (dt.TableName)
                    {
                    case "Sys_MapAttr":
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["UIVisible"] == "0")
                            {
                                continue;
                            }

                            if (dr["FK_MapData"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            string myPk          = dr["MyPK"];
                            string FK_MapData    = dr["FK_MapData"];
                            string keyOfEn       = dr["KeyOfEn"];
                            string name          = dr["Name"];
                            string defVal        = dr["DefVal"];
                            string UIContralType = dr["UIContralType"];
                            string MyDataType    = dr["MyDataType"];
                            string lgType        = dr["LGType"];
                            bool   isEnable      = false;
                            if (dr["UIIsEnable"].ToString() == "1")
                            {
                                isEnable = true;
                            }

                            double X = double.Parse(dr["X"]);
                            double Y = double.Parse(dr["Y"]);
                            if (X == 0)
                            {
                                X = 100;
                            }
                            if (Y == 0)
                            {
                                Y = 100;
                            }

                            string UIBindKey = dr["UIBindKey"];
                            switch (UIContralType)
                            {
                            case CtrlType.TextBox:
                                TBType tp = TBType.String;
                                switch (MyDataType)
                                {
                                case DataType.AppInt:
                                    tp = TBType.Int;
                                    break;

                                case DataType.AppFloat:
                                case DataType.AppDouble:
                                    tp = TBType.Float;
                                    break;

                                case DataType.AppMoney:
                                    tp = TBType.Money;
                                    break;

                                case DataType.AppString:
                                    tp = TBType.String;
                                    break;

                                case DataType.AppDateTime:
                                    tp = TBType.DateTime;
                                    break;

                                case DataType.AppDate:
                                    tp = TBType.Date;
                                    break;

                                default:
                                    break;
                                }

                                BPTextBox tb = new BPTextBox(tp);
                                tb.NameOfReal = keyOfEn;
                                tb.Name       = keyOfEn;
                                tb.SetValue(Canvas.LeftProperty, X);
                                tb.SetValue(Canvas.TopProperty, Y);

                                tb.Text  = this.GetValByKey(keyOfEn);        //给控件赋值.
                                tb.Width = double.Parse(dr["UIWidth"]);

                                if (tb.Height > 24)
                                {
                                    tb.TextWrapping = TextWrapping.Wrap;
                                }

                                tb.Height = double.Parse(dr["UIHeight"]);

                                if (isEnable)
                                {
                                    tb.IsEnabled = true;
                                }
                                else
                                {
                                    tb.IsEnabled = false;
                                }
                                this.canvasMain.Children.Add(tb);
                                break;

                            case CtrlType.DDL:
                                BPDDL ddl = new BPDDL();
                                ddl.Name      = keyOfEn;
                                ddl.HisLGType = lgType;
                                ddl.Width     = double.Parse(dr["UIWidth"]);
                                ddl.UIBindKey = UIBindKey;
                                ddl.HisLGType = lgType;
                                if (lgType == LGType.Enum)
                                {
                                    DataTable dtEnum = this.FrmDS.Tables["Sys_Enum"];
                                    foreach (DataRow drEnum in dtEnum.Rows)
                                    {
                                        if (drEnum["EnumKey"].ToString() != UIBindKey)
                                        {
                                            continue;
                                        }

                                        ListBoxItem li = new ListBoxItem();
                                        li.Tag     = drEnum["IntKey"].ToString();
                                        li.Content = drEnum["Lab"].ToString();
                                        ddl.Items.Add(li);
                                    }
                                    if (ddl.Items.Count == 0)
                                    {
                                        throw new Exception("@没有从Sys_Enum中找到编号为(" + UIBindKey + ")的枚举值。");
                                    }
                                }
                                else
                                {
                                    ddl.BindEns(UIBindKey);
                                }

                                ddl.SetValue(Canvas.LeftProperty, X);
                                ddl.SetValue(Canvas.TopProperty, Y);

                                //给控件赋值.
                                ddl.SetSelectVal(this.GetValByKey(keyOfEn));

                                this.canvasMain.Children.Add(ddl);
                                break;

                            case CtrlType.CheckBox:
                                BPCheckBox cb = new BPCheckBox();
                                cb.Name    = keyOfEn;
                                cb.Content = name;

                                Label cbLab = new Label();
                                cbLab.Name    = "CBLab" + cb.Name;
                                cbLab.Content = name;
                                cbLab.Tag     = keyOfEn;
                                cb.Content    = cbLab;

                                cb.SetValue(Canvas.LeftProperty, X);
                                cb.SetValue(Canvas.TopProperty, Y);

                                if (this.GetValByKey(keyOfEn) == "1")
                                {
                                    cb.IsChecked = true;
                                }
                                else
                                {
                                    cb.IsChecked = false;
                                }
                                this.canvasMain.Children.Add(cb);
                                break;

                            case CtrlType.RB:
                                break;

                            default:
                                break;
                            }
                        }
                        continue;

                    case "Sys_FrmRB":
                        DataTable dtRB = this.FrmDS.Tables["Sys_FrmRB"];
                        foreach (DataRow dr in dtRB.Rows)
                        {
                            if (dr["FK_MapData"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            BPRadioBtn btn = new BPRadioBtn();
                            btn.Name      = dr["MyPK"];
                            btn.GroupName = dr["KeyOfEn"];
                            btn.Content   = dr["Lab"];
                            btn.UIBindKey = dr["EnumKey"];
                            btn.Tag       = dr["IntKey"];
                            btn.SetValue(Canvas.LeftProperty, double.Parse(dr["X"].ToString()));
                            btn.SetValue(Canvas.TopProperty, double.Parse(dr["Y"].ToString()));
                            this.canvasMain.Children.Add(btn);
                        }
                        continue;

                    case "Sys_MapDtl":
                        foreach (DataRow dr in dt.Rows)
                        {
                            BPDtl dtl = new BPDtl(dr["No"], this.FrmDS);
                            dtl.SetValue(Canvas.LeftProperty, double.Parse(dr["X"]));
                            dtl.SetValue(Canvas.TopProperty, double.Parse(dr["Y"]));
                            dtl.Width  = double.Parse(dr["W"]);
                            dtl.Height = double.Parse(dr["H"]);
                            this.canvasMain.Children.Add(dtl);
                        }
                        continue;

                    case "Sys_FrmEle":
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["FK_MapData"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            BPEle img = new BPEle();
                            img.Name    = dr["MyPK"].ToString();
                            img.EleType = dr["EleType"].ToString();
                            img.EleName = dr["EleName"].ToString();
                            img.EleID   = dr["EleID"].ToString();

                            img.Cursor = Cursors.Hand;
                            img.SetValue(Canvas.LeftProperty, double.Parse(dr["X"].ToString()));
                            img.SetValue(Canvas.TopProperty, double.Parse(dr["Y"].ToString()));

                            img.Width  = double.Parse(dr["W"].ToString());
                            img.Height = double.Parse(dr["H"].ToString());
                            this.canvasMain.Children.Add(img);
                        }
                        continue;

                    case "Sys_MapData":
                        if (dt.Rows.Count == 0)
                        {
                            continue;
                        }
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["No"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            Glo.HisMapData      = new MapData();
                            Glo.HisMapData.FrmH = double.Parse(dt.Rows[0]["FrmH"]);
                            Glo.HisMapData.FrmW = double.Parse(dt.Rows[0]["FrmW"]);
                            Glo.HisMapData.No   = (string)dt.Rows[0]["No"];
                            Glo.HisMapData.Name = (string)dt.Rows[0]["Name"];
                            // Glo.IsDtlFrm = false;
                            this.canvasMain.Width    = Glo.HisMapData.FrmW;
                            this.canvasMain.Height   = Glo.HisMapData.FrmH;
                            this.scrollViewer1.Width = Glo.HisMapData.FrmW;
                        }
                        break;

                    case "Sys_FrmBtn":
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["FK_MapData"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            BPBtn btn = new BPBtn();
                            btn.Name         = dr["MyPK"];
                            btn.Content      = dr["Text"].Replace("&nbsp;", " ");
                            btn.HisBtnType   = (BtnType)int.Parse(dr["BtnType"]);
                            btn.HisEventType = (EventType)int.Parse(dr["EventType"]);

                            if (dr["EventContext"] != null)
                            {
                                btn.EventContext = dr["EventContext"].Replace("~", "'");
                            }

                            if (dr["MsgErr"] != null)
                            {
                                btn.MsgErr = dr["MsgErr"].Replace("~", "'");
                            }

                            if (dr["MsgOK"] != null)
                            {
                                btn.MsgOK = dr["MsgOK"].Replace("~", "'");
                            }

                            btn.SetValue(Canvas.LeftProperty, double.Parse(dr["X"]));
                            btn.SetValue(Canvas.TopProperty, double.Parse(dr["Y"]));
                            this.canvasMain.Children.Add(btn);
                        }
                        continue;

                    case "Sys_FrmLine":
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["FK_MapData"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            string color = dr["BorderColor"];
                            if (string.IsNullOrEmpty(color))
                            {
                                color = "Black";
                            }

                            BPLine myline = new BPLine(dr["MyPK"], color, double.Parse(dr["BorderWidth"]),
                                                       double.Parse(dr["X1"]), double.Parse(dr["Y1"]), double.Parse(dr["X2"]),
                                                       double.Parse(dr["Y2"]));

                            myline.SetValue(Canvas.LeftProperty, double.Parse(dr["X"]));
                            myline.SetValue(Canvas.TopProperty, double.Parse(dr["Y"]));
                            this.canvasMain.Children.Add(myline);
                        }
                        continue;

                    case "Sys_FrmLab":
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["FK_MapData"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            BPLabel lab = new BPLabel();
                            lab.Name = dr["MyPK"];
                            string text = dr["Text"].Replace("&nbsp;", " ");
                            text         = text.Replace("@", "\n");
                            lab.Content  = text;
                            lab.FontSize = double.Parse(dr["FontSize"]);
                            lab.Cursor   = Cursors.Hand;
                            lab.SetValue(Canvas.LeftProperty, double.Parse(dr["X"]));
                            lab.SetValue(Canvas.TopProperty, double.Parse(dr["Y"]));

                            if (dr["IsBold"] == "1")
                            {
                                lab.FontWeight = FontWeights.Bold;
                            }
                            else
                            {
                                lab.FontWeight = FontWeights.Normal;
                            }

                            string color = dr["FontColor"];
                            lab.Foreground = new SolidColorBrush(Glo.ToColor(color));
                            this.canvasMain.Children.Add(lab);
                        }
                        continue;

                    case "Sys_FrmLink":
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["FK_MapData"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            BPLink link = new BPLink();
                            link.Name    = dr["MyPK"];
                            link.Content = dr["Text"];
                            link.URL     = dr["URL"];

                            link.WinTarget = dr["Target"];

                            link.FontSize = double.Parse(dr["FontSize"]);
                            link.Cursor   = Cursors.Hand;
                            link.SetValue(Canvas.LeftProperty, double.Parse(dr["X"]));
                            link.SetValue(Canvas.TopProperty, double.Parse(dr["Y"]));

                            string color = dr["FontColor"];
                            if (string.IsNullOrEmpty(color))
                            {
                                color = "Black";
                            }

                            link.Foreground = new SolidColorBrush(Glo.ToColor(color));
                            this.canvasMain.Children.Add(link);
                        }
                        continue;

                    case "Sys_FrmImg":
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["FK_MapData"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            BPImg img = new BPImg();
                            img.Name   = dr["MyPK"];
                            img.Cursor = Cursors.Hand;
                            img.SetValue(Canvas.LeftProperty, double.Parse(dr["X"].ToString()));
                            img.SetValue(Canvas.TopProperty, double.Parse(dr["Y"].ToString()));

                            img.Width  = double.Parse(dr["W"].ToString());
                            img.Height = double.Parse(dr["H"].ToString());
                            this.canvasMain.Children.Add(img);
                        }
                        continue;

                    case "Sys_FrmImgAth":
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["FK_MapData"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            BPImgAth ath = new BPImgAth();
                            ath.Name   = dr["MyPK"];
                            ath.Cursor = Cursors.Hand;
                            ath.SetValue(Canvas.LeftProperty, double.Parse(dr["X"].ToString()));
                            ath.SetValue(Canvas.TopProperty, double.Parse(dr["Y"].ToString()));

                            ath.Height = double.Parse(dr["H"].ToString());
                            ath.Width  = double.Parse(dr["W"].ToString());
                            this.canvasMain.Children.Add(ath);
                        }
                        continue;

                    case "Sys_MapM2M":
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["FK_MapData"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            BPM2M m2m = new BPM2M(dr["NoOfObj"]);
                            m2m.SetValue(Canvas.LeftProperty, double.Parse(dr["X"]));
                            m2m.SetValue(Canvas.TopProperty, double.Parse(dr["Y"]));

                            m2m.Width  = double.Parse(dr["W"]);
                            m2m.Height = double.Parse(dr["H"]);
                            this.canvasMain.Children.Add(m2m);
                        }
                        continue;

                    case "Sys_FrmAttachment":
                        foreach (DataRow dr in dt.Rows)
                        {
                            if (dr["FK_MapData"] != Glo.FK_MapData)
                            {
                                continue;
                            }

                            string uploadTypeInt = dr["UploadType"].ToString();
                            if (uploadTypeInt == null)
                            {
                                uploadTypeInt = "0";
                            }

                            AttachmentUploadType uploadType = (AttachmentUploadType)int.Parse(uploadTypeInt);
                            if (uploadType == AttachmentUploadType.Single)
                            {
                                BPAttachment ath = new BPAttachment(dr["NoOfObj"],
                                                                    dr["Name"], dr["Exts"],
                                                                    double.Parse(dr["W"]), dr["SaveTo"].ToString());

                                ath.SetValue(Canvas.LeftProperty, double.Parse(dr["X"]));
                                ath.SetValue(Canvas.TopProperty, double.Parse(dr["Y"]));

                                ath.Label  = dr["Name"] as string;
                                ath.Exts   = dr["Exts"] as string;
                                ath.SaveTo = dr["SaveTo"] as string;

                                ath.X = double.Parse(dr["X"]);
                                ath.Y = double.Parse(dr["Y"]);

                                if (dr["IsUpload"] == "1")
                                {
                                    ath.IsUpload = true;
                                }
                                else
                                {
                                    ath.IsUpload = false;
                                }

                                if (dr["IsDelete"] == "1")
                                {
                                    ath.IsDelete = true;
                                }
                                else
                                {
                                    ath.IsDelete = false;
                                }

                                if (dr["IsDownload"] == "1")
                                {
                                    ath.IsDownload = true;
                                }
                                else
                                {
                                    ath.IsDownload = false;
                                }

                                this.canvasMain.Children.Add(ath);
                                continue;
                            }

                            if (uploadType == AttachmentUploadType.Multi)
                            {
                                BPAttachmentM athM = new BPAttachmentM();
                                athM.SetValue(Canvas.LeftProperty, double.Parse(dr["X"]));
                                athM.SetValue(Canvas.TopProperty, double.Parse(dr["Y"]));
                                athM.Name   = dr["NoOfObj"];
                                athM.Width  = double.Parse(dr["W"]);
                                athM.Height = double.Parse(dr["H"]);
                                athM.X      = double.Parse(dr["X"]);
                                athM.Y      = double.Parse(dr["Y"]);
                                athM.SaveTo = dr["SaveTo"];
                                athM.Text   = dr["Name"];
                                athM.Label  = dr["Name"];
                                this.canvasMain.Children.Add(athM);
                                continue;
                            }
                        }
                        continue;

                    default:
                        break;
                    }
                }
                loadingWindow.DialogResult = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("err:" + table, ex.Message + " " + ex.StackTrace,
                                MessageBoxButton.OK);
            }
            this.SetGridLines();
        }