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; } } }
/// <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); } }