Ejemplo n.º 1
0
        void OnFinishClick(object sender, CancelEventArgs e)
        {
            if (chkToXML.Checked)
            {
                #region XML
                FileInfo fileInfo = null;
                try
                {
                    fileInfo = new FileInfo(btnXMLFile.Text);
                }
                catch (Exception ex)
                {
                }

                XmlDocument doc = ABCControls.ABCView.GetEmptyXMLLayout(fileInfo.Name);
                doc.Save(btnXMLFile.Text);
                OwnerStudio.Worker.OpenFromXMLFile(btnXMLFile.Text);
                #endregion
            }

            if (chkToDatabase.Checked)
            {
                #region Database
                STViewGroupsController groupCtrl = new STViewGroupsController();
                STViewGroupsInfo       groupInfo = (STViewGroupsInfo)groupCtrl.GetObjectByNo(lkeGroup.Text);
                if (groupInfo == null)
                {
                    groupInfo      = new STViewGroupsInfo();
                    groupInfo.No   = lkeGroup.Text;
                    groupInfo.Name = lkeGroup.Text;
                    groupCtrl.CreateObject(groupInfo);
                }

                STViewsController viewCtrl = new STViewsController();
                STViewsInfo       viewInfo = (STViewsInfo)viewCtrl.GetObjectByNo(txtViewName.Text);
                if (viewInfo == null)
                {
                    viewInfo                  = new STViewsInfo();
                    viewInfo.STViewNo         = txtViewName.Text;
                    viewInfo.STViewName       = txtViewName.Text;
                    viewInfo.FK_STViewGroupID = groupInfo.STViewGroupID;
                    String strXML = ABCControls.ABCView.GetEmptyXMLLayout(txtViewName.Text).InnerXml;
                    viewInfo.STViewXML = ABCHelper.StringCompressor.CompressString(strXML);

                    viewCtrl.CreateObject(viewInfo);
                }

                OwnerStudio.Worker.OpenFromDatabase(viewInfo);
                OwnerStudio.ViewTreeList.RefreshViewList();
                #endregion
            }
            this.Close();
        }
Ejemplo n.º 2
0
        void ViewExplorer_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e)
        {
            MyData obj = (MyData)this.GetDataRecordByNode(this.FocusedNode);

            if (obj == null || obj.InnerData == null)
            {
                return;
            }


            String strNo = String.Empty;

            if (obj.InnerData is STViewsInfo)
            {
                strNo = (obj.InnerData as STViewsInfo).STViewNo;
            }
            if (obj.InnerData is STViewGroupsInfo)
            {
                strNo = (obj.InnerData as STViewGroupsInfo).No;
            }

            if (strNo == e.Value.ToString())
            {
                this.OptionsBehavior.Editable = false;
                return;
            }



            if (obj.InnerData is STViewsInfo)
            {
                STViewsController viewCtrl = new STViewsController();
                //if ( viewCtrl.GetObjectByNo( e.Value.ToString() )!=null )
                //{
                //    ABCHelper.ABCMessageBox.Show( String.Format( "View Name : '{0}' is already existed. " , e.Value.ToString() ) , "Message" , MessageBoxButtons.OK , MessageBoxIcon.Error );
                //    e.Value=strNo;
                //    this.OptionsBehavior.Editable=false;
                //    return;
                //}
                STViewsInfo info = (STViewsInfo)obj.InnerData;
                if (info != null)
                {
                    info.STViewNo   = e.Value.ToString();
                    info.STViewName = e.Value.ToString();
                    viewCtrl.UpdateObject(info);
                }
            }
            if (obj.InnerData is STViewGroupsInfo)
            {
                STViewGroupsController groupCtrl = new STViewGroupsController();
                //if ( groupCtrl.GetObjectByNo( e.Value.ToString() )!=null )
                //{
                //    ABCHelper.ABCMessageBox.Show( String.Format( "Group Name : '{0}' is already existed. " , e.Value.ToString() ) , "Message" , MessageBoxButtons.OK , MessageBoxIcon.Error );
                //    e.Value=strNo;
                //    this.OptionsBehavior.Editable=false;
                //    return;
                //}
                STViewGroupsInfo info = (STViewGroupsInfo)obj.InnerData;
                if (info != null)
                {
                    info.No   = e.Value.ToString();
                    info.Name = e.Value.ToString();
                    groupCtrl.UpdateObject(info);
                }
            }

            this.OptionsBehavior.Editable = false;
        }
Ejemplo n.º 3
0
        void Menu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            MyData obj = (MyData)this.GetDataRecordByNode(this.FocusedNode);

            STViewGroupsController groupCtrl = new STViewGroupsController();
            STViewsController      viewCtrl  = new STViewsController();

            if (e.Item.Tag != null && e.Item.Tag.ToString() == "Refresh")
            {
                RefreshViewList();
            }

            if (e.Item.Tag != null && e.Item.Tag.ToString() == "NewView" && this.Selection.Count > 0)
            {
                if (obj == null || obj.InnerData == null)
                {
                    return;
                }

                STViewGroupsInfo groupInfo = (STViewGroupsInfo)obj.InnerData;
                if (groupInfo != null)
                {
                    #region Create ViewInfo
                    STViewsInfo viewInfo = new STViewsInfo();
                    viewInfo.FK_STViewGroupID = groupInfo.STViewGroupID;
                    viewInfo.STViewNo         = "View";
                    int i = 0;
                    while (viewCtrl.GetObjectByNo(viewInfo.STViewNo) != null)
                    {
                        viewInfo.STViewNo += i;
                    }
                    viewInfo.STViewName = viewInfo.STViewNo;
                    String strXML = ABCControls.ABCView.GetEmptyXMLLayout(viewInfo.STViewName).InnerXml;
                    viewInfo.STViewXML = ABCHelper.StringCompressor.CompressString(strXML);
                    viewCtrl.CreateObject(viewInfo);

                    #endregion

                    new MyData(obj, new object[] { viewInfo.STViewNo, viewInfo.STViewID }, viewInfo);
                    this.RefreshDataSource();
                }
            }
            if (e.Item.Tag != null && e.Item.Tag.ToString() == "NewGroup" && this.Selection.Count > 0)
            {
                #region Create GroupInfo
                STViewGroupsInfo groupInfo = new STViewGroupsInfo();
                groupInfo.No = "Group";
                int i = 0;
                while (groupCtrl.GetObjectByNo(groupInfo.No) != null)
                {
                    groupInfo.No += i;
                }
                groupInfo.Name = groupInfo.No;
                groupCtrl.CreateObject(groupInfo);

                #endregion

                new MyData(this.DataSource as MyData, new object[] { groupInfo.No, groupInfo.STViewGroupID }, groupInfo);
                this.RefreshDataSource();
            }
            if (e.Item.Tag != null && e.Item.Tag.ToString() == "NewChildGroup" && this.Selection.Count > 0)
            {
                if (obj == null || obj.InnerData == null)
                {
                    return;
                }

                STViewGroupsInfo groupInfo = (STViewGroupsInfo)obj.InnerData;
                if (groupInfo != null)
                {
                    #region Create GroupInfo
                    STViewGroupsInfo newGroupInfo = new STViewGroupsInfo();
                    newGroupInfo.No = "Group";
                    int i = 0;
                    while (groupCtrl.GetObjectByNo(newGroupInfo.No) != null)
                    {
                        newGroupInfo.No += i;
                    }
                    newGroupInfo.Name             = newGroupInfo.No;
                    newGroupInfo.FK_STViewGroupID = groupInfo.STViewGroupID;
                    groupCtrl.CreateObject(newGroupInfo);

                    #endregion

                    new MyData(obj, new object[] { newGroupInfo.No, newGroupInfo.STViewGroupID }, newGroupInfo);
                    this.RefreshDataSource();
                }
            }
            if (e.Item.Tag != null && e.Item.Tag.ToString() == "NewRootGroup")
            {
                #region Create GroupInfo
                STViewGroupsInfo newGroupInfo = new STViewGroupsInfo();
                newGroupInfo.No = "Group";
                int i = 0;
                while (groupCtrl.GetObjectByNo(newGroupInfo.No) != null)
                {
                    newGroupInfo.No += i;
                }
                newGroupInfo.Name = newGroupInfo.No;
                groupCtrl.CreateObject(newGroupInfo);

                #endregion

                new MyData(this.DataSource as MyData, new object[] { newGroupInfo.No, newGroupInfo.STViewGroupID }, newGroupInfo);
                this.RefreshDataSource();
            }
            if (e.Item.Tag != null && (e.Item.Tag.ToString() == "RenameView" || e.Item.Tag.ToString() == "RenameGroup") && this.Selection.Count > 0)
            {
                this.OptionsBehavior.Editable = true;
                this.ShowEditor();
            }

            if (e.Item.Tag != null && e.Item.Tag.ToString() == "OpenView")
            {
                if (obj == null || obj.InnerData == null)
                {
                    return;
                }

                STViewsInfo info = (STViewsInfo) new STViewsController().GetObjectByID(((STViewsInfo)obj.InnerData).GetID());
                if (info == null)
                {
                    return;
                }

                OwnerStudio.Worker.OpenFromDatabase(info);
            }

            if (e.Item.Tag != null && e.Item.Tag.ToString() == "RunView")
            {
                if (obj == null || obj.InnerData == null)
                {
                    return;
                }

                STViewsInfo info = (STViewsInfo) new STViewsController().GetObjectByID(((STViewsInfo)obj.InnerData).GetID());
                if (info == null)
                {
                    return;
                }

                ABCScreen.ABCScreenFactory.RunScreen(info, ViewMode.Test);
            }

            if (e.Item.Tag != null && e.Item.Tag.ToString() == "DeleteView")
            {
                if (obj == null || obj.InnerData == null)
                {
                    return;
                }

                DialogResult result = ABCHelper.ABCMessageBox.Show("Do you want to delete selected View ? ", "Delete View", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    STViewsInfo info = (STViewsInfo)obj.InnerData;
                    viewCtrl.DeleteObject(info.STViewID);
                    obj.parentCore.childrenCore.Remove(obj);
                    obj.parentCore = null;
                    this.RefreshDataSource();
                }
            }

            if (e.Item.Tag != null && e.Item.Tag.ToString() == "DeleteGroup")
            {
                if (obj == null || obj.InnerData == null)
                {
                    return;
                }

                DialogResult result = ABCHelper.ABCMessageBox.Show("Do you want to delete selected Group and all children View ? ", "Delete Group", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    STViewGroupsInfo info = (STViewGroupsInfo)obj.InnerData;
                    viewCtrl.DeleteObjectsByFK("FK_STViewGroupID", info.STViewGroupID);
                    groupCtrl.DeleteObject(info.STViewGroupID);
                    obj.parentCore.childrenCore.Remove(obj);
                    obj.parentCore = null;
                    this.RefreshDataSource();
                }
            }

            if (e.Item.Tag != null && e.Item.Tag.ToString() == "Import" && this.Selection.Count > 0)
            {
                if (obj == null || obj.InnerData == null)
                {
                    return;
                }

                STViewsInfo info = (STViewsInfo) new STViewsController().GetObjectByID(((STViewsInfo)obj.InnerData).GetID());
                if (info == null)
                {
                    return;
                }

                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter           = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
                dlg.FilterIndex      = 0;
                dlg.RestoreDirectory = true;
                dlg.Title            = "Import Layout from XML file";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(dlg.FileName);
                    info.STViewXML = ABCHelper.StringCompressor.CompressString(doc.InnerXml);
                    new STViewsController().UpdateObject(info);
                    ABCHelper.ABCMessageBox.Show("Saved ...!", "Import From XML", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            if (e.Item.Tag != null && e.Item.Tag.ToString() == "Export" && this.Selection.Count > 0)
            {
                if (obj == null || obj.InnerData == null)
                {
                    return;
                }

                STViewsInfo info = (STViewsInfo) new STViewsController().GetObjectByID(((STViewsInfo)obj.InnerData).GetID());
                if (info == null)
                {
                    return;
                }

                SaveFileDialog dlg = new SaveFileDialog();
                dlg.Filter           = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
                dlg.FilterIndex      = 0;
                dlg.RestoreDirectory = true;
                dlg.Title            = "Export Layout to XML file";
                if (dlg.ShowDialog() == DialogResult.OK && !String.IsNullOrWhiteSpace(dlg.FileName))
                {
                    XmlDocument doc           = new XmlDocument();
                    string      strDecompress = ABCHelper.StringCompressor.DecompressString(info.STViewXML);
                    doc.LoadXml(strDecompress);
                    doc.Save(dlg.FileName);
                    ABCHelper.ABCMessageBox.Show("Export ...!", "Export To XML", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }