예제 #1
0
        private void ReadLayout(BizMainLayout bizWindow, ref string designKey, out string layoutFmt)
        {
            layoutFmt = "";

            //if (listView1.SelectedItems.Count <= 0)
            //{
            //    MessageBox.Show("未选择需要进行设计的窗体,不能读取布局配置。", "提示");
            //    return;
            //}

            ListViewItem[] lvis = listView1.Items.Find(designKey, false);
            if (lvis.Length <= 0)
            {
                MessageBox.Show("未选择需要进行设计的窗体,不能读取布局配置。", "提示");
                return;
            }

            WindowInfoData windowInfo = (lvis[0].Tag as WindowInfoData);

            if (windowInfo == null)
            {
                MessageBox.Show("窗体信息无效,不能读取布局配置。", "提示");
                return;
            }

            layoutFmt = windowInfo.窗体信息.布局配置;
        }
예제 #2
0
        private void butDesign_Click(object sender, EventArgs e)
        {
            try
            {
                if (listView1.SelectedItems.Count <= 0)
                {
                    MessageBox.Show("请选择需要进行设计的窗体。", "提示");
                    return;
                }

                WindowInfoData wid = listView1.SelectedItems[0].Tag as WindowInfoData;
                if (wid == null)
                {
                    MessageBox.Show("窗体信息对象转换无效。", "提示");
                    return;
                }

                bool isMdi = AppSetting.ReadBool("IsMdiWindow", true);


                OpenWindowDesign(wid.窗体ID, isMdi);
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
예제 #3
0
        private void SaveLayout(BizMainLayout bizWindow, string designKey, string layoutFmt)
        {
            //if (listView1.SelectedItems.Count <= 0)
            //{
            //    MessageBox.Show("未选择需要进行设计的窗体,不能保存布局配置。", "提示");
            //    return;
            //}

            ListViewItem[] lvis = listView1.Items.Find(designKey, false);
            if (lvis.Length <= 0)
            {
                MessageBox.Show("未选择需要进行设计的窗体,不能保存布局配置。", "提示");
                return;
            }

            WindowInfoData windowInfo = (lvis[0].Tag as WindowInfoData);

            if (windowInfo == null)
            {
                MessageBox.Show("窗体信息无效,不能保存布局配置。", "提示");
                return;
            }

            windowInfo.版本          = windowInfo.版本 + 1;
            windowInfo.窗体信息.布局配置   = layoutFmt;
            windowInfo.窗体信息.最后更新日期 = DateTime.Now;

            _rwm.UpdateWindowInfo(windowInfo);

            lvis[0].SubItems[2].Text = windowInfo.版本.ToString();
            lvis[0].SubItems[3].Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm");
        }
예제 #4
0
        private void SyncSelRowData()
        {
            try
            {
                ClearData();

                if (listView1.SelectedItems.Count <= 0)
                {
                    return;
                }

                WindowInfoData windowInfo = listView1.SelectedItems[0].Tag as WindowInfoData;
                if (windowInfo == null)
                {
                    MessageBox.Show("未获取到对应的窗体信息。", "提示");
                    return;
                }

                txtWindowName.Text = windowInfo.窗体名称;
                txtWindowName.Tag  = windowInfo.窗体ID;

                cbxWindowGroup.Text = windowInfo.分组标记;

                if (windowInfo.窗体信息 != null)
                {
                    rtbWindowDescription.Text = windowInfo.窗体信息.窗体描述;
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
예제 #5
0
        private void lstRoles_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                ClearWindowChecked();

                if (lstRoles.SelectedItems.Count <= 0)
                {
                    return;
                }

                string windowId = _rwm.GetRoleMainWindowID(lstRoles.SelectedItems[0].Tag.ToString());
                if (string.IsNullOrEmpty(windowId))
                {
                    return;
                }

                foreach (ListViewItem lvi in listView1.Items)
                {
                    WindowInfoData windowInfo = lvi.Tag as WindowInfoData;

                    if (windowInfo.窗体ID.Equals(windowId))
                    {
                        lvi.Checked = true;
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
예제 #6
0
        private void butNew_Click(object sender, EventArgs e)
        {
            try
            {
                if (Verify() == false)
                {
                    return;
                }

                WindowInfoData windowInfo = new WindowInfoData();
                windowInfo.窗体ID      = SqlHelper.GetCmpUID();
                windowInfo.科室ID      = cbxDepartment.SelectedValue.ToString();
                windowInfo.窗体名称      = txtWindowName.Text;
                windowInfo.分组标记      = cbxWindowGroup.Text;
                windowInfo.窗体信息.窗体描述 = rtbWindowDescription.Text;
                windowInfo.窗体信息.创建日期 = _rwm.GetServerDate();

                windowInfo.窗体信息.CopyBasePro(windowInfo);

                _rwm.NewWindow(windowInfo);

                NewView(windowInfo);

                UpdateWindowGroup();

                ButtonHint.Start(sender as Button, "OK");
                //添加后定位焦点
                listView1.Items.Find(windowInfo.窗体ID, false)[0].Selected = true;
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
예제 #7
0
        private void butModify_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtWindowName.Tag == null)
                {
                    MessageBox.Show("请选择需要修改的窗体信息。", "提示");
                    return;
                }


                WindowInfoData windowInfo = GetSelectWindowInfo();
                if (windowInfo == null)
                {
                    MessageBox.Show("未获取到有效的窗体信息。", "提示");
                    return;
                }

                if (Verify(true) == false)
                {
                    return;
                }


                bool isNewGroup = false;
                if (cbxWindowGroup.Text.Equals(windowInfo.分组标记) == false)
                {
                    isNewGroup = true;
                }

                windowInfo.窗体名称      = txtWindowName.Text;
                windowInfo.分组标记      = cbxWindowGroup.Text;
                windowInfo.窗体信息.窗体描述 = rtbWindowDescription.Text;

                windowInfo.窗体信息.CopyBasePro(windowInfo);

                _rwm.UpdateWindowInfo(windowInfo);

                if (isNewGroup)
                {
                    listView1.Items.Remove(listView1.SelectedItems[0]);
                    NewView(windowInfo);
                }
                else
                {
                    listView1.SelectedItems[0].SubItems[0].Text = txtWindowName.Text;
                    listView1.SelectedItems[0].SubItems[1].Text = SqlHelper.Nvl(windowInfo.分组标记, "未分组");
                }

                UpdateWindowGroup();

                ButtonHint.Start(sender as Button, "OK");
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
예제 #8
0
        private void QueryLinkWindow(string designKey, out List <string> names)
        {
            names = new List <string>();

            foreach (ListViewItem lvi in listView1.Items)
            {
                if (lvi.Tag == null)
                {
                    continue;
                }

                WindowInfoData windowInfo = lvi.Tag as WindowInfoData;
                if (windowInfo == null)
                {
                    continue;
                }

                names.Add(windowInfo.窗体名称);
            }
        }
예제 #9
0
        private void NewView(WindowInfoData windowInfo)
        {
            string groupName = SqlHelper.Nvl(windowInfo.分组标记, "未分组");

            ListViewGroup lvgCur = GetCurGroup(groupName);

            if (lvgCur == null)
            {
                lvgCur = new ListViewGroup(groupName);
                listView1.Groups.Add(lvgCur);
            }
            //新增的窗体,最后更新时间为空
            ListViewItem itemNew = new ListViewItem(new string[] { windowInfo.窗体名称, groupName, windowInfo.版本.ToString(), "" }, 0, lvgCur);

            //添加ID赋值,listview定位使用find查找会用到
            itemNew.Name = itemNew.Name = windowInfo.窗体ID;
            itemNew.Tag  = windowInfo;

            listView1.Items.Add(itemNew);

            listView1.View = View.Details;
        }
예제 #10
0
        //static private void LoadAppTitle()
        //{
        //    try
        //    {
        //        Configuration ca = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        //        bool hasKey = ca.AppSettings.Settings.AllKeys.Contains("apptitle");

        //        if (hasKey)
        //        {
        //            _appTitle = ca.AppSettings.Settings["apptitle"].Value;
        //        }
        //    }
        //    catch { }
        //}


        static private void ReadLayout(BizMainLayout bizWindow, ref string designKey, out string layoutFmt)
        {
            layoutFmt = "";

            if (_loginUser == null || _dbHelper == null)
            {
                return;
            }

            RoleWindowModel rwm = new RoleWindowModel(_dbHelper);

            WindowInfoData windowInfo = rwm.GetRoleMainWindowInfo(_loginUser.RoleId);

            if (windowInfo == null)
            {
                MessageBox.Show("窗体配置信息读取失败。", "提示");
                return;
            }

            designKey      = windowInfo.窗体ID;
            bizWindow.Name = "Win_" + windowInfo.窗体ID;
            layoutFmt      = windowInfo.窗体信息.布局配置;
        }
예제 #11
0
        private void OpenWindowDesign(string designKey, bool isMdiStyle)
        {
            ListViewItem[] lvis = listView1.Items.Find(designKey, false);
            if (lvis.Length <= 0)
            {
                MessageBox.Show("未选择需要进行设计的窗体,不能读取布局配置。", "提示");
                return;
            }

            WindowInfoData wid = (lvis[0].Tag as WindowInfoData);

            if (wid == null)
            {
                MessageBox.Show("窗体信息无效,不能读取布局配置。", "提示");
                return;
            }

            StationInfo stationInfo = new StationInfo();

            stationInfo.DBServerName   = (this.Parent.TopLevelControl as frmMainConfig).ServerName;
            stationInfo.DepartmentId   = cbxDepartment.SelectedValue.ToString();
            stationInfo.DepartmentName = cbxDepartment.Text;

            if (isMdiStyle)
            {
                frmDesignParent bmlMdi = new frmDesignParent();


                bmlMdi.SetDesignText(wid.窗体ID, wid.窗体名称);

                //配置事件
                bmlMdi.OnSaveWindowLayout      += SaveLayout;
                bmlMdi.OnReadWindowLayout      += ReadLayout;
                bmlMdi.OnQueryParentWindowName += QueryLinkWindow;
                bmlMdi.OnMdiWindowChange       += MdiWindowChange;

                bmlMdi.Init(_dbHelper, _loginUser, stationInfo, null);

                bmlMdi.Show(this);
            }
            else
            {
                BizMainLayout bmlPopup = new BizMainLayout(true);

                bmlPopup.SetDesignText(wid.窗体ID, wid.窗体名称, null, null);

                //配置事件
                bmlPopup.OnStateSync             += StateSync;
                bmlPopup.OnSaveWindowLayout      += SaveLayout;
                bmlPopup.OnReadWindowLayout      += ReadLayout;
                bmlPopup.OnQueryParentWindowName += QueryLinkWindow;
                bmlPopup.OnMdiWindowChange       += MdiWindowChange;

                bmlPopup.Init(_dbHelper, _loginUser, stationInfo, null);


                bmlPopup.BeforeLoadAssembly();


                bmlPopup.Show(this);
            }
        }
예제 #12
0
        /// <summary>
        /// 绑定窗体信息数据
        /// </summary>
        private void BindWindowData()
        {
            //_isLoadBodypart = true;
            try
            {
                listView1.Clear();
                cbxWindowGroup.Items.Clear();


                DataTable dtWindows = _rwm.GetWindowInfo(cbxDepartment.SelectedValue.ToString());

                foreach (DataColumn dc in dtWindows.Columns)
                {
                    if (("窗体名称,版本").IndexOf(dc.Caption) >= 0)
                    {
                        ColumnHeader columnHeader = new ColumnHeader();
                        columnHeader.Text  = dc.Caption;
                        columnHeader.Name  = dc.Caption;
                        columnHeader.Width = 120;
                        listView1.Columns.Add(columnHeader);
                    }
                    //默认隐藏分组标记,版本列
                    if (("分组标记").IndexOf(dc.Caption) >= 0)
                    {
                        ColumnHeader columnHeader = new ColumnHeader();
                        columnHeader.Text  = dc.Caption;
                        columnHeader.Name  = dc.Caption;
                        columnHeader.Width = 0;
                        listView1.Columns.Add(columnHeader);
                    }
                }
                //添加固定列最后更新日期
                ColumnHeader columnHeaderDate = new ColumnHeader();
                columnHeaderDate.Text  = "最后更新日期";
                columnHeaderDate.Name  = "最后更新日期";
                columnHeaderDate.Width = 120;
                listView1.Columns.Add(columnHeaderDate);

                DataTable dtGroup = _rwm.GetWindowGroups(cbxDepartment.SelectedValue.ToString());

                foreach (DataRow dr in dtGroup.Rows)
                {
                    string groupTag  = dr["分组标记"].ToString();
                    string groupName = SqlHelper.Nvl(groupTag, "未分组");


                    ListViewGroup lvg = new ListViewGroup(groupName);
                    listView1.Groups.Add(lvg);


                    if (cbxWindowGroup.Items.IndexOf(groupTag) < 0)
                    {
                        cbxWindowGroup.Items.Add(groupTag);
                    }
                }


                foreach (DataRow drItem in dtWindows.Rows)
                {
                    WindowInfoData windowInfo = new WindowInfoData();
                    windowInfo.BindRowData(drItem);

                    string        gn      = SqlHelper.Nvl(windowInfo.分组标记, "未分组");
                    ListViewGroup lvgCur  = GetCurGroup(gn);
                    string        sdate   = windowInfo.窗体信息.最后更新日期.Year == 1 ? "" : windowInfo.窗体信息.最后更新日期.ToString("yyyy-MM-dd hh:mm");
                    ListViewItem  itemNew = new ListViewItem(new string[] { windowInfo.窗体名称, gn, windowInfo.版本.ToString(), sdate }, 0, lvgCur);

                    itemNew.Name = windowInfo.窗体ID;

                    itemNew.Tag = windowInfo;

                    listView1.Items.Add(itemNew);
                }

                listView1.View = View.Details;
            }
            finally
            {
                //_isLoadBodypart = false;
            }
        }