Beispiel #1
0
        public static Boolean RemoveSheetConfiguration(ModuleConfiguration module, SheetConfiguration sheet)
        {
            module.Sheets.Remove(sheet);
            Boolean Result = Convert.ToBoolean(Agent.CallService("Yqun.BO.BusinessManager.dll", "UpdateSheetConfiguration", new object[] { module }));

            return(Result);
        }
Beispiel #2
0
        public SheetReferenceDialog(int RowIndex, int ColumnIndex, DownListCellType CellType)
        {
            InitializeComponent();

            this.SheetConfiguration = SheetConfiguration;
            this.RowIndex           = RowIndex;
            this.ColumnIndex        = ColumnIndex;
            this.CellType           = CellType;

            DataFilter = new DataFilterCondition();
        }
Beispiel #3
0
        private void ShowSheetReferenceDialog()
        {
            if (FpSpread.ActiveSheet.ActiveCell.CellType is DownListCellType)
            {
                DownListCellType CellType = FpSpread.ActiveSheet.ActiveCell.CellType as DownListCellType;

                SheetConfiguration SheetConfiguration = FpSpread.ActiveSheet.Tag as SheetConfiguration;
                int RowIndex    = FpSpread.ActiveSheet.ActiveRowIndex;
                int ColumnIndex = FpSpread.ActiveSheet.ActiveColumnIndex;
                //SheetReferenceDialog ReferenceDialog = new SheetReferenceDialog(SheetConfiguration, RowIndex, ColumnIndex, CellType);
                //ReferenceDialog.ShowDialog();
            }
        }
        public static bool Delete(string Code)
        {
            StringBuilder Sql_Select = new StringBuilder();

            //增加查询条件Scdel=0   2013-10-19
            Sql_Select.Append("Select * From sys_biz_Sheet Where Scdel=0 and CatlogCode like '");
            Sql_Select.Append(Code);
            Sql_Select.Append("%'");
            DataTable Data = Agent.CallService("Yqun.BO.LoginBO.dll", "GetDataTable", new object[] { Sql_Select.ToString() }) as DataTable;

            if (Data != null && Data.Rows.Count > 0)
            {
                foreach (DataRow Row in Data.Rows)
                {
                    String             Index         = Row["ID"].ToString();
                    SheetConfiguration Configuration = DepositorySheetConfiguration.InitConfiguration(Index);
                    DepositorySheetConfiguration.Delete(Configuration);
                }
            }
            //增加字段Scts_1,Scdel 之后 删除操作只做伪删除,便于数据同步     2013-10-15
            StringBuilder Sql_Delete = new StringBuilder();

            //Sql_Delete.Append("Delete From sys_biz_SheetCatlog Where CatlogCode like '");
            //Sql_Delete.Append(Code);
            //Sql_Delete.Append("%'");
            Sql_Delete.Append("Update sys_biz_SheetCatlog Set Scts_1='" + DateTime.Now + "',Scdel=1");
            Sql_Delete.Append(" Where CatlogCode like '");
            Sql_Delete.Append(Code);
            Sql_Delete.Append("%'");

            Boolean Result = false;

            try
            {
                object r = Agent.CallService("Yqun.BO.LoginBO.dll", "ExcuteCommand", new object[] { Sql_Delete.ToString() });
                Result = (Convert.ToInt32(r) == 1);
            }
            catch
            { }

            return(Result);
        }
        private void ConditionItemSelector_Load(object sender, EventArgs e)
        {
            String ErrorInfo = "";

            ProgressScreen.Current.ShowSplashScreen();
            this.AddOwnedForm(ProgressScreen.Current);

            try
            {
                SheetInfo = DepositorySheetConfiguration.InitConfiguration(SheetIndex);

                ProgressScreen.Current.SetStatus = "正在初始化表单‘" + SheetInfo.Description + "’";

                fpSpread1.Sheets.Clear();
                SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), SheetInfo.SheetStyle, "SheetView") as SheetView;
                SheetView.SheetName     = SheetInfo.Description;
                SheetView.OperationMode = OperationMode.ReadOnly;
                fpSpread1.Sheets.Add(SheetView);

                if (SheetInfo.DataTableSchema.Schema != null)
                {
                    foreach (FieldDefineInfo field in SheetInfo.DataTableSchema.Schema.FieldInfos)
                    {
                        SheetView.Cells[field.RangeInfo].BackColor = Color.LightPink;
                        SheetView.Cells[field.RangeInfo].Tag       = field;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorInfo = ex.Message;
            }

            this.RemoveOwnedForm(ProgressScreen.Current);
            ProgressScreen.Current.CloseSplashScreen();
            Activate();

            if (ErrorInfo != "")
            {
                MessageBox.Show("加载表单出错!\r\n原因:" + ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #6
0
        public bool NewSheetConfiguration(SheetConfiguration Sheet)
        {
            StringBuilder Sql_Select = new StringBuilder();

            //增加查询条件Scdel=0   2013-10-19
            Sql_Select.Append("Select ID,SCTS,Scts_1,CatlogCode,Description,SheetStyle,DataTable From sys_biz_Sheet Where Scdel=0 and ID='");
            Sql_Select.Append(Sheet.Index);
            Sql_Select.Append("'");

            DataTable Data = GetDataTable(Sql_Select.ToString());

            if (Data != null)
            {
                DataRow Row = Data.NewRow();
                Row["ID"]          = Sheet.Index;
                Row["SCTS"]        = DateTime.Now.ToString();
                Row["CatlogCode"]  = Sheet.Code;
                Row["Description"] = Sheet.Description;
                Row["SheetStyle"]  = Sheet.SheetStyle;
                Row["DataTable"]   = "";

                Row["Scts_1"] = DateTime.Now.ToString();
                Data.Rows.Add(Row);
            }

            Boolean Result = false;

            try
            {
                object r = Update(Data);
                Result = (Convert.ToInt32(r) == 1);
            }
            catch
            { }

            return(Result);
        }
        public void WriteTestFile()
        {
            var configuration = new SheetConfiguration()
            {
                Name    = "Sheet A",
                Columns = new List <ColumnBase>()
                {
                    new TextColumn("Title", nameof(Record.Name)),
                    new BooleanColumn("Active", nameof(Record.IsActive)),
                    new DateColumn("Edited on...", nameof(Record.LastEditTime)),
                    new NumberColumn("Length", nameof(Record.Size))
                },
                Data = new List <object>()
                {
                    new Record()
                    {
                        LastEditTime = DateTime.Now,
                        IsActive     = true,
                        Name         = "Test a",
                        Size         = 123.4
                    },
                    new Record()
                    {
                        LastEditTime = DateTime.MaxValue,
                        IsActive     = false,
                        Name         = "Test b",
                        Size         = 4
                    }
                }
            };

            using (var stream = ExcelExporter.Generate(configuration))
            {
                File.WriteAllBytes(TestFilePath, stream.ToArray());
            }
        }
Beispiel #8
0
        public List <String> IsReferenceSheet(SheetConfiguration sheet)
        {
            List <String> Result = new List <string>();

            StringBuilder Sql_Command = new StringBuilder();

            // 增加查询条件 Scdel=0     2013-10-19
            Sql_Command.Append("Select ID,Description From sys_biz_Module Where Scdel=0 and Sheets like ',");
            Sql_Command.Append(sheet.Index);
            Sql_Command.Append(",'");

            DataTable Data = GetDataTable(Sql_Command.ToString());

            if (Data != null && Data.Rows.Count > 0)
            {
                foreach (DataRow Row in Data.Rows)
                {
                    String Description = Row["Description"].ToString();
                    Result.Add(Description);
                }
            }

            return(Result);
        }
Beispiel #9
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker    worker = sender as BackgroundWorker;
            BatchPrintClass     Params = e.Argument as BatchPrintClass;
            ModuleConfiguration Model  = Params.modelInfo;
            String DataCode            = Params.dataCode;

            ModelDataManager DataManager = new ModelDataManager();
            DataSet          dataSet     = new DataSet();

            if (dataID != null)
            {
                dataSet = DataManager.GetData(Model, dataID, DataCode);
            }
            else
            {
                dataSet = DataManager.GetData(Model, DataCode);
            }

            FpSpread fpSpread = new MyCell();

            PrintDialog Dialog = new PrintDialog();

            Dialog.AllowSomePages             = true;
            Dialog.PrinterSettings.PrintRange = PrintRange.SomePages;
            Dialog.PrinterSettings.FromPage   = 1;
            Dialog.PrinterSettings.ToPage     = 1;
            if (DialogResult.OK == Dialog.ShowDialog())
            {
                //初始化模板样式
                fpSpread.Sheets.Clear();
                foreach (SheetConfiguration Sheet in Model.Sheets)
                {
                    SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), Sheet.SheetStyle, "SheetView") as SheetView;
                    SheetView.Tag       = Sheet;
                    SheetView.SheetName = Sheet.Description;
                    fpSpread.Sheets.Add(SheetView);
                }

                fpSpread.LoadFormulas(true);

                //加载数据到模板样式
                if (dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow Row in dataSet.Tables[0].Rows)
                    {
                        Application.DoEvents();

                        int Index = dataSet.Tables[0].Rows.IndexOf(Row);
                        worker.ReportProgress((Index + 1) / dataSet.Tables[0].Rows.Count);

                        String DataID = Row["ID"].ToString();
                        foreach (SheetView SheetView in fpSpread.Sheets)
                        {
                            SheetConfiguration SheetConfiguration = SheetView.Tag as SheetConfiguration;
                            TableDefineInfo    TableInfo          = SheetConfiguration.DataTableSchema.Schema;
                            if (TableInfo != null)
                            {
                                foreach (FieldDefineInfo FieldInfo in TableInfo.FieldInfos)
                                {
                                    DataRow[] DataRows = dataSet.Tables[GetBracketName(TableInfo.Name)].Select("ID='" + DataID + "'");
                                    SheetView.Cells[FieldInfo.RangeInfo].Value = DataRows[0][FieldInfo.FieldName];
                                }
                            }
                        }

                        //批量打印
                        BatchPrintDocument Document = new BatchPrintDocument(fpSpread);
                        Document.PrinterSettings = Dialog.PrinterSettings;
                        Document.Print();
                    }

                    e.Result = "已输出全部资料到打印机。";
                }
                else
                {
                    e.Result = string.Format("模板 {0} 中没有资料数据。", Model.Description);
                }

                fpSpread.Dispose();
                fpSpread = null;
            }
            else
            {
                return;
            }
        }
Beispiel #10
0
        public static List <String> IsReferenceSheet(SheetConfiguration Sheet)
        {
            List <String> Result = Agent.CallService("Yqun.BO.BusinessManager.dll", "IsReferenceSheet", new object[] { Sheet }) as List <String>;

            return(Result);
        }
Beispiel #11
0
        public static bool Delete(SheetConfiguration Sheet)
        {
            Boolean Result = Convert.ToBoolean(Agent.CallService("Yqun.BO.BusinessManager.dll", "DeleteSheetConfiguration", new object[] { Sheet }));

            return(Result);
        }
Beispiel #12
0
        private void StadiumItemSelector_Load(object sender, EventArgs e)
        {
            String ErrorInfo = "";

            ProgressScreen.Current.ShowSplashScreen();
            this.AddOwnedForm(ProgressScreen.Current);

            ProgressScreen.Current.SetStatus = "正在加载模板...";
            ModelInfo = DepositoryModuleConfiguration.InitModuleConfiguration(ModelIndex);

            try
            {
                fpSpread1.Sheets.Clear();
                foreach (SheetConfiguration Sheet in ModelInfo.Sheets)
                {
                    if (Sheet == null)
                    {
                        continue;
                    }

                    ProgressScreen.Current.SetStatus = "正在初始化表单‘" + Sheet.Description + "’";

                    SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), Sheet.SheetStyle, "SheetView") as SheetView;
                    SheetView.Tag        = Sheet;
                    SheetView.SheetName  = Sheet.Description;
                    SheetView.ZoomFactor = 1.0F;
                    fpSpread1.Sheets.Add(SheetView);

                    SheetConfiguration Configuration = SheetView.Tag as SheetConfiguration;
                    if (Configuration.DataTableSchema.Schema == null)
                    {
                        continue;
                    }

                    foreach (FieldDefineInfo field in Configuration.DataTableSchema.Schema.FieldInfos)
                    {
                        SheetView.Cells[field.RangeInfo].BackColor = Color.LightPink;
                        SheetView.Cells[field.RangeInfo].Tag       = field;
                    }
                }

                lView_ExtentDataItems.Items.Clear();
                foreach (FieldDefineInfo fieldInfo in ModelInfo.ExtentDataSchema.FieldInfos)
                {
                    ListViewItem Item = new ListViewItem();
                    Item.Text = fieldInfo.FieldName;
                    Item.Tag  = fieldInfo;
                    Item.SubItems.Add(fieldInfo.Description);
                    Item.SubItems.Add(fieldInfo.FieldType.Description);


                    lView_ExtentDataItems.Items.Add(Item);
                }
            }
            catch (Exception ex)
            {
                ErrorInfo = ex.Message;
            }

            this.RemoveOwnedForm(ProgressScreen.Current);
            ProgressScreen.Current.CloseSplashScreen();
            Activate();

            label2.BackColor = Color.LightPink;

            if (ErrorInfo != "")
            {
                MessageBox.Show("加载模板出错!\r\n原因:" + ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #13
0
        public bool DeleteSheetConfiguration(SheetConfiguration Sheet)
        {
            //增加字段Scts_1,Scdel 之后 删除操作只做伪删除,便于数据同步   2013-10-17
            StringBuilder Sql_Sheet = new StringBuilder();

            //Sql_Sheet.Append("Delete From sys_biz_Sheet Where ID ='");
            //Sql_Sheet.Append(Sheet.Index);
            //Sql_Sheet.Append("'");
            Sql_Sheet.Append("Update sys_biz_Sheet Set Scts_1=Getdate(),Scdel=1 Where ID ='");
            Sql_Sheet.Append(Sheet.Index);
            Sql_Sheet.Append("'");

            StringBuilder Sql_DataArea = new StringBuilder();

            if (Sheet.DataTableSchema.Schema != null)
            {
                //增加字段Scts_1,Scdel 之后 删除操作只做伪删除,便于数据同步   2013-10-17
                //Sql_DataArea.Append("Delete From sys_biz_DataArea Where SheetID ='");
                //Sql_DataArea.Append(Sheet.Index);
                //Sql_DataArea.Append("' and TableName='");
                //Sql_DataArea.Append(Sheet.DataTableSchema.Schema.Name);
                //Sql_DataArea.Append("'");
                Sql_DataArea.Append("Update sys_biz_DataArea Set Scts_1=Getdate(),Scdel=1 Where SheetID ='");
                Sql_DataArea.Append(Sheet.Index);
                Sql_DataArea.Append("' and TableName='");
                Sql_DataArea.Append(Sheet.DataTableSchema.Schema.Name);
                Sql_DataArea.Append("'");
            }
            StringBuilder Sql_Column = new StringBuilder();

            if (Sheet.DataTableSchema.Schema != null)
            {
                //增加字段Scts_1,Scdel 之后 删除操作只做伪删除,便于数据同步   2013-10-17
                //Sql_Column.Append("Delete From sys_columns Where  TableName='");
                //Sql_Column.Append(Sheet.DataTableSchema.Schema.Name);
                //Sql_Column.Append("'");
                Sql_Column.Append("Update sys_columns Set Scts_1=Getdate(),Scdel=1 Where TableName='");
                Sql_Column.Append(Sheet.DataTableSchema.Schema.Name);
                Sql_Column.Append("'");
            }
            StringBuilder Sql_SheetDrop = new StringBuilder();

            if (Sheet.DataTableSchema.Schema != null)
            {
                Sql_SheetDrop.Append("drop table [" + Sheet.DataTableSchema.Schema.Name + "]");
            }

            List <string> sql_Commands = new List <string>();

            sql_Commands.Add(Sql_Sheet.ToString());
            if (Sheet.DataTableSchema.Schema != null)
            {
                sql_Commands.Add(Sql_DataArea.ToString());
                sql_Commands.Add(Sql_Column.ToString());
                sql_Commands.Add(Sql_SheetDrop.ToString());
            }

            Boolean Result = false;

            IDbConnection Connection  = GetConntion();
            Transaction   Transaction = new Transaction(Connection);

            try
            {
                object r    = ExcuteCommands(sql_Commands.ToArray(), Transaction);
                int[]  ints = (int[])r;
                for (int i = 0; i < ints.Length; i++)
                {
                    if (i != 0)
                    {
                        Result = Result & (Convert.ToInt32(ints[i]) == 1);
                    }
                    else
                    {
                        Result = (Convert.ToInt32(ints[i]) == 1);
                    }
                }

                if (Result)
                {
                    Transaction.Commit();
                }
                else
                {
                    Transaction.Rollback();
                }
            }
            catch
            {
                Transaction.Rollback();
            }

            if (Sheet.DataTableSchema.Schema != null)
            {
                Result = Result & DataSchemaManager.DeleteTableStruct(Sheet.DataTableSchema.Schema.Name);
            }

            return(Result);
        }
Beispiel #14
0
        public bool UpdateSheetConfiguration(SheetConfiguration Sheet)
        {
            Boolean Result = false;

            StringBuilder Sql_Sheets = new StringBuilder();

            //2013-10-17  增加查询条件  Scdel=0   0未删除  1已删除
            Sql_Sheets.Append("Select ID,SCTS,CatlogCode,Description,SheetStyle,DataTable,SCTS_1,Scdel From sys_biz_Sheet Where Scdel=0 and ID='");
            Sql_Sheets.Append(Sheet.Index);
            Sql_Sheets.Append("'");

            StringBuilder Sql_DataAreas = new StringBuilder();

            //2013-10-17  增加查询条件  Scdel=0   0未删除  1已删除
            Sql_DataAreas.Append("Select ID,SCTS,SheetID,TableName,ColumnName,Range,SCTS_1,Scdel From sys_biz_DataArea Where Scdel=0 and SheetID='");
            Sql_DataAreas.Append(Sheet.Index);
            Sql_DataAreas.Append("'");

            List <string> sql_Commands = new List <string>();

            sql_Commands.Add(Sql_Sheets.ToString());
            sql_Commands.Add(Sql_DataAreas.ToString());

            DataSet dataset = GetDataSet(sql_Commands.ToArray());

            if (dataset != null)
            {
                DataTable DataSheets = dataset.Tables["sys_biz_Sheet"];
                DataTable DataAreas  = dataset.Tables["sys_biz_DataArea"];

                if (DataSheets != null)
                {
                    if (DataSheets.Rows.Count > 0)
                    {
                        DataRow SheetRow = DataSheets.Rows[0];
                        SheetRow["ID"]          = Sheet.Index;
                        SheetRow["SCTS"]        = DateTime.Now.ToString();
                        SheetRow["CatlogCode"]  = Sheet.Code;
                        SheetRow["Description"] = Sheet.Description;
                        SheetRow["SheetStyle"]  = Sheet.SheetStyle;
                        SheetRow["SCTS_1"]      = DateTime.Now.ToString();

                        if (Sheet.DataTableSchema.Schema != null)
                        {
                            foreach (FieldDefineInfo fieldInfo in Sheet.DataTableSchema.Schema.FieldInfos)
                            {
                                DataRow[] AreaRows = DataAreas.Select("SheetID='" + Sheet.Index + "' and TableName='" + Sheet.DataTableSchema.Schema.Name + "' and ColumnName='" + fieldInfo.FieldName + "'");
                                if (AreaRows.Length > 0)
                                {
                                    AreaRows[0]["SheetID"]    = Sheet.Index;
                                    AreaRows[0]["SCTS"]       = DateTime.Now.ToString();
                                    AreaRows[0]["TableName"]  = Sheet.DataTableSchema.Schema.Name;
                                    AreaRows[0]["ColumnName"] = fieldInfo.FieldName;
                                    AreaRows[0]["Range"]      = fieldInfo.RangeInfo;
                                    AreaRows[0]["SCTS_1"]     = DateTime.Now.ToString();
                                }
                                else
                                {
                                    DataRow AreaRow = DataAreas.NewRow();
                                    AreaRow["ID"]         = Guid.NewGuid().ToString();
                                    AreaRow["SCTS"]       = DateTime.Now.ToString();
                                    AreaRow["SheetID"]    = Sheet.Index;
                                    AreaRow["TableName"]  = Sheet.DataTableSchema.Schema.Name;
                                    AreaRow["ColumnName"] = fieldInfo.FieldName;
                                    AreaRow["Range"]      = fieldInfo.RangeInfo;
                                    AreaRows[0]["SCTS_1"] = DateTime.Now.ToString();
                                    DataAreas.Rows.Add(AreaRow);
                                }
                            }

                            SheetRow["DataTable"] = Sheet.DataTableSchema.Schema.Name;
                        }
                        else
                        {
                            SheetRow["DataTable"] = "";
                        }
                    }
                    else
                    {
                        DataRow SheetRow = DataSheets.NewRow();
                        SheetRow["ID"]          = Sheet.Index;
                        SheetRow["SCTS"]        = DateTime.Now.ToString();
                        SheetRow["CatlogCode"]  = Sheet.Code;
                        SheetRow["Description"] = Sheet.Description;
                        SheetRow["SheetStyle"]  = Sheet.SheetStyle;
                        SheetRow["SCTS_1"]      = DateTime.Now.ToString();

                        if (Sheet.DataTableSchema.Schema != null)
                        {
                            foreach (FieldDefineInfo fieldInfo in Sheet.DataTableSchema.Schema.FieldInfos)
                            {
                                DataRow[] AreaRows = DataAreas.Select("SheetID='" + Sheet.Index + "' and TableName='" + Sheet.DataTableSchema.Schema.Name + "' and ColumnName='" + fieldInfo.FieldName + "'");
                                if (AreaRows.Length > 0)
                                {
                                    AreaRows[0]["SheetID"]    = Sheet.Index;
                                    AreaRows[0]["SCTS"]       = DateTime.Now.ToString();
                                    AreaRows[0]["TableName"]  = Sheet.DataTableSchema.Schema.Name;
                                    AreaRows[0]["ColumnName"] = fieldInfo.FieldName;
                                    AreaRows[0]["Range"]      = fieldInfo.RangeInfo;
                                    AreaRows[0]["SCTS_1"]     = DateTime.Now.ToString();
                                }
                                else
                                {
                                    DataRow AreaRow = DataAreas.NewRow();
                                    AreaRow["ID"]         = Guid.NewGuid().ToString();
                                    AreaRow["SCTS"]       = DateTime.Now.ToString();
                                    AreaRow["SheetID"]    = Sheet.Index;
                                    AreaRow["TableName"]  = Sheet.DataTableSchema.Schema.Name;
                                    AreaRow["ColumnName"] = fieldInfo.FieldName;
                                    AreaRow["Range"]      = fieldInfo.RangeInfo;
                                    AreaRows[0]["SCTS_1"] = DateTime.Now.ToString();
                                    DataAreas.Rows.Add(AreaRow);
                                }
                            }

                            SheetRow["DataTable"] = Sheet.DataTableSchema.Schema.Name;
                        }
                        else
                        {
                            SheetRow["DataTable"] = "";
                        }

                        DataSheets.Rows.Add(SheetRow);
                    }
                }

                IDbConnection Connection  = GetConntion();
                Transaction   Transaction = new Transaction(Connection);

                try
                {
                    object r = Update(dataset, Transaction);
                    Result = (Convert.ToInt32(r) == 1);

                    if (Result)
                    {
                        Transaction.Commit();
                    }
                    else
                    {
                        Transaction.Rollback();
                    }
                }
                catch
                {
                    Transaction.Rollback();
                }
            }

            return(Result);
        }
Beispiel #15
0
        public List <SheetConfiguration> InitSheetConfiguration(string[] Indexes)
        {
            SheetConfiguration[] Configurations = new SheetConfiguration[Indexes.Length];

            StringBuilder Sql_Sheets = new StringBuilder();

            //增加查询条件Scdel=0   2013-10-19
            Sql_Sheets.Append("Select ID,Description,CatlogCode,SheetStyle,DataTable from sys_biz_Sheet where Scdel=0 and ID in ('");
            Sql_Sheets.Append(string.Join("','", Indexes));
            Sql_Sheets.Append("')");

            StringBuilder Sql_Tables = new StringBuilder();

            //增加查询条件Scdel=0   2013-10-19
            Sql_Tables.Append("Select * from sys_Tables where Scdel=0 and TableName in (");
            Sql_Tables.Append("Select DataTable from sys_biz_Sheet where Scdel=0 and ID in ('");
            Sql_Tables.Append(string.Join("','", Indexes));
            Sql_Tables.Append("'))");

            StringBuilder Sql_FieldInfos = new StringBuilder();

            //增加查询条件Scdel=0   2013-10-19
            Sql_FieldInfos.Append("Select * from sys_Columns where Scdel=0 and TableName in (");
            Sql_FieldInfos.Append("Select DataTable from sys_biz_Sheet where Scdel=0 and ID in ('");
            Sql_FieldInfos.Append(string.Join("','", Indexes));
            Sql_FieldInfos.Append("'))");
            Sql_FieldInfos.Append(" order by scts");

            StringBuilder Sql_DataAreas = new StringBuilder();

            //增加查询条件Scdel=0   2013-10-19
            Sql_DataAreas.Append("Select SheetID,TableName,ColumnName,Range From sys_biz_DataArea Where Scdel=0 and SheetID in ('");
            Sql_DataAreas.Append(string.Join("','", Indexes));
            Sql_DataAreas.Append("')");

            List <string> sql_Commands = new List <string>();

            sql_Commands.Add(Sql_Sheets.ToString());
            sql_Commands.Add(Sql_Tables.ToString());
            sql_Commands.Add(Sql_FieldInfos.ToString());
            sql_Commands.Add(Sql_DataAreas.ToString());

            DataSet dataset = GetDataSet(sql_Commands.ToArray());

            if (dataset != null)
            {
                DataTable DataSheets = dataset.Tables["sys_biz_Sheet"];
                DataTable DataTables = dataset.Tables["sys_Tables"];
                DataTable DataFields = dataset.Tables["sys_Columns"];
                DataTable DataAreas  = dataset.Tables["sys_biz_DataArea"];

                foreach (DataRow SheetRow in DataSheets.Rows)
                {
                    SheetConfiguration Configuration = new SheetConfiguration();
                    Configuration.Index       = SheetRow["ID"].ToString();
                    Configuration.Code        = SheetRow["CatlogCode"].ToString();
                    Configuration.SheetStyle  = SheetRow["SheetStyle"].ToString();
                    Configuration.Description = SheetRow["Description"].ToString();

                    string DataTable = SheetRow["DataTable"].ToString();
                    if (!string.IsNullOrEmpty(DataTable))
                    {
                        DataRow[] TableRows = DataTables.Select("TableName = '" + DataTable + "'");
                        if (TableRows.Length > 0)
                        {
                            Configuration.DataTableSchema.Schema             = new TableDefineInfo();
                            Configuration.DataTableSchema.Schema.Name        = DataTable;
                            Configuration.DataTableSchema.Schema.Description = TableRows[0]["DESCRIPTION"].ToString();
                            Configuration.DataTableSchema.Schema.Index       = TableRows[0]["ID"].ToString();

                            DataRow[] FieldRows = DataFields.Select("TableName = '" + DataTable + "'", "colname");
                            foreach (DataRow FieldRow in FieldRows)
                            {
                                FieldDefineInfo FieldInfo = new FieldDefineInfo(Configuration.DataTableSchema.Schema);
                                FieldInfo.Index       = FieldRow["ID"].ToString();
                                FieldInfo.Description = FieldRow["DESCRIPTION"].ToString();
                                FieldInfo.FieldName   = FieldRow["COLNAME"].ToString();
                                FieldInfo.IsKeyField  = (FieldRow["IsKeyField"] != DBNull.Value ? Convert.ToBoolean(FieldRow["IsKeyField"]) : false);

                                String scpt = FieldRow["scpt"].ToString();
                                FieldInfo.IsNotNull  = ((scpt.Length > 0 ? scpt.Substring(0, 1) : "0") == "1" ? true : false);
                                FieldInfo.IsNotCopy  = ((scpt.Length > 1 ? scpt.Substring(1, 1) : "0") == "1" ? true : false);
                                FieldInfo.IsPingxing = ((scpt.Length > 2 ? scpt.Substring(2, 1) : "0") == "1" ? true : false);
                                FieldInfo.IsReadOnly = ((scpt.Length > 3 ? scpt.Substring(3, 1) : "0") == "1" ? true : false);

                                String ColType = FieldRow["COLType"].ToString();
                                FieldInfo.FieldType = FieldType.GetFieldType(ColType);

                                DataRow[] dataAreas = DataAreas.Select("SheetID='" + Configuration.Index + "' and TableName='" + DataTable + "' and ColumnName='" + FieldInfo.FieldName + "'");
                                if (dataAreas.Length > 0)
                                {
                                    FieldInfo.RangeInfo = dataAreas[0]["Range"].ToString();
                                }
                            }
                        }
                    }

                    int Index = Array.IndexOf(Indexes, Configuration.Index);
                    Configurations[Index] = Configuration;
                }
            }

            return(new List <SheetConfiguration>(Configurations));
        }
Beispiel #16
0
        private void ButtonOk_Click(object sender, EventArgs e)
        {
            if (modelInfo == null)
            {
                return;
            }

            modelIndex = modelInfo.Index;
            modelText  = modelInfo.Description;

            ModelFields.Clear();

            if (CheckBox_ModelIndex.Checked)
            {
                ModelFields.Add(string.Concat("'", modelIndex, "'"));
            }
            if (CheckBox_ModelName.Checked)
            {
                ModelFields.Add(string.Concat("'", modelText, "'"));
            }
            if (CheckBox_SCTS.Checked)
            {
                ModelFields.Add(string.Concat("biz_norm_extent_", modelIndex, ".SCTS"));
            }
            if (CheckBox_SCPT.Checked)
            {
                ModelFields.Add(string.Concat("biz_norm_extent_", modelIndex, ".SCPT"));
            }
            if (CheckBox_SCCT.Checked)
            {
                ModelFields.Add(string.Concat("biz_norm_extent_", modelIndex, ".SCCT"));
            }

            foreach (SheetView Sheet in FpSpread.Sheets)
            {
                if (Sheet.Tag is SheetConfiguration)
                {
                    SheetConfiguration sheetConfiguration = Sheet.Tag as SheetConfiguration;
                    TableDefineInfo    TableSchema        = sheetConfiguration.DataTableSchema.Schema;
                    if (TableSchema != null)
                    {
                        foreach (FieldDefineInfo FieldInfo in TableSchema.FieldInfos)
                        {
                            if (Sheet.Cells[FieldInfo.RangeInfo].BackColor == Color.Blue)
                            {
                                ModelFields.Add(string.Concat("[", TableSchema.Name, "].[", FieldInfo.FieldName, "]"));
                            }
                        }
                    }
                }
                else
                {
                    foreach (Row Row in Sheet.Rows)
                    {
                        if (Row.BackColor == Color.Blue)
                        {
                            ModelFields.Add(string.Concat("[", Sheet.Tag.ToString(), "].[", Sheet.Cells[Row.Index, 0].Text, "]"));
                        }
                    }
                }
            }

            this.DialogResult = DialogResult.OK;
            Close();
        }