예제 #1
0
 private ClientParam GetClientParams()
 {
     ClientParam cParam = new ClientParam();
     cParam.FolderName = string.IsNullOrEmpty(tbAddToNewFolder.Text) ? cbAddToExistFolder.Text : tbAddToNewFolder.Text;
     cParam.FormName = tbFormName.Text;
     cParam.FormTitle = tbFormTitle.Text;
     cParam.IsMasterDetails = cbIsMasterDetails.Checked;
     cParam.ProviderName = tbProviderName.Text;
     cParam.TableName = tbTableName.Text;
     cParam.RealTableName = tbTableNameF.Text;
     cParam.ChildTableName = tbChildTableName.Text;
     cParam.SelectAlias = this.cmbSelectAlias.Text;
     cParam.ClientType = (ClientType)this.cmbDataBaseType.SelectedIndex;
     cParam.RptFileName = txtRptFileName.Text;
     if (cParam.IsMasterDetails)
     {
         if (tbChildTableName.Text != "")
         {
             string[] DetailTableName = tbChildTableName.Text.Split(',');
             cParam.DetailProviderName = cParam.ProviderName.Substring(0, cParam.ProviderName.IndexOf('.')) + "." + DetailTableName[0];
         }
     }
     return cParam;
 }
예제 #2
0
        private void GenDetailGridView(ClientParam cParam)
        {
            #if VS90
            object oDetail = FDesignerDocument.webControls.item("Detail", 0);

            WebDevPage.IHTMLElement eDetail = null;
            WebDevPage.IHTMLElement eWebGridView1 = null;

            if (oDetail == null || !(oDetail is WebDevPage.IHTMLElement))
                return;
            eDetail = (WebDevPage.IHTMLElement)oDetail;
            eDetail.setAttribute("DataMember", cParam.ChildTableName, 0);

            object oWebGridView1 = FDesignerDocument.webControls.item("wgvDetail", 0);
            eWebGridView1 = (WebDevPage.IHTMLElement)oWebGridView1;
            eWebGridView1.setAttribute("DataSourceID", "Detail", 0);
            //eWebGridView1.setAttribute("DataMember", BlockItem.TableName, 0);

            //这里本来想再往下找Columns节点的,可是找不到,只能先这样写了
            StringBuilder sb = new StringBuilder(eWebGridView1.innerHTML);
            int idx = eWebGridView1.innerHTML.IndexOf("</Columns>");
            List<string> KeyFields = new List<string>();
            AddNewRowControlCollection controls = new AddNewRowControlCollection(null, typeof(AddNewRowControlItem));
            foreach (DataRow dr in SelectedDetailFields.Rows)
            {
                idx = sb.ToString().IndexOf("</Columns>");
                sb.Insert(idx, "\r            <asp:BoundField DataField=\"" + dr["ColumnName"].ToString() + "\" HeaderText=\"" + (string.IsNullOrEmpty(dr["Caption"].ToString()) ? dr["ColumnName"].ToString() : dr["Caption"].ToString()) + "\" SortExpression=\"" + dr["ColumnName"].ToString() + "\" />\r\n            ");
            }
            eWebGridView1.innerHTML = sb.ToString();
            #else
            WebDataSource Detail = (WebDataSource)FPage.FindControl("Detail");
            Detail.DataMember = cParam.ChildTableName;
            IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
            FComponentChangeService.OnComponentChanged(Detail, null, "", "M");
            WebGridView wgvDetail = (WebGridView)FPage.FindControl("wgvDetail");
            wgvDetail.Columns.Clear();

            //GridView
            if (wgvDetail != null)
            {
                foreach (DataRow dr in SelectedDetailFields.Rows)
                {
                    System.Web.UI.WebControls.BoundField aBoundField = new System.Web.UI.WebControls.BoundField();
                    aBoundField.DataField = dr["ColumnName"].ToString();
                    aBoundField.HeaderText = dr["Caption"].ToString();
                    aBoundField.SortExpression = dr["ColumnName"].ToString();
                    if (aBoundField.HeaderText == "")
                        aBoundField.HeaderText = dr["ColumnName"].ToString();
                    wgvDetail.Columns.Add(aBoundField);
                }
            }

            FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
            FComponentChangeService.OnComponentChanged(wgvDetail, null, "", "M");
            #endif
        }
예제 #3
0
        private void GenEasilyReport(ClientParam cParam)
        {
            Object aEasilyReport = FRootForm.Container.Components["easilyreport1"];
            if (this.cbTemplate.Text == "CEasilyReportSingle1")
            {
                Type bindingSourceItemType = aEasilyReport.GetType().GetProperty("DataSource").PropertyType.GetProperty("Item").PropertyType;
                object aBindingSourceItem = Activator.CreateInstance(bindingSourceItemType);
                aBindingSourceItem.GetType().GetProperty("BindingSource").SetValue(aBindingSourceItem, FRootForm.Container.Components["ibs" + cParam.TableName], null);

                IList iDataSource = aEasilyReport.GetType().GetProperty("DataSource").GetValue(aEasilyReport, null) as IList;
                iDataSource.Add(aBindingSourceItem);

                aEasilyReport.GetType().GetProperty("ReportID").SetValue(aEasilyReport, cParam.FormName, null);
                aEasilyReport.GetType().GetProperty("ReportName").SetValue(aEasilyReport, cParam.FormTitle, null);

                DataTable dt = ((DataView)(FRootForm.Container.Components["ibs" + cParam.TableName] as InfoBindingSource).List).Table;

                Type datasourceItemType = aEasilyReport.GetType().GetProperty("FieldItems").PropertyType.GetProperty("Item").PropertyType;//找出DataSourceItem的类型
                object dataSourceItem = Activator.CreateInstance(datasourceItemType);//创建DataSourceItem类型的实例

                IList iDataSourceItemFields = null;
                foreach (DataRow dr in SelectedMasterFields.Rows)
                {
                    Type fieldsType = aEasilyReport.GetType().Assembly.GetType("Infolight.EasilyReportTools.FieldItem");//找出FieldItem的类型
                    object fieldsItem = Activator.CreateInstance(fieldsType);//创建FieldItem类型的实例

                    fieldsItem.GetType().GetProperty("ColumnName").SetValue(fieldsItem, dr["ColumnName"].ToString(), null);
                    fieldsItem.GetType().GetProperty("Caption").SetValue(fieldsItem, dr["Caption"].ToString(), null);
                    if (dr["Caption"].ToString() == String.Empty)
                        fieldsItem.GetType().GetProperty("Caption").SetValue(fieldsItem, dr["ColumnName"].ToString(), null);
                    fieldsItem.GetType().GetProperty("Width").SetValue(fieldsItem, Convert.ToInt32(dr["Width"]), null);

                    if (CheckNum(dt, dr["ColumnName"].ToString()))
                    {
                        fieldsItem.GetType().GetProperty("CaptionAlignment").SetValue(fieldsItem, HorizontalAlignment.Right, null);
                        fieldsItem.GetType().GetProperty("ColumnAlignment").SetValue(fieldsItem, HorizontalAlignment.Right, null);
                    }

                    iDataSourceItemFields = dataSourceItem.GetType().GetProperty("Fields").GetValue(dataSourceItem, null) as IList;//得到一个FieldItemCollection
                    iDataSourceItemFields.Add(fieldsItem);
                }

                foreach (DataRow dr in SelectedMasterGroups.Rows)
                {
                    for (int i = 0; i < iDataSourceItemFields.Count; i++)
                    {
                        String iFieldsColumnName = iDataSourceItemFields[i].GetType().GetProperty("ColumnName").GetValue(iDataSourceItemFields[i], null).ToString();
                        if (iFieldsColumnName == dr["ColumnName"].ToString())
                        {
                            //item.Order = Infolight.EasilyReportTools.FieldItem.OrderType.Ascend;
                            iDataSourceItemFields[i].GetType().GetProperty("Order").SetValue(iDataSourceItemFields[i], iDataSourceItemFields[i].GetType().GetProperty("Order").PropertyType.GetField("Ascend").GetValue(iDataSourceItemFields[i]), null);
                            //item.Group = Infolight.EasilyReportTools.FieldItem.GroupType.Normal;
                            iDataSourceItemFields[i].GetType().GetProperty("Group").SetValue(iDataSourceItemFields[i], iDataSourceItemFields[i].GetType().GetProperty("Group").PropertyType.GetField("Normal").GetValue(iDataSourceItemFields[i]), null);
                        }
                    }
                }

                IList iFieldItems = aEasilyReport.GetType().GetProperty("FieldItems").GetValue(aEasilyReport, null) as IList;
                iFieldItems.Add(dataSourceItem);
            }
            else if (this.cbTemplate.Text == "CEasilyReportMasterDetail1")
            {
                aEasilyReport.GetType().GetProperty("HeaderBindingSource").SetValue(aEasilyReport, FRootForm.Container.Components["ibs" + cParam.TableName], null);

                Type bindingSourceItemType = aEasilyReport.GetType().GetProperty("DataSource").PropertyType.GetProperty("Item").PropertyType;
                object aBindingSourceItem = Activator.CreateInstance(bindingSourceItemType);
                aBindingSourceItem.GetType().GetProperty("BindingSource").SetValue(aBindingSourceItem, FRootForm.Container.Components["ibs" + cParam.ChildTableName], null);

                IList iDataSource = aEasilyReport.GetType().GetProperty("DataSource").GetValue(aEasilyReport, null) as IList;
                iDataSource.Add(aBindingSourceItem);

                aEasilyReport.GetType().GetProperty("ReportID").SetValue(aEasilyReport, cParam.FormName, null);
                aEasilyReport.GetType().GetProperty("ReportName").SetValue(aEasilyReport, cParam.FormTitle, null);

                DataTable dt = ((InfoDataSet)(FRootForm.Container.Components["ibs" + cParam.TableName] as InfoBindingSource).DataSource).RealDataSet.Tables[cParam.ChildTableName];

                int i = 0;
                foreach (DataRow dr in SelectedMasterFields.Rows)
                {
                    i++;

                    Type reportDataSourceItemType = aEasilyReport.GetType().Assembly.GetType("Infolight.EasilyReportTools.ReportDataSourceItem");
                    object aReportDataSourceItem = Activator.CreateInstance(reportDataSourceItemType);
                    if ((i - 1) % 2 == 0)
                    {
                        aReportDataSourceItem.GetType().GetProperty("NewLine").SetValue(aReportDataSourceItem, true, null);
                        aReportDataSourceItem.GetType().GetProperty("Cells").SetValue(aReportDataSourceItem, 2, null);
                    }
                    else
                    {
                        aReportDataSourceItem.GetType().GetProperty("Cells").SetValue(aReportDataSourceItem, 0, null);
                    }
                    aReportDataSourceItem.GetType().GetProperty("ColumnName").SetValue(aReportDataSourceItem, dr["ColumnName"].ToString(), null);
                    if (dr["Caption"].ToString() == String.Empty)
                        aReportDataSourceItem.GetType().GetProperty("Format").SetValue(aReportDataSourceItem, dr["ColumnName"].ToString() + ": {0}", null);
                    else
                        aReportDataSourceItem.GetType().GetProperty("Format").SetValue(aReportDataSourceItem, dr["Caption"].ToString() + ": {0}", null);

                    IList iHeaderItems = aEasilyReport.GetType().GetProperty("HeaderItems").GetValue(aEasilyReport, null) as IList;
                    iHeaderItems.Add(aReportDataSourceItem);
                }

                Type datasourceItemType = aEasilyReport.GetType().GetProperty("FieldItems").PropertyType.GetProperty("Item").PropertyType;//找出DataSourceItem的类型
                object dataSourceItem = Activator.CreateInstance(datasourceItemType);//创建DataSourceItem类型的实例

                IList iDataSourceItemFields = null;
                foreach (DataRow dr in SelectedDetailFields.Rows)
                {
                    Type fieldsType = aEasilyReport.GetType().Assembly.GetType("Infolight.EasilyReportTools.FieldItem");//找出FieldItem的类型
                    object fieldsItem = Activator.CreateInstance(fieldsType);//创建FieldItem类型的实例
                    fieldsItem.GetType().GetProperty("ColumnName").SetValue(fieldsItem, dr["ColumnName"].ToString(), null);
                    fieldsItem.GetType().GetProperty("Caption").SetValue(fieldsItem, dr["Caption"].ToString(), null);
                    if (dr["Caption"].ToString() == String.Empty)
                        fieldsItem.GetType().GetProperty("Caption").SetValue(fieldsItem, dr["ColumnName"].ToString(), null);
                    fieldsItem.GetType().GetProperty("Width").SetValue(fieldsItem, Convert.ToInt32(dr["Width"]), null);

                    if (CheckNum(dt, dr["ColumnName"].ToString()))
                    {
                        fieldsItem.GetType().GetProperty("CaptionAlignment").SetValue(fieldsItem, HorizontalAlignment.Right, null);
                        fieldsItem.GetType().GetProperty("ColumnAlignment").SetValue(fieldsItem, HorizontalAlignment.Right, null);
                    }

                    iDataSourceItemFields = dataSourceItem.GetType().GetProperty("Fields").GetValue(dataSourceItem, null) as IList;//得到一个FieldItemCollection
                    iDataSourceItemFields.Add(fieldsItem);
                }

                foreach (DataRow dr in SelectedDetailGroups.Rows)
                {
                    for (int j = 0; j < iDataSourceItemFields.Count; j++)
                    {
                        String iFieldsColumnName = iDataSourceItemFields[j].GetType().GetProperty("ColumnName").GetValue(iDataSourceItemFields[j], null).ToString();
                        if (iFieldsColumnName == dr["ColumnName"].ToString())
                        {
                            //item.Order = Infolight.EasilyReportTools.FieldItem.OrderType.Ascend;
                            iDataSourceItemFields[j].GetType().GetProperty("Order").SetValue(iDataSourceItemFields[j], iDataSourceItemFields[j].GetType().GetProperty("Order").PropertyType.GetField("Ascend").GetValue(iDataSourceItemFields[j]), null);
                            //item.Group = Infolight.EasilyReportTools.FieldItem.GroupType.Normal;
                            iDataSourceItemFields[j].GetType().GetProperty("Group").SetValue(iDataSourceItemFields[j], iDataSourceItemFields[j].GetType().GetProperty("Group").PropertyType.GetField("Normal").GetValue(iDataSourceItemFields[j]), null);
                        }
                    }
                }

                IList iFieldItems = aEasilyReport.GetType().GetProperty("FieldItems").GetValue(aEasilyReport, null) as IList;
                iFieldItems.Add(dataSourceItem);
            }
        }
예제 #4
0
        public static void GenDataSet(Project GlobalProject, ClientParam cParam, WinClientParam winParam, IDesignerHost FDesignerHost)
        {
            InfoDataSet FDataSet = FDesignerHost.CreateComponent(typeof(InfoDataSet), "id" + cParam.TableName) as InfoDataSet;
            FDataSet.RemoteName = cParam.ProviderName;
            FDataSet.Active = true;
            FDataSet.AlwaysClose = true;

            InfoBindingSource MainBindingSource = FDesignerHost.CreateComponent(typeof(InfoBindingSource), "ibs" + cParam.TableName) as InfoBindingSource;
            MainBindingSource.DataSource = FDataSet;
            MainBindingSource.DataMember = FDataSet.RealDataSet.Tables[0].TableName;

            WinCreateXSD(GlobalProject, FDataSet, cParam, winParam);
        }
예제 #5
0
 private void GenBlock(ClientParam cp)
 {
     if (this.cbTemplate.Text == "WebEasilyReportSingle")
     {
         SetSelectedMasterFields(cp);
         SetSelectedMasterGroups(cp);
         GenMasterGridView(cp);
     }
     else if (this.cbTemplate.Text == "WebEasilyReportMasterDetail1")
     {
         SetSelectedMasterFields(cp);
         SetSelectedMasterGroups(cp);
         SetSelectedDetailFields(cp);
         SetSelectedDetailGroups(cp);
         GenMasterFormView(cp);
         GenDetailGridView(cp);
     }
 }
예제 #6
0
 public void GenWebQuery(ClientParam cParam)
 {
     List<TBlockFieldItem> listfield = SetFields(cParam);
     foreach (TBlockFieldItem aFieldItem in listfield)
     {
         CreateWebQueryField(aFieldItem, "", true);
     }
 }
예제 #7
0
        public void GenWebDataSet(ProjectItem projItem, ClientParam cParam, bool isMasterDetails)
        {
            //NotifyRefresh(1000);
            NotifyRefresh(1000);
            //WebDataSet
            string Path = projItem.get_FileNames(0);
            String lan = GetLanguage();
            string FileName = System.IO.Path.GetFileNameWithoutExtension(Path) + ".aspx" + lan;
            Path = System.IO.Path.GetDirectoryName(Path);
            FileName = Path + "\\" + FileName;
            if (!File.Exists(FileName))
                return;
            System.IO.StreamReader SR = new System.IO.StreamReader(FileName);
            string Context = SR.ReadToEnd();
            SR.Close();

            if (lan == String.Empty || lan == ".cs")
            {
                Context = Context.Replace("this.WMaster.RemoteName = null;", "this.WMaster.RemoteName = \"" + cParam.ProviderName + "\";");
                Context = Context.Replace("this.WMaster.Active = false;", "this.WMaster.Active = true;");

                if (isMasterDetails)
                {
                    Context = Context.Replace("this.WDetail.RemoteName = null;", "this.WDetail.RemoteName = \"" + cParam.DetailProviderName + "\";");
                    Context = Context.Replace("this.WDetail.Active = false;", "this.WDetail.Active = true;");
                    Context = Context.Replace("\"NewDataSet_\"", "\"NewDataSet_" + cParam.DetailProviderName.Substring(cParam.DetailProviderName.IndexOf('.') + 1, cParam.DetailProviderName.Length - cParam.DetailProviderName.IndexOf('.') - 1) + "\"");
                }
            }
            else if (lan == ".vb")
            {
                Context = Context.Replace("Me.WMaster.RemoteName = Nothing", "Me.WMaster.RemoteName = \"" + cParam.ProviderName + "\"");
                Context = Context.Replace("Me.WMaster.Active = False", "Me.WMaster.Active = True");

                if (isMasterDetails)
                {
                    Context = Context.Replace("Me.WDetail.RemoteName = Nothing", "Me.WDetail.RemoteName = \"" + cParam.DetailProviderName + "\"");
                    Context = Context.Replace("Me.WDetail.Active = False", "Me.WDetail.Active = True");
                    Context = Context.Replace("\"NewDataSet_\"", "\"NewDataSet_" + cParam.DetailProviderName.Substring(cParam.DetailProviderName.IndexOf('.') + 1, cParam.DetailProviderName.Length - cParam.DetailProviderName.IndexOf('.') - 1) + "\"");
                }
            }

            System.IO.FileStream Filefs = new System.IO.FileStream(FileName, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite);
            System.IO.StreamWriter SW = new System.IO.StreamWriter(Filefs, Encoding.UTF8);
            SW.Write(Context);
            SW.Close();
            Filefs.Close();
            //WebDataSource Master
            NotifyRefresh(1000);

            //GetSchema
            if (WizardDataSet != null)
                WizardDataSet.Dispose();
            WizardDataSet = new InfoDataSet(true);
            WizardDataSet.RemoteName = cParam.ProviderName;
            WizardDataSet.Active = true;
            WizardDataSet.ServerModify = false;
            WizardDataSet.PacketRecords = 100;
            WizardDataSet.AlwaysClose = true;

            if (isMasterDetails)
            {
                if (WizardDetailDataSet != null)
                    WizardDetailDataSet.Dispose();
                WizardDetailDataSet = new InfoDataSet(true);
                WizardDetailDataSet.RemoteName = cParam.DetailProviderName;
                WizardDetailDataSet.Active = true;
                WizardDetailDataSet.ServerModify = false;
                WizardDetailDataSet.PacketRecords = 100;
                WizardDetailDataSet.AlwaysClose = false;
            }

            #if VS90
            object oMaster = FDesignerDocument.webControls.item("Master", 0);
            if (oMaster != null && oMaster is WebDevPage.IHTMLElement)
            {
                ((WebDevPage.IHTMLElement)oMaster).setAttribute("DataMember", cParam.TableName, 0);
            }

            if (isMasterDetails)
            {
                object oDetail = FDesignerDocument.webControls.item("Detail", 0);
                if (oDetail != null && oDetail is WebDevPage.IHTMLElement)
                {
                    ((WebDevPage.IHTMLElement)oDetail).setAttribute("DataMember", (cParam.ChildTableName.Split(','))[0], 0);
                }
            }

            WebClientCreator.SaveWebDataSet(WizardDataSet, WizardDetailDataSet, projItem);
            #else
            WebDataSource Master = (WebDataSource)FPage.FindControl("Master");
            Master.DataMember = cParam.TableName;
            IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
            FComponentChangeService.OnComponentChanged(Master, null, "", "M");

            if (isMasterDetails)
            {
                WebDataSource Detail = (WebDataSource)FPage.FindControl("Detail");
                string[] DetailTableName = cParam.ChildTableName.Split(',');
                Detail.DataMember = DetailTableName[0];
                FComponentChangeService.OnComponentChanged(Detail, null, "", "M");
            }
            WebClientCreator.SaveWebDataSet(WizardDataSet, WizardDetailDataSet, projItem);
            #endif
        }
예제 #8
0
        private void GenMasterSingle1(ClientParam cParam)
        {
            IComponent aDataSet = FRootForm.Container.Components["Query"];
            if (aDataSet != null)
                FDesignerHost.DestroyComponent(aDataSet);
            IComponent aSource = FRootForm.Container.Components["ibsQuery"];
            if (aSource != null)
                FDesignerHost.DestroyComponent(aSource);

            InfoDataSet FDataSet = FDesignerHost.CreateComponent(typeof(InfoDataSet), "id" + cParam.TableName) as InfoDataSet;
            FDataSet.RemoteName = cParam.ProviderName;
            FDataSet.Active = true;
            FDataSet.AlwaysClose = true;
            InfoBindingSource MainBindingSource = FDesignerHost.CreateComponent(typeof(InfoBindingSource), "ibs" + cParam.TableName) as InfoBindingSource;
            MainBindingSource.DataSource = FDataSet;
            MainBindingSource.DataMember = FDataSet.RealDataSet.Tables[0].TableName;
            SplitContainer SplitContainer1 = FRootForm.Controls["splitContainer1"] as SplitContainer;
            InfoDataGridView Grid = SplitContainer1.Panel2.Controls["InfoDataGridView1"] as InfoDataGridView;
            Grid.DataSource = MainBindingSource;
            Grid.Columns.Clear();
            DataGridViewTextBoxColumn Column;

            for (int i = 0; i < SelectedMasterFields.Rows.Count; i++)
            {
                Column = FDesignerHost.CreateComponent(typeof(DataGridViewTextBoxColumn), "dgc" + cParam.TableName + SelectedMasterFields.Rows[i]["ColumnName"].ToString()) as DataGridViewTextBoxColumn;
                Column.DataPropertyName = SelectedMasterFields.Rows[i]["ColumnName"].ToString();
                Column.HeaderText = SelectedMasterFields.Rows[i]["Caption"].ToString();
                Column.MaxInputLength = Convert.ToInt32(SelectedMasterFields.Rows[i]["Width"]);
                if (Column.HeaderText.Trim() == "")
                    Column.HeaderText = SelectedMasterFields.Rows[i]["ColumnName"].ToString();
                Grid.Columns.Add(Column);
            }
        }
예제 #9
0
        private void GenWebEasilyReport(ClientParam cParam)
        {
            #if VS90
            //WebDataSource Master = (WebDataSource)FPage.FindControl("Master");
            if (this.cbTemplate.Text == "WebEasilyReportSingle")
            {
                Infolight.EasilyReportTools.DataSourceItemCollection dataSourceItemCollection = new Infolight.EasilyReportTools.DataSourceItemCollection();
                Infolight.EasilyReportTools.DataSourceItem dataSourceItem = new Infolight.EasilyReportTools.DataSourceItem();

                DataTable dt = WebDataSet.CreateWebDataSet("WMaster").RealDataSet.Tables[cParam.TableName].Copy();

                foreach (DataRow dr in SelectedMasterFields.Rows)
                {
                    Infolight.EasilyReportTools.FieldItem fieldItem = new Infolight.EasilyReportTools.FieldItem();
                    fieldItem.ColumnName = dr["ColumnName"].ToString();
                    fieldItem.Caption = dr["Caption"].ToString();
                    if (fieldItem.Caption == String.Empty)
                        fieldItem.Caption = dr["ColumnName"].ToString();
                    fieldItem.Width = Convert.ToInt32(dr["Width"]);
                    if (CheckNum(dt, fieldItem.ColumnName))
                    {
                        fieldItem.CaptionAlignment = HorizontalAlignment.Right;
                        fieldItem.ColumnAlignment = HorizontalAlignment.Right;
                    }
                    dataSourceItem.Fields.Add(fieldItem);
                }

                dataSourceItemCollection.Add(dataSourceItem);

                foreach (DataRow dr in SelectedMasterGroups.Rows)
                {
                    foreach (Infolight.EasilyReportTools.FieldItem item in dataSourceItem.Fields)
                    {
                        if (item.ColumnName == dr["ColumnName"].ToString())
                        {
                            item.Group = Infolight.EasilyReportTools.FieldItem.GroupType.Normal;
                            item.Order = Infolight.EasilyReportTools.FieldItem.OrderType.Ascend;
                        }
                    }
                }

                WebDevPage.IHTMLElement WebEasilyReport1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("WebEasilyReport1", 0);
                if (WebEasilyReport1 != null)
                {
                    WebEasilyReport1.setAttribute("ReportID", cParam.FormName, 0);
                    WebEasilyReport1.setAttribute("ReportName", cParam.FormTitle, 0);

                    SetCollectionValue(WebEasilyReport1, typeof(Infolight.EasilyReportTools.WebEasilyReport).GetProperty("FieldItems"), dataSourceItemCollection);
                }
            }
            else if (this.cbTemplate.Text == "WebEasilyReportMasterDetail1")
            {
                int i = 0;
                Infolight.EasilyReportTools.ReportItemCollection aReportItemCollection = new Infolight.EasilyReportTools.ReportItemCollection();
                foreach (DataRow dr in SelectedMasterFields.Rows)
                {
                    i++;
                    Infolight.EasilyReportTools.ReportDataSourceItem reportDataSourceItem = new Infolight.EasilyReportTools.ReportDataSourceItem();
                    if ((i - 1) % 2 == 0)
                    {
                        reportDataSourceItem.NewLine = true;
                        reportDataSourceItem.Cells = 2;
                    }
                    else
                    {
                        reportDataSourceItem.Cells = 0;
                    }
                    reportDataSourceItem.ColumnName = dr["ColumnName"].ToString();
                    reportDataSourceItem.Format = "{0}";
                    if (dr["Caption"].ToString() == String.Empty)
                        reportDataSourceItem.Format = dr["ColumnName"].ToString() + ": " + reportDataSourceItem.Format;
                    else
                        reportDataSourceItem.Format = dr["Caption"].ToString() + ": " + reportDataSourceItem.Format;
                    aReportItemCollection.Add(reportDataSourceItem);
                }

                Infolight.EasilyReportTools.DataSourceItemCollection dataSourceItemCollection = new Infolight.EasilyReportTools.DataSourceItemCollection();
                Infolight.EasilyReportTools.DataSourceItem dataSourceItem = new Infolight.EasilyReportTools.DataSourceItem();

                DataTable dt = WebDataSet.CreateWebDataSet("WMaster").RealDataSet.Tables[cParam.ChildTableName].Copy();

                foreach (DataRow dr in SelectedDetailFields.Rows)
                {
                    Infolight.EasilyReportTools.FieldItem fieldItem = new Infolight.EasilyReportTools.FieldItem();
                    fieldItem.ColumnName = dr["ColumnName"].ToString();
                    fieldItem.Caption = dr["Caption"].ToString();
                    if (fieldItem.Caption == String.Empty)
                        fieldItem.Caption = dr["ColumnName"].ToString();
                    fieldItem.Width = Convert.ToInt32(dr["Width"]);
                    if (CheckNum(dt, fieldItem.ColumnName))
                    {
                        fieldItem.CaptionAlignment = HorizontalAlignment.Right;
                        fieldItem.ColumnAlignment = HorizontalAlignment.Right;
                    }
                    dataSourceItem.Fields.Add(fieldItem);
                }
                dataSourceItemCollection.Add(dataSourceItem);

                foreach (DataRow dr in SelectedDetailGroups.Rows)
                {
                    foreach (Infolight.EasilyReportTools.FieldItem item in dataSourceItem.Fields)
                    {
                        if (item.ColumnName == dr["ColumnName"].ToString())
                        {
                            item.Group = Infolight.EasilyReportTools.FieldItem.GroupType.Normal;
                            item.Order = Infolight.EasilyReportTools.FieldItem.OrderType.Ascend;
                        }
                    }
                }

                WebDevPage.IHTMLElement WebEasilyReport1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("WebEasilyReport1", 0);
                if (WebEasilyReport1 != null)
                {
                    WebEasilyReport1.setAttribute("ReportID", cParam.FormName, 0);
                    WebEasilyReport1.setAttribute("ReportName", cParam.FormTitle, 0);

                    SetCollectionValue(WebEasilyReport1, typeof(Infolight.EasilyReportTools.WebEasilyReport).GetProperty("HeaderItems"), aReportItemCollection);
                    SetCollectionValue(WebEasilyReport1, typeof(Infolight.EasilyReportTools.WebEasilyReport).GetProperty("FieldItems"), dataSourceItemCollection);
                }
            }
            #else
            Object WebEasilyReport1 = FPage.FindControl("WebEasilyReport1");
            WebEasilyReport1.GetType().GetProperty("ReportID").SetValue(WebEasilyReport1, cParam.FormName, null);
            WebEasilyReport1.GetType().GetProperty("ReportName").SetValue(WebEasilyReport1, cParam.FormTitle, null);

            WebDataSource Master = (WebDataSource)FPage.FindControl("Master");

            if (this.cbTemplate.Text == "WebEasilyReportSingle")
            {
                DataTable dt = WebDataSet.CreateWebDataSet("WMaster").RealDataSet.Tables[cParam.TableName].Copy();

                Type datasourceItemType = WebEasilyReport1.GetType().GetProperty("FieldItems").PropertyType.GetProperty("Item").PropertyType;//找出DataSourceItem的类型
                object dataSourceItem = Activator.CreateInstance(datasourceItemType);//创建DataSourceItem类型的实例

                IList iDataSourceItemFields = null;
                foreach (DataRow dr in SelectedMasterFields.Rows)
                {
                    Type fieldsType = WebEasilyReport1.GetType().Assembly.GetType("Infolight.EasilyReportTools.FieldItem");//找出FieldItem的类型
                    object fieldsItem = Activator.CreateInstance(fieldsType);//创建FieldItem类型的实例

                    fieldsItem.GetType().GetProperty("ColumnName").SetValue(fieldsItem, dr["ColumnName"].ToString(), null);
                    fieldsItem.GetType().GetProperty("Caption").SetValue(fieldsItem, dr["Caption"].ToString(), null);
                    if (dr["Caption"].ToString() == String.Empty)
                        fieldsItem.GetType().GetProperty("Caption").SetValue(fieldsItem, dr["ColumnName"].ToString(), null);
                    fieldsItem.GetType().GetProperty("Width").SetValue(fieldsItem, Convert.ToInt32(dr["Width"]), null);

                    if (CheckNum(dt, dr["ColumnName"].ToString()))
                    {
                        fieldsItem.GetType().GetProperty("CaptionAlignment").SetValue(fieldsItem, HorizontalAlignment.Right, null);
                        fieldsItem.GetType().GetProperty("ColumnAlignment").SetValue(fieldsItem, HorizontalAlignment.Right, null);
                    }

                    iDataSourceItemFields = dataSourceItem.GetType().GetProperty("Fields").GetValue(dataSourceItem, null) as IList;//得到一个FieldItemCollection
                    iDataSourceItemFields.Add(fieldsItem);
                }

                foreach (DataRow dr in SelectedMasterGroups.Rows)
                {
                    for (int i = 0; i < iDataSourceItemFields.Count; i++)
                    {
                        String iFieldsColumnName = iDataSourceItemFields[i].GetType().GetProperty("ColumnName").GetValue(iDataSourceItemFields[i], null).ToString();
                        if (iFieldsColumnName == dr["ColumnName"].ToString())
                        {
                            //item.Order = Infolight.EasilyReportTools.FieldItem.OrderType.Ascend;
                            iDataSourceItemFields[i].GetType().GetProperty("Order").SetValue(iDataSourceItemFields[i], iDataSourceItemFields[i].GetType().GetProperty("Order").PropertyType.GetField("Ascend").GetValue(iDataSourceItemFields[i]), null);
                            //item.Group = Infolight.EasilyReportTools.FieldItem.GroupType.Normal;
                            iDataSourceItemFields[i].GetType().GetProperty("Group").SetValue(iDataSourceItemFields[i], iDataSourceItemFields[i].GetType().GetProperty("Group").PropertyType.GetField("Normal").GetValue(iDataSourceItemFields[i]), null);
                        }
                    }
                }

                IList iFieldItems = WebEasilyReport1.GetType().GetProperty("FieldItems").GetValue(WebEasilyReport1, null) as IList;
                iFieldItems.Add(dataSourceItem);
            }
            else if (this.cbTemplate.Text == "WebEasilyReportMasterDetail1")
            {
                int i = 0;
                foreach (DataRow dr in SelectedMasterFields.Rows)
                {
                    i++;

                    Type reportDataSourceItemType = WebEasilyReport1.GetType().Assembly.GetType("Infolight.EasilyReportTools.ReportDataSourceItem");
                    object aReportDataSourceItem = Activator.CreateInstance(reportDataSourceItemType);
                    if ((i - 1) % 2 == 0)
                    {
                        aReportDataSourceItem.GetType().GetProperty("NewLine").SetValue(aReportDataSourceItem, true, null);
                        aReportDataSourceItem.GetType().GetProperty("Cells").SetValue(aReportDataSourceItem, 2, null);
                    }
                    else
                    {
                        aReportDataSourceItem.GetType().GetProperty("Cells").SetValue(aReportDataSourceItem, 0, null);
                    }
                    aReportDataSourceItem.GetType().GetProperty("ColumnName").SetValue(aReportDataSourceItem, dr["ColumnName"].ToString(), null);
                    if (dr["Caption"].ToString() == String.Empty)
                        aReportDataSourceItem.GetType().GetProperty("Format").SetValue(aReportDataSourceItem, dr["ColumnName"].ToString() + ": {0}", null);
                    else
                        aReportDataSourceItem.GetType().GetProperty("Format").SetValue(aReportDataSourceItem, dr["Caption"].ToString() + ": {0}", null);

                    IList iHeaderItems = WebEasilyReport1.GetType().GetProperty("HeaderItems").GetValue(WebEasilyReport1, null) as IList;
                    iHeaderItems.Add(aReportDataSourceItem);
                }

                DataTable dt = WebDataSet.CreateWebDataSet("WMaster").RealDataSet.Tables[cParam.ChildTableName].Copy();

                Type datasourceItemType = WebEasilyReport1.GetType().GetProperty("FieldItems").PropertyType.GetProperty("Item").PropertyType;//找出DataSourceItem的类型
                object dataSourceItem = Activator.CreateInstance(datasourceItemType);//创建DataSourceItem类型的实例

                IList iDataSourceItemFields = null;
                foreach (DataRow dr in SelectedDetailFields.Rows)
                {
                    Type fieldsType = WebEasilyReport1.GetType().Assembly.GetType("Infolight.EasilyReportTools.FieldItem");//找出FieldItem的类型
                    object fieldsItem = Activator.CreateInstance(fieldsType);//创建FieldItem类型的实例
                    fieldsItem.GetType().GetProperty("ColumnName").SetValue(fieldsItem, dr["ColumnName"].ToString(), null);
                    fieldsItem.GetType().GetProperty("Caption").SetValue(fieldsItem, dr["Caption"].ToString(), null);
                    if (dr["Caption"].ToString() == String.Empty)
                        fieldsItem.GetType().GetProperty("Caption").SetValue(fieldsItem, dr["ColumnName"].ToString(), null);
                    fieldsItem.GetType().GetProperty("Width").SetValue(fieldsItem, Convert.ToInt32(dr["Width"]), null);

                    if (CheckNum(dt, dr["ColumnName"].ToString()))
                    {
                        fieldsItem.GetType().GetProperty("CaptionAlignment").SetValue(fieldsItem, HorizontalAlignment.Right, null);
                        fieldsItem.GetType().GetProperty("ColumnAlignment").SetValue(fieldsItem, HorizontalAlignment.Right, null);
                    }

                    iDataSourceItemFields = dataSourceItem.GetType().GetProperty("Fields").GetValue(dataSourceItem, null) as IList;//得到一个FieldItemCollection
                    iDataSourceItemFields.Add(fieldsItem);
                }

                foreach (DataRow dr in SelectedDetailGroups.Rows)
                {
                    for (int j = 0; j < iDataSourceItemFields.Count; j++)
                    {
                        String iFieldsColumnName = iDataSourceItemFields[j].GetType().GetProperty("ColumnName").GetValue(iDataSourceItemFields[j], null).ToString();
                        if (iFieldsColumnName == dr["ColumnName"].ToString())
                        {
                            //item.Order = Infolight.EasilyReportTools.FieldItem.OrderType.Ascend;
                            iDataSourceItemFields[j].GetType().GetProperty("Order").SetValue(iDataSourceItemFields[j], iDataSourceItemFields[j].GetType().GetProperty("Order").PropertyType.GetField("Ascend").GetValue(iDataSourceItemFields[j]), null);
                            //item.Group = Infolight.EasilyReportTools.FieldItem.GroupType.Normal;
                            iDataSourceItemFields[j].GetType().GetProperty("Group").SetValue(iDataSourceItemFields[j], iDataSourceItemFields[j].GetType().GetProperty("Group").PropertyType.GetField("Normal").GetValue(iDataSourceItemFields[j]), null);
                        }
                    }
                }

                IList iFieldItems = WebEasilyReport1.GetType().GetProperty("FieldItems").GetValue(WebEasilyReport1, null) as IList;
                iFieldItems.Add(dataSourceItem);
            }

            IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
            NotifyRefresh(200);
            FComponentChangeService.OnComponentChanged(WebEasilyReport1, null, "", "M");
            #endif
        }
예제 #10
0
        private void GenMasterFormView(ClientParam cp)
        {
            #if VS90
            WebDevPage.IHTMLElement FormView = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("wfvMaster", 0);
            if (FormView != null)
            {
                RefreshFormView(FormView, SelectedMasterFields.Rows);
            }
            #else
            WebDataSource Master = (WebDataSource)FPage.FindControl("Master");
            WebFormView wfvMaster = (WebFormView)FPage.FindControl("wfvMaster");
            //Generate RESX
            GenResx(Master);
            FormViewDesigner aDesigner = FDesignerHost.GetDesigner(wfvMaster) as FormViewDesigner;

            //FormView
            foreach (System.Web.UI.Design.TemplateGroup tempGroup in aDesigner.TemplateGroups)
            {
                foreach (System.Web.UI.Design.TemplateDefinition tempDefin in tempGroup.Templates)
                {
                    if (tempDefin.Name == "EditItemTemplate" || tempDefin.Name == "InsertItemTemplate" || tempDefin.Name == "ItemTemplate")
                    {
                        StringBuilder builder = new StringBuilder();
                        string content = tempDefin.Content;
                        if (content == null || content.Length == 0)
                            continue;

                        string[] ctrlTexts = content.Split("\r\n".ToCharArray());
                        //Control[] ctrls = ControlParser.ParseControls(host, content);
                        int i = 0;
                        int j = 0;
                        int m = wfvMaster.LayOutColNum * 2;

                        List<string> lists = new List<string>();
                        String ExtraName = "";

                        foreach (DataRow dr in SelectedMasterFields.Rows)
                        {
                            lists.Add(dr["ColumnName"].ToString());

                            String FormatStyle = FormatEditMask(dr["EditMask"].ToString());

                            if (tempDefin.Name == "ItemTemplate")
                            {
                                String S3 = String.Format("<asp:Label ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>'></asp:Label>", "l" + dr["ColumnName"].ToString(), dr["ColumnName"].ToString(), FormatStyle);
                                lists.Add(S3);
                            }
                            else
                            {
                                if (tempDefin.Name == "InsertItemTemplate")
                                {
                                    FormViewField aViewField = new FormViewField();
                                    aViewField.ControlID = "tb" + dr["ColumnName"].ToString();
                                    aViewField.FieldName = dr["Caption"].ToString();
                                    wfvMaster.Fields.Add(aViewField);
                                }
                                String S4 = String.Format("<asp:TextBox ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>' MaxLength=\"{3}\"></asp:TextBox>", "tb" + dr["ColumnName"].ToString(), dr["ColumnName"].ToString(), FormatStyle, dr["Width"].ToString());
                                lists.Add(S4);
                            }
                        }

                        j = j * 2;

                        if (m > 0)
                        {
                            builder.Append("<table>");
                        }

                        foreach (string ctrlText in lists.ToArray())
                        {
                            if (ctrlText == null || ctrlText.Length == 0)
                                continue;

                            if (m > 0)
                            {
                                if (i % m == 0)
                                {
                                    builder.Append("<tr>");
                                }

                                builder.Append("<td>");
                            }
                            // add dd
                            string ddText = "";
                            if (tempDefin.Name != "ItemTemplate")
                            {
                                //ddText = GetValidateText(ctrlText);
                                //ddText = GetDDText(ddText, BlockItem);
                                ddText = GetDDText(ctrlText, SelectedMasterFields, tempDefin.Name);
                            }
                            else
                            {
                                ddText = GetDDText(ctrlText, SelectedMasterFields, tempDefin.Name);
                            }
                            builder.Append(ddText);
                            builder.Append("\r\n");

                            if (m > 0)
                            {
                                builder.Append("</td>");

                                if (i % m == m - 1)
                                {
                                    builder.Append("</tr>");
                                }
                            }
                            i++;
                        }

                        if (m > 0)
                        {
                            if (i % m != 0)
                            {
                                int n = m - (i % m);
                                int q = 0;
                                while (q < n)
                                {
                                    builder.Append("<td></td>");
                                    q++;
                                }
                                builder.Append("</tr>");
                            }
                            builder.Append("</table>");
                        }

                        tempDefin.Content = builder.ToString();
                    }
                }
            }

            IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
            NotifyRefresh(200);
            FComponentChangeService.OnComponentChanged(wfvMaster, null, "", "M");
            FComponentChangeService.OnComponentChanged(Master, null, "", "M");
            #endif
        }
예제 #11
0
        private void GenMasterGridView(ClientParam cParam)
        {
            #if VS90
            object oMaster = FDesignerDocument.webControls.item("Master", 0);

            WebDevPage.IHTMLElement eMaster = null;
            WebDevPage.IHTMLElement eWebGridView1 = null;

            if (oMaster == null || !(oMaster is WebDevPage.IHTMLElement))
                return;
            eMaster = (WebDevPage.IHTMLElement)oMaster;

            object oWebGridView1 = FDesignerDocument.webControls.item("wgvMaster", 0);
            if (oWebGridView1 == null)
                oWebGridView1 = FDesignerDocument.webControls.item("WebGridView1", 0);
            eWebGridView1 = (WebDevPage.IHTMLElement)oWebGridView1;
            //eWebGridView1.setAttribute("DataMember", FClientData.TableName, 0);

            //这里本来想再往下找Columns节点的,可是找不到,只能先这样写了
            StringBuilder sb = new StringBuilder(eWebGridView1.innerHTML);
            int idx = eWebGridView1.innerHTML.IndexOf("</Columns>");
            if (idx == -1)
            {
                idx = sb.ToString().IndexOf("<SelectedRowStyle");
                sb.Insert(idx, "<Columns>\r\n            </Columns>");
            }
            List<string> KeyFields = new List<string>();
            foreach (DataRow dr in SelectedMasterFields.Rows)
            {
                idx = sb.ToString().IndexOf("</Columns>");

                sb.Insert(idx, "\r            <asp:BoundField DataField=\"" + dr["ColumnName"].ToString() + "\" HeaderText=\"" + (string.IsNullOrEmpty(dr["Caption"].ToString()) ? dr["ColumnName"].ToString() : dr["Caption"].ToString()) + "\" SortExpression=\"" + dr["ColumnName"].ToString() + "\" />\r\n            ");

            }
            eWebGridView1.innerHTML = sb.ToString();
            #else
            WebGridView WebGridView1 = (WebGridView)FPage.FindControl("WebGridView1");
            WebGridView1.Columns.Clear();
            List<string> KeyFields = new List<string>();
            foreach (DataRow dr in SelectedMasterFields.Rows)
            {
                System.Web.UI.WebControls.BoundField aBoundField = new System.Web.UI.WebControls.BoundField();
                aBoundField.DataField = dr["ColumnName"].ToString();
                aBoundField.HeaderText = dr["Caption"].ToString();
                aBoundField.SortExpression = dr["ColumnName"].ToString();
                if (aBoundField.HeaderText == "")
                    aBoundField.HeaderText = dr["ColumnName"].ToString();
                WebGridView1.Columns.Add(aBoundField);
            }

            IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
            NotifyRefresh(200);
            FComponentChangeService.OnComponentChanged(WebGridView1, null, "", "M");
            #endif
        }
예제 #12
0
 private void GenMainBlockControl(ClientParam cParam)
 {
     if (this.cbTemplate.Text == "CEasilyReportSingle1")
     {
         SetSelectedMasterFields(cParam);
         SetSelectedMasterGroups(cParam);
         GenMasterSingle1(cParam);
     }
     else if (this.cbTemplate.Text == "CEasilyReportMasterDetail1")
     {
         SetSelectedMasterFields(cParam);
         SetSelectedMasterGroups(cParam);
         SetSelectedDetailFields(cParam);
         SetSelectedDetailGroups(cParam);
         GenMasterDetail1(cParam);
     }
 }
예제 #13
0
 public static void WinCreateXSD(Project GlobalProject, InfoDataSet FDataSet, ClientParam cParam, WinClientParam winParam)
 {
     string filePath = winParam.OutputPath + "\\" + winParam.PackageName + "\\";
     bool CreateFileSucess = true;
     string fileName = "";
     try
     {
         fileName = filePath + FDataSet.Site.Name + ".xsd";
         FDataSet.RealDataSet.WriteXmlSchema(fileName);
     }
     catch
     {
         CreateFileSucess = false;
         MessageBox.Show("Failed to create xsd file!");
     }
     finally
     {
         if (CreateFileSucess && File.Exists(fileName))
         {
             GlobalProject.ProjectItems.AddFromFile(fileName);
         }
     }
 }
예제 #14
0
 public static void GetWinQuery(Form FRootForm, ClientParam cParam, List<TBlockFieldItem> list)
 {
     InfoBindingSource ibs = FRootForm.Container.Components["ibs" + cParam.TableName] as InfoBindingSource;
     foreach (TBlockFieldItem aFieldItem in list)
     {
         CreateWinQueryField(FRootForm, aFieldItem, "", ibs);
     }
 }
예제 #15
0
        private List<TBlockFieldItem> SetFields(ClientParam cParam)
        {
            DataTable dtDD = ReportCreator.GetDDTable(cParam.ClientType, cParam.SelectAlias, cParam.RealTableName);
            DataTable dtTableSchema = FInfoDataSet.RealDataSet.Tables[0];
            List<TBlockFieldItem> list = new List<TBlockFieldItem>();
            for (int I = 0; I < dtTableSchema.Columns.Count; I++)
            {
                DataRow[] DRs = dtDD.Select("FIELD_NAME='" + dtTableSchema.Columns[I].ColumnName + "'");
                TBlockFieldItem aBlockFieldItem = new TBlockFieldItem();
                aBlockFieldItem.DataField = dtTableSchema.Columns[I].ColumnName;
                aBlockFieldItem.DataType = dtTableSchema.Columns[I].DataType;
                if (DRs.Length == 1)
                {
                    DataRow DR = DRs[0];

                    aBlockFieldItem.Description = DR["CAPTION"].ToString();
                    aBlockFieldItem.CheckNull = DR["CHECK_NULL"].ToString().ToUpper();
                    aBlockFieldItem.DefaultValue = DR["DEFAULT_VALUE"].ToString();
                    aBlockFieldItem.ControlType = DR["NEEDBOX"].ToString();
                    aBlockFieldItem.EditMask = DR["EDITMASK"].ToString();
                    if (aBlockFieldItem.DataType == typeof(DateTime))
                    {
                        if (aBlockFieldItem.ControlType == null || aBlockFieldItem.ControlType == "")
                            aBlockFieldItem.ControlType = "DateTimeBox";
                    }
                    aBlockFieldItem.QueryMode = DR["QUERYMODE"].ToString();
                    list.Add(aBlockFieldItem);
                }
            }
            return list;
        }
예제 #16
0
        private ClientParam GetClientParams()
        {
            ClientParam cParam = new ClientParam();
            cParam.FormName = tbFormName.Text;
            cParam.FormTitle = tbFormTitle.Text;
            cParam.IsMasterDetails = cbIsMasterDetails.Checked;
            cParam.ProviderName = tbProviderName.Text;
            cParam.TableName = tbTableName.Text;
            cParam.RealTableName = tbTableNameF.Text;
            cParam.ChildTableName = tbChildTableName.Text;

            if (cParam.ChildTableName != null && cParam.ChildTableName != String.Empty)
            {
                String ModuleName = FInfoDataSet.RemoteName.Substring(0, FInfoDataSet.RemoteName.IndexOf('.'));
                String SolutionName = System.IO.Path.GetFileNameWithoutExtension(_dte2.Solution.FullName);
                cParam.ChildRealTableName = CliUtils.GetTableName(ModuleName, cParam.ChildTableName, SolutionName);
            }

            cParam.SelectAlias = this.cmbSelectAlias.Text;
            cParam.ClientType = (ClientType)this.cmbDataBaseType.SelectedIndex;
            if (cParam.IsMasterDetails)
            {
                if (tbChildTableName.Text != "")
                {
                    string[] DetailTableName = tbChildTableName.Text.Split(',');
                    cParam.DetailProviderName = cParam.ProviderName.Substring(0, cParam.ProviderName.IndexOf('.')) + "." + DetailTableName[0];
                }
            }
            return cParam;
        }
예제 #17
0
        private void WriteWebDataSourceHTML(ref Window FDesignWindow, ClientParam cParam, ProjectItem projItem)
        {
            String FileName = FDesignWindow.Document.FullName;
            FDesignWindow.Close(vsSaveChanges.vsSaveChangesYes);

            String UpdateHTML = "";

            UpdateHTML = String.Format("<rsweb:reportviewer id=\"ReportViewer1\" runat=\"server\" width=\"100%\" Font-Names=\"Verdana\""
                + " Font-Size=\"8pt\" Height=\"400px\">"
                + "<LocalReport ReportPath=\"\">"
                + "<DataSources>"
                + "<rsweb:ReportDataSource DataSourceId=\"Master\" Name={0} />"
                + "</DataSources>"
                + "</LocalReport>"
                + "</rsweb:reportviewer>",
                "\"NewDataSet_" + cParam.ProviderName.Substring(cParam.ProviderName.IndexOf('.') + 1) + "\"");

            //Start Update Process
            System.IO.StreamReader SR = new System.IO.StreamReader(FileName, Encoding.Default);
            String Context = SR.ReadToEnd();
            SR.Close();

            //Update HTML
            int x, y;
            string temp = "";
            x = Context.IndexOf("<rsweb");
            y = Context.IndexOf("</rsweb");
            temp = Context.Substring(x, (y - x) + 21);
            Context = Context.Replace(temp, UpdateHTML);

            //Page Title
            Context = Context.Replace("<title>Untitled Page</title>", "<title>" + cParam.FormTitle + "</title>");

            System.IO.FileStream Filefs = new System.IO.FileStream(FileName, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite);
            System.IO.StreamWriter SW = new System.IO.StreamWriter(Filefs, Encoding.UTF8);
            SW.Write(Context);
            SW.Close();
            Filefs.Close();

            FDesignWindow = projItem.Open("{7651A702-06E5-11D1-8EBD-00A0C90F26EA}");
            FDesignWindow.Activate();
        }
예제 #18
0
        private void SetSelectedMasterGroups(ClientParam cParam)
        {
            SelectedMasterGroups = new DataTable();
            SelectedMasterGroups.Columns.Add(new DataColumn("ColumnName", typeof(String)));
            SelectedMasterGroups.Columns.Add(new DataColumn("DataType", typeof(Type)));
            SelectedMasterGroups.Columns.Add(new DataColumn("Caption", typeof(String)));
            SelectedMasterGroups.Columns.Add(new DataColumn("Width", typeof(int)));
            SelectedMasterGroups.Columns.Add(new DataColumn("EditMask", typeof(String)));

            List<TBlockFieldItem> listfield = SetFields(cParam,cParam.TableName, cParam.RealTableName);
            foreach (TBlockFieldItem tb in listfield)
            {
                foreach (System.Windows.Forms.TreeNode tn in this.tvGroupSelect.Nodes[0].Nodes)
                {
                    if (tn.Text == tb.DataField)
                    {
                        if (tn.Checked)
                        {
                            DataRow dr = SelectedMasterGroups.NewRow();
                            dr["ColumnName"] = tb.DataField;
                            dr["DataType"] = tb.DataType;
                            dr["Caption"] = tb.Description;
                            dr["Width"] = tb.Length;
                            dr["EditMask"] = tb.EditMask;
                            SelectedMasterGroups.Rows.Add(dr);
                        }
                        break;
                    }
                }
            }
        }
예제 #19
0
 private void GenWinForm(WinClientParam winParam, ClientParam cParam)
 {
     Solution Sln = _dte2.Solution;
     Project P = null;
     int I;
     for (I = 1; I <= Sln.Projects.Count; I++)
     {
         P = Sln.Projects.Item(I);
         if (string.Compare(winParam.PackageName, P.Name) == 0)
             break;
         P = null;
     }
     if (P == null)
         throw new Exception("Can not find project " + winParam.PackageName + " in solution");
     ProjectItem PI;
     String lan = GetLanguage();
     for (I = P.ProjectItems.Count; I >= 1; I--)
     {
         PI = P.ProjectItems.Item(I);
         if (string.Compare(PI.Name, "Form1" + lan) == 0)
         {
             string Path = PI.get_FileNames(0);
             Path = System.IO.Path.GetDirectoryName(Path);
             RenameNameSpace(Path + "\\Form1" + lan, winParam.PackageName, cParam.FormName);
             RenameNameSpace(Path + "\\Form1.Designer" + lan, winParam.PackageName, cParam.FormName);
             Window W = PI.Open("{00000000-0000-0000-0000-000000000000}");
             W.Activate();
             GlobalPI = PI;
             GlobalWindow = W;
             if (string.Compare(cParam.FormName, "Form1") != 0)
             {
                 PI.Name = cParam.FormName + lan;
                 W.Close(vsSaveChanges.vsSaveChangesYes);
                 W = PI.Open("{00000000-0000-0000-0000-000000000000}");
                 W.Activate();
             }
             FDesignerHost = (IDesignerHost)W.Object;
             FRootForm = (System.Windows.Forms.Form)FDesignerHost.RootComponent;
             FRootForm.Name = cParam.FormName;
             FRootForm.Text = cParam.FormTitle;
             IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
         }
         if (string.Compare(PI.Name, "Program" + lan) == 0)
         {
             RenameNameSpace(PI.get_FileNames(0), winParam.PackageName, cParam.FormName);
         }
     }
 }
예제 #20
0
        public void WriteWebFormTitle(Window FDesignWindow, ClientParam cParam, ProjectItem projItem)
        {
            String FileName = FDesignWindow.Document.FullName;
            FDesignWindow.Close(vsSaveChanges.vsSaveChangesYes);

            //Start Update Process
            System.IO.StreamReader SR = new System.IO.StreamReader(FileName, Encoding.Default);
            String Context = SR.ReadToEnd();
            SR.Close();

            //Page Title
            Context = Context.Replace("<title>Untitled Page</title>", "<title>" + cParam.FormTitle + "</title>");

            System.IO.FileStream Filefs = new System.IO.FileStream(FileName, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite);
            System.IO.StreamWriter SW = new System.IO.StreamWriter(Filefs, Encoding.UTF8);
            SW.Write(Context);
            SW.Close();
            Filefs.Close();

            FDesignWindow = projItem.Open("{7651A702-06E5-11D1-8EBD-00A0C90F26EA}");
            FDesignWindow.Activate();
        }
예제 #21
0
        private bool GenWinSolution(WinClientParam winParam, ClientParam cParam)
        {
            Solution sln = _dte2.Solution;
            string BaseFormName = GetBaseWinForm(cbIsMasterDetails.Checked);
            FTemplatePath = Path.GetDirectoryName(_addIn.Object.GetType().Assembly.Location) + "\\Templates\\";
            string CurrentSln = _dte2.Solution.FileName;
            String lan = GetLanguage();
            string BaseFormProj = BaseFormName + "\\" + BaseFormName + lan + "proj";
            string FilePath = winParam.OutputPath + "\\" + winParam.PackageName;
            if (System.IO.Directory.Exists(FilePath))
            {
                if (FilePath == "\\")
                    throw new Exception("Unknown Output Path: " + "\\");

                DialogResult dr = MessageBox.Show("There is another File which name is " + winParam.PackageName + " existed! Do you want to delete it first", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (dr == DialogResult.Yes)
                {
                    try
                    {
                        System.IO.Directory.Delete(FilePath, true);
                    }
                    catch
                    {
                        System.IO.Directory.Delete(FilePath, true);
                    }
                }
                else
                {
                    return false;
                }
            }

            Project P = sln.AddFromTemplate(FTemplatePath + BaseFormProj,
                    FilePath, winParam.PackageName, true);
            P.Name = winParam.PackageName;
            string FileName = FilePath + "\\" + winParam.PackageName + lan + "proj";
            P.Save(FileName);
            sln.Open(CurrentSln);
            int I;
            P = null;
            for (I = 1; I <= sln.Projects.Count; I++)
            {
                P = sln.Projects.Item(I);
                if (string.Compare(P.Name, winParam.PackageName) == 0)
                    break;
                else
                    P = null;
            }
            if (P != null)
                sln.Remove(P);
            P = sln.AddFromFile(FilePath + "\\" + winParam.PackageName + lan + "proj", false);
            P.Properties.Item("RootNamespace").Value = winParam.PackageName;
            P.Properties.Item("AssemblyName").Value = winParam.PackageName;
            sln.SaveAs(sln.FileName);
            sln.SolutionBuild.StartupProjects = P;
            sln.SolutionBuild.BuildProject(sln.SolutionBuild.ActiveConfiguration.Name, P.FullName, true);
            GlobalProject = P;

            if (winParam.AssemblyOutputPath != null && winParam.AssemblyOutputPath != "")
                GlobalProject.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value = winParam.AssemblyOutputPath;

            return true;
        }
예제 #22
0
        public static void WebCreateXSD(IDesignerHost FDesignerHost, ClientParam cParam, WebClientParam wecParam, Project proj)
        {
            WebDataSet aWebDataSet = new WebDataSet();

            ProjectItem webformDir = ReportCreator.FindProjectItem(proj, wecParam.FolderName);

            if (aWebDataSet != null)
            {
                aWebDataSet.SetWizardDesignMode(true);
                aWebDataSet.RemoteName = cParam.ProviderName;
                aWebDataSet.PacketRecords = 100;
                aWebDataSet.Active = true;

                String s;
                s = EEPRegistry.WebClient;

                string filePath = s + "\\" + wecParam.FolderName + "\\";
                bool CreateFileSucess = true;
                string fileName = "";
                try
                {
                    fileName = filePath + cParam.FormName + ".xsd";
                    aWebDataSet.RealDataSet.WriteXmlSchema(fileName);
                }
                catch
                {
                    CreateFileSucess = false;
                    MessageBox.Show("Failed to create xsd file!");
                }
                finally
                {
                    if (CreateFileSucess && File.Exists(fileName))
                    {
                        webformDir.ProjectItems.AddFromFile(fileName);
                    }
                    if (aWebDataSet != null)
                    {
                        aWebDataSet.Dispose();
                    }
                }
            }
        }