private void NewSheet() { TreeNode Node = FpSheetView.SelectedNode; Boolean IsSheet = Convert.ToBoolean(Node.Tag); if (!IsSheet) { string Code = DepositorySheetCatlog.GetNextCode(Node.Name); string SheetName = DepositorySheetConfiguration.GetSheetName(Node.Name, "新建表单"); Sys_Sheet sheet = new Sys_Sheet(); sheet.ID = Guid.NewGuid(); sheet.CatlogCode = Code; sheet.SheetData = ""; sheet.Name = SheetName; sheet.SheetXML = JZCommonHelper.GZipCompressString(SheetConfiguration.BlankSheet); Boolean Result = ModuleHelperClient.SaveSheet(sheet); if (Result) { TreeNode SubNode = new TreeNode(); SubNode.Name = sheet.ID.ToString(); SubNode.Text = SheetName; SubNode.SelectedImageIndex = 2; SubNode.ImageIndex = 2; SubNode.Tag = true; Node.Nodes.Add(SubNode); Node.Expand(); Node.TreeView.SelectedNode = SubNode; } } }
private void btnSave_Click(object sender, EventArgs e) { int reportIndex = Convert.ToInt32(NumberIndex.Value); reportIndex--; if (reportIndex < 0) { MessageBox.Show("报告索引不能小于1"); NumberIndex.Focus(); return; } Boolean bResult = ModuleHelperClient.UpdateReportIndex(ModuleID, reportIndex, ComboCatlog.Text); if (bResult) { MessageBox.Show("设置成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("设置失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } //this.DialogResult = DialogResult.Yes; this.Close(); }
private void CopySheet() { TreeNode Node = FpSheetView.SelectedNode; Boolean IsSheet = Convert.ToBoolean(Node.Tag); if (IsSheet) { Guid newSheetID = Guid.NewGuid(); if (DialogResult.OK == MessageBox.Show("确定要复制表单‘" + Node.Text + "’吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information)) { Boolean Result = ModuleHelperClient.CopySheet(new Guid(Node.Name), newSheetID, Node.Text + "-副本"); if (Result) { TreeNode SubNode = new TreeNode(); SubNode.Name = newSheetID.ToString(); SubNode.Text = Node.Text + "-副本"; SubNode.SelectedImageIndex = 2; SubNode.ImageIndex = 2; SubNode.Tag = true; Node.Parent.Nodes.Add(SubNode); Node.TreeView.SelectedNode = SubNode; SubNode.EnsureVisible(); } String Message = (Result ? "复制表单成功。" : "复制表单失败!"); MessageBoxIcon Icon = (Result ? MessageBoxIcon.Information : MessageBoxIcon.Error); MessageBox.Show(Message, "提示", MessageBoxButtons.OK, Icon); } } }
private void ModelDesigner_Load(object sender, EventArgs e) { sheetsList = ModuleHelperClient.GetSheetsByModuleID(moduleID); ImportSheetButton.Visible = !ForLine; RemoveSheetButton.Visible = !ForLine; WriteFunctionButton.Visible = !ForLine; toolStripSeparator2.Visible = !ForLine; toolStripSeparator3.Visible = !ForLine; LoadSheets(); }
private void ReportIndexSettingDialog_Load(object sender, EventArgs e) { //rbSDWai.Checked = true; var set = ModuleHelperClient.GetReportIndex(ModuleID); if (set == null) { return; } var setTable = set.Tables["Setting"]; var catlogTable = set.Tables["Catlog"]; if (catlogTable != null) { foreach (DataRow row in catlogTable.Rows) { var catlog = Convert.ToString(row["StatisticsCatlog"]); if (string.IsNullOrEmpty(catlog) == false) { if (ComboCatlog.Items.Contains(catlog) == false) { ComboCatlog.Items.Add(catlog); } } } } if (setTable != null && setTable.Rows != null && setTable.Rows.Count > 0) { var row = setTable.Rows[0]; var reportIndex = Convert.ToInt32(row["ReportIndex"]); reportIndex++; NumberIndex.Value = reportIndex; if (reportIndex <= 0) { MessageBox.Show("序号初始化异常,请谨慎操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } var catlog = Convert.ToString(row["StatisticsCatlog"]); ComboCatlog.Text = catlog; } }
private void DeleteModule() { TreeNode Node = TemplateTree.SelectedNode; Boolean IsModule = Convert.ToBoolean(Node.Tag); string Msg = "你确定要删除模板 ‘" + Node.Text + "’ 吗?"; if (IsModule && DialogResult.Yes == MessageBox.Show(Msg, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk)) { if (!ModuleHelperClient.IsModuleUsing(new Guid(Node.Name))) { ModuleHelperClient.DeleteModule(new Guid(Node.Name)); Node.Remove(); } else { String Info = "删除失败,因为工程结构使用了该模板。"; MessageBox.Show(Info, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// 保存模块 /// </summary> private void SaveModule() { Boolean Result = false; if (ForLine) { Result = ModuleHelperClient.SaveLineFormula(moduleID, CrossSheetFormulaCache); } else { Result = ModuleHelperClient.SaveModule(moduleID, sheetsList, CrossSheetFormulaCache); } String msg = Result ? "保存模板成功。" : "保存模板失败。"; MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ReportIndexSettingDialog dlgRIS = new ReportIndexSettingDialog(moduleID, sheetsList.Count); dlgRIS.ShowDialog(); }
private void DeleteSheet() { TreeNode Node = FpSheetView.SelectedNode; Boolean IsSheet = Convert.ToBoolean(Node.Tag); string Msg = "你确定要删除表单 ‘" + Node.Text + "’ 吗?"; if (IsSheet && DialogResult.Yes == MessageBox.Show(Msg, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk)) { if (!ModuleHelperClient.IsSheetUsing(new Guid(Node.Name))) { if (ModuleHelperClient.DeleteSheet(new Guid(Node.Name))) { Node.Remove(); } } else { String Info = "删除失败,因为有模板使用了该表单。"; MessageBox.Show(Info, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void FpSheetView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { if (e.Label != null) { if (e.Label.Length > 0) { if (e.Label.IndexOfAny(new char[] { '@', '.', ',', '!' }) == -1) { e.Node.EndEdit(false); Boolean IsSheet = Convert.ToBoolean(e.Node.Tag); if (!IsSheet) { ModuleHelperClient.UpdateSheetCatelogName(new Guid(e.Node.Name), e.Label); } else { ModuleHelperClient.UpdateSheetName(new Guid(e.Node.Name), e.Label); } } else { e.CancelEdit = true; MessageBox.Show("无效的树节点文本.\n" + "无效的字符是: '@','.', ',', '!'", "编辑节点"); e.Node.BeginEdit(); } } else { e.CancelEdit = true; MessageBox.Show("无效的树节点文本.\n文本不能为空", "编辑节点"); e.Node.BeginEdit(); } e.Node.TreeView.LabelEdit = false; } }
private void NewModule() { TreeNode Node = TemplateTree.SelectedNode; Boolean IsModule = Convert.ToBoolean(Node.Tag); if (!IsModule) { string Code = DepositoryResourceCatlog.GetNextCode(Node.Name); string ModuleName = "新建模板"; Sys_Module module = new Sys_Module(); module.ID = Guid.NewGuid(); module.ModuleSettings = new List <ModuleSetting>(); module.Name = ModuleName; module.Description = ModuleName; module.CatlogCode = Code; Boolean Result = ModuleHelperClient.NewModule(module); if (Result) { TreeNode SubNode = new TreeNode(); SubNode.Name = module.ID.ToString(); SubNode.Text = ModuleName; SubNode.SelectedImageIndex = 2; SubNode.ImageIndex = 2; SubNode.Tag = true; Node.Nodes.Add(SubNode); Node.Expand(); Node.TreeView.SelectedNode = SubNode; Node.TreeView.SelectedNode.TreeView.LabelEdit = true; Node.TreeView.SelectedNode.BeginEdit(); } } }
/// <summary> /// 保存表单样式 /// </summary> private void SaveSheetStyle() { try { Sys_Sheet sheet = new Sys_Sheet(); sheet.ID = sheetID; sheet.Name = SheetName; sheet.SheetXML = JZCommonHelper.GZipCompressString(Editor.GetActiveSheetXml()); List <JZCell> cells = new List <JZCell>(); List <CellLogic> cellLogicList = new List <CellLogic>(); List <JZFormulaData> cellFormulasList = new List <JZFormulaData>(); //bool bIsKeyDescEmpty = false; #region CellLogic foreach (Cell cell in dataCells) { if (cell == null) { continue; } JZCell c = new JZCell(); c.Name = cell.Column.Label + cell.Row.Label; c.Value = cell.Value; bool bHasExist = false; foreach (JZCell cc in cells) { if (cc.Name == c.Name) { bHasExist = true; break; } } if (bHasExist == true) { continue; } cells.Add(c); CellLogic cl = new CellLogic(); cl.Name = c.Name; JZCellProperty p = cell.Tag as JZCellProperty; if (p != null) { cl.Description = p.Description; cl.IsKey = p.IsKey; cl.IsNotCopy = p.IsNotCopy; cl.IsNotNull = p.IsNotNull; cl.IsPingxing = p.IsPingxing; cl.IsReadOnly = p.IsReadOnly; cl.IsUnique = p.IsUnique; if (cl.IsKey == true && string.IsNullOrEmpty(cl.Description)) { //bIsKeyDescEmpty = true; MessageBox.Show(string.Format("单元格{0}的描述不能为空", c.Name)); return; } } cellLogicList.Add(cl); } #endregion #region Formulas if (FpSpread.Sheets[0] != null) { for (int j = 0; j < FpSpread.Sheets[0].ColumnCount; j++) { for (int m = 0; m < FpSpread.Sheets[0].RowCount; m++) { Cell c = FpSpread.Sheets[0].Cells[m, j]; JZFormulaData cl = new JZFormulaData(); if (c != null) { if (!string.IsNullOrEmpty(c.Formula)) { //logger.Error(string.Format("Name:{0} ColumnIndex:{1} RowIndex:{2} Formula:{3} ", ((char)('A' + c.Column.Index)).ToString() + (c.Row.Index + 1).ToString(), c.Column.Index, c.Row.Index, c.Formula)); cl.ColumnIndex = c.Column.Index; cl.RowIndex = c.Row.Index; cl.Formula = c.Formula; cellFormulasList.Add(cl); } } } } } #endregion sheet.SheetData = Newtonsoft.Json.JsonConvert.SerializeObject(cells); sheet.CellLogic = JZCommonHelper.GZipCompressString(Newtonsoft.Json.JsonConvert.SerializeObject(cellLogicList)); sheet.Formulas = JZCommonHelper.GZipCompressString(Newtonsoft.Json.JsonConvert.SerializeObject(cellFormulasList)); if (ModuleHelperClient.SaveSheet(sheet)) { MessageBox.Show("保存成功。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("保存失败。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("保存失败。" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void SheetDesinger_Load(object sender, EventArgs e) { ProgressScreen.Current.ShowSplashScreen(); this.AddOwnedForm(ProgressScreen.Current); ProgressScreen.Current.SetStatus = "正在初始化表单..."; try { Sys_Sheet sheetItem = ModuleHelperClient.GetSheetItemByID(sheetID); FpSpread.Sheets.Clear(); if (ModuleHelperClient.IsContainerXml(sheetItem.SheetXML)) { sheetItem.SheetXML = sheetItem.SheetXML; } else { sheetItem.SheetXML = JZCommonHelper.GZipDecompressString(sheetItem.SheetXML); } SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetItem.SheetXML, "SheetView") as SheetView; SheetView.SheetName = sheetItem.Name; List <FarPoint.CalcEngine.FunctionInfo> Infos = FunctionItemInfoUtil.getFunctionItemInfos(); foreach (FarPoint.CalcEngine.FunctionInfo Info in Infos) { SheetView.AddCustomFunction(Info); } List <JZCell> sheetDataAreaCells = Newtonsoft.Json.JsonConvert.DeserializeObject <List <JZCell> >(sheetItem.SheetData); if (sheetDataAreaCells != null) { foreach (JZCell cell in sheetDataAreaCells) { dataCells.Add(SheetView.Cells[cell.Name]); } } FpSpread.Sheets.Add(SheetView); dtCellStyle = ModuleHelperClient.GetCellStyleBySheetID(sheetID); for (int i = 0; i < dtCellStyle.Rows.Count; i++) { if (dtCellStyle.Rows[i]["CellStyle"] != null) { JZCellStyle CurrentCellStyle = Newtonsoft.Json.JsonConvert.DeserializeObject <JZCellStyle>(dtCellStyle.Rows[i]["CellStyle"].ToString()); if (CurrentCellStyle != null) { string strCellName = dtCellStyle.Rows[i]["CellName"].ToString(); Cell cell = SheetView.Cells[strCellName]; cell.ForeColor = CurrentCellStyle.ForColor; cell.BackColor = CurrentCellStyle.BackColor; cell.Font = new Font(CurrentCellStyle.FamilyName, CurrentCellStyle.FontSize, CurrentCellStyle.FontStyle); } } } FpSpread.LoadFormulas(true); fpSheetEditor1.EnableToolStrip(true); UpdateChart(); UpdateEquation(); } catch (Exception ex) { MessageBox.Show("加载表单出错!\r\n原因:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.RemoveOwnedForm(ProgressScreen.Current); ProgressScreen.Current.CloseSplashScreen(); this.Activate(); } }
private void LoadSheets() { ProgressScreen.Current.ShowSplashScreen(); this.AddOwnedForm(ProgressScreen.Current); Dictionary <Guid, SheetView> SheetCollection = new Dictionary <Guid, SheetView>(); List <FarPoint.CalcEngine.FunctionInfo> Infos = FunctionItemInfoUtil.getFunctionItemInfos(); try { CrossSheetFormulaCache.Clear(); FpSpread.Sheets.Clear(); List <JZFormulaData> CrossSheetLineFormulaInfos = ModuleHelperClient.GetLineFormulaByModuleIndex(moduleID); foreach (Sys_Sheet sheet in sheetsList) { ProgressScreen.Current.SetStatus = "正在初始化表单‘" + sheet.Name + "’"; String sheetXML = ModuleHelperClient.GetSheetXMLByID(sheet.ID); SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetXML, "SheetView") as SheetView; SheetView.Tag = sheet.ID; SheetView.SheetName = sheet.Name; SheetView.ZoomFactor = 1.0F; FpSpread.Sheets.Add(SheetView); DataTable dtCellStyle = ModuleHelperClient.GetCellStyleBySheetID(sheet.ID); for (int i = 0; i < dtCellStyle.Rows.Count; i++) { if (dtCellStyle.Rows[i]["CellStyle"] != null) { JZCellStyle CurrentCellStyle = Newtonsoft.Json.JsonConvert.DeserializeObject <JZCellStyle>(dtCellStyle.Rows[i]["CellStyle"].ToString()); if (CurrentCellStyle != null) { string strCellName = dtCellStyle.Rows[i]["CellName"].ToString(); Cell cell = SheetView.Cells[strCellName]; cell.ForeColor = CurrentCellStyle.ForColor; cell.BackColor = CurrentCellStyle.BackColor; cell.Font = new Font(CurrentCellStyle.FamilyName, CurrentCellStyle.FontSize, CurrentCellStyle.FontStyle); } } } foreach (FarPoint.CalcEngine.FunctionInfo Info in Infos) { SheetView.AddCustomFunction(Info); } if (!SheetCollection.ContainsKey(sheet.ID)) { SheetCollection.Add(sheet.ID, SheetView); } } FpSpread.LoadFormulas(true); foreach (JZFormulaData formula in CrossSheetLineFormulaInfos) { if (!SheetCollection.ContainsKey(formula.SheetIndex)) { continue; } SheetView Sheet = SheetCollection[formula.SheetIndex]; Cell cell = Sheet.Cells[formula.RowIndex, formula.ColumnIndex]; if (cell != null) { if (formula.Formula.ToUpper().Trim() == "NA()") { cell.Formula = ""; } else { cell.Formula = formula.Formula; } if (formula.FormulaType == 1) { cell.BackColor = Color.Blue; } string key = string.Format("{0}_{1}_{2}", formula.SheetIndex, formula.RowIndex, formula.ColumnIndex); if (ForLine) {//线路公式 if (formula.FormulaType == 1) { if (!CrossSheetFormulaCache.ContainsKey(key)) { CrossSheetFormulaCache.Add(key, formula); } else { CrossSheetFormulaCache[key] = formula; } } } else { if (!CrossSheetFormulaCache.ContainsKey(key)) { CrossSheetFormulaCache.Add(key, formula); } else { CrossSheetFormulaCache[key] = formula; } } } } FpSpread.LoadFormulas(true); fpSpreadEditor1.EnableToolStrip(true); UpdateChart(); UpdateEquation(); } catch (Exception ex) { MessageBox.Show("加载模板出错!\r\n原因:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.RemoveOwnedForm(ProgressScreen.Current); ProgressScreen.Current.CloseSplashScreen(); this.Activate(); } }
private void LoadSpread(Guid moduleID) { try { ProgressScreen.Current.ShowSplashScreen(); ProgressScreen.Current.SetStatus = "正在打开模板..."; FpSpread = new MyCell(); //增加水印、图章 FpSpread.Watermark = ModuleHelperClient.GetWatermarkByModuleID(moduleID); Dictionary <Guid, SheetView> SheetCollection = new Dictionary <Guid, SheetView>(); List <FarPoint.CalcEngine.FunctionInfo> Infos = FunctionItemInfoUtil.getFunctionItemInfos(); JZDocument defaultDocument = ModuleHelperClient.GetDefaultDocument(moduleID); List <JZFormulaData> CrossSheetLineFormulaInfos = ModuleHelperClient.GetLineFormulaByModuleIndex(moduleID); foreach (JZSheet sheet in defaultDocument.Sheets) { ProgressScreen.Current.SetStatus = "正在初始化表单‘" + sheet.Name + "’"; String sheetXML = ModuleHelperClient.GetSheetXMLByID(sheet.ID); SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetXML, "SheetView") as SheetView; SheetView.Tag = sheet.ID; SheetView.SheetName = sheet.Name; SheetView.Cells[0, 0].Value = ""; SheetView.Protect = true; FpSpread.Sheets.Add(SheetView); DataTable dtCellStyle = ModuleHelperClient.GetCellStyleBySheetID(sheet.ID); for (int i = 0; i < dtCellStyle.Rows.Count; i++) { if (dtCellStyle.Rows[i]["CellStyle"] != null) { JZCellStyle CurrentCellStyle = Newtonsoft.Json.JsonConvert.DeserializeObject <JZCellStyle>(dtCellStyle.Rows[i]["CellStyle"].ToString()); if (CurrentCellStyle != null) { string strCellName = dtCellStyle.Rows[i]["CellName"].ToString(); Cell cell = SheetView.Cells[strCellName]; cell.ForeColor = CurrentCellStyle.ForColor; cell.BackColor = CurrentCellStyle.BackColor; cell.Font = new Font(CurrentCellStyle.FamilyName, CurrentCellStyle.FontSize, CurrentCellStyle.FontStyle); } } } SheetCollection.Add(sheet.ID, SheetView); foreach (FarPoint.CalcEngine.FunctionInfo Info in Infos) { SheetView.AddCustomFunction(Info); } } ProgressScreen.Current.SetStatus = "正在初始化跨表公式..."; FpSpread.LoadFormulas(false); foreach (JZFormulaData formula in CrossSheetLineFormulaInfos) { if (!SheetCollection.ContainsKey(formula.SheetIndex)) { continue; } SheetView Sheet = SheetCollection[formula.SheetIndex]; Cell cell = Sheet.Cells[formula.RowIndex, formula.ColumnIndex]; if (cell != null) { try { if (formula.Formula.ToUpper().Trim() == "NA()") { cell.Formula = ""; } else { cell.Formula = formula.Formula; } } catch { } } } FpSpread.LoadFormulas(true); ProgressScreen.Current.SetStatus = "正在显示资料..."; } catch (Exception ex) { logger.Error(ex.ToString()); } finally { try { //this.RemoveOwnedForm(ProgressScreen.Current); ProgressScreen.Current.CloseSplashScreen(); } catch { } } }