private void IsSave() { if (!editrights) { return; } if (MsgBox.ShowYesNo("数据已经发生改变,是否保存?") != DialogResult.Yes) { return; } WaitDialogForm wait = null; PspType obj = Services.BaseService.GetOneByKey <PspType>(uid1); System.IO.MemoryStream ms = new System.IO.MemoryStream(); try { wait = new WaitDialogForm("", "正在保存数据, 请稍候..."); obj.Contents = ms.GetBuffer(); Services.BaseService.Update("UpdatePspTypeBy", obj); wait.Close(); MsgBox.Show("保存成功"); excelstate = false; } catch { wait.Close(); MsgBox.Show("保存失败"); } }
private void barEdititem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.FocusedNode == null) { return; } string uid = treeList1.FocusedNode["UID"].ToString(); PspType obj = Services.BaseService.GetOneByKey <PspType>(uid); PspType objCopy = new PspType(); DataConverter.CopyTo <PspType>(obj, objCopy); FrmPspTypeDialog dlg = new FrmPspTypeDialog(); dlg.Text = progName; dlg.Object = objCopy; if (dlg.ShowDialog() != DialogResult.OK) { return; } DataConverter.CopyTo <PspType>(objCopy, obj); treeList1.FocusedNode.SetValue("Title", obj.Title); }
private void barAdd1item_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.FocusedNode == null) { return; } string uid = treeList1.FocusedNode["UID"].ToString(); PspType obj = new PspType(); obj.UID = obj.UID + "|" + ProjectUID; obj.Contents = bts; obj.ParentID = uid; obj.CreateDate = DateTime.Now; obj.Col1 = progName; FrmPspTypeDialog dlg = new FrmPspTypeDialog(); dlg.Text = progName; dlg.Object = obj; dlg.IsCreate = true; if (dlg.ShowDialog() != DialogResult.OK) { return; } dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow())); }
private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { if (excelstate) { IsSave(); } if (treeList1.FocusedNode == null) { return; } excelstate = false; string uid = treeList1.FocusedNode["UID"].ToString(); uid1 = uid; PspType obj = Services.BaseService.GetOneByKey <PspType>(uid); WaitDialogForm wait = null; try { wait = new WaitDialogForm("", "正在加载数据, 请稍候..."); System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Contents); //by1 = obj.Contents; fpSpread1.Open(ms); wait.Close(); fpSpread1.ActiveSheet.Columns[0, fpSpread1.ActiveSheet.Columns.Count - 1].AllowAutoFilter = true; //查询 fpSpread1.Sheets[0].SetColumnAllowAutoSort(-1, true); //排序 } catch { wait.Close(); } }
private void IsSave() { if (!editrights) { return; } if (MsgBox.ShowYesNo("数据已经发生改变,是否保存?") != DialogResult.Yes) { return; } WaitDialogForm wait = null; PspType obj = Services.BaseService.GetOneByKey <PspType>(uid1); try { wait = new WaitDialogForm("", "正在保存数据, 请稍候..."); dsoExcelControl1.AxFramerControl.Save(filename, true, null, null); obj.Contents = dsoExcelControl1.FileData1(filename); Services.BaseService.Update("UpdatePspTypeBy", obj); wait.Close(); MsgBox.Show("保存成功"); excelstate = false; } catch { wait.Close(); MsgBox.Show("保存失败"); } }
private void barAdditem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { PspType obj = new PspType(); obj.Contents = bts; obj.ParentID = ""; obj.CreateDate = DateTime.Now; obj.Col1 = progName; FrmPspTypeDialog dlg = new FrmPspTypeDialog(); dlg.Text = progName; dlg.Object = obj; dlg.IsCreate = true; if (dlg.ShowDialog() != DialogResult.OK) { return; } string uid = treeList1.FocusedNode["UID"].ToString(); uid1 = uid; PspType obj1 = Services.BaseService.GetOneByKey <PspType>(uid); WaitDialogForm wait = null; try { wait = new WaitDialogForm("", "正在加载数据, 请稍候..."); System.IO.MemoryStream ms = new System.IO.MemoryStream(obj1.Contents); // by1 = obj.Contents; string str = ""; str = filename; string fname = filepath + Guid.NewGuid().ToString() + ".xls"; filename = fname; dsoExcelControl1.saveStreamFile(fname, ms.ToArray()); dsoExcelControl1.FileOpen(fname); // dsoExcelControl1.FileNew(); dsoExcelControl1.AxFramerControl.Titlebar = false; dsoExcelControl1.Onisdispalymenubar(false); dsoExcelControl1.Onisdispalytoolbar(false); if (File.Exists(str)) { File.Delete(str); } // fpSpread1.Open(ms); wait.Close(); //fpSpread1.ActiveSheet.Columns[0, fpSpread1.ActiveSheet.Columns.Count - 1].AllowAutoFilter = true;//查询 //fpSpread1.Sheets[0].SetColumnAllowAutoSort(-1, true);//排序 } catch { wait.Close(); } dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow())); }
private void barAdd1item_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.FocusedNode == null) { return; } string uid = treeList1.FocusedNode["UID"].ToString(); PspType obj = new PspType(); obj.UID = obj.UID + "|" + ProjectUID; obj.Contents = bts; obj.ParentID = uid; obj.CreateDate = DateTime.Now; obj.Col1 = ProjectUID; FrmPspTypeDialog dlg = new FrmPspTypeDialog(); dlg.Text = progName; dlg.Object = obj; dlg.IsCreate = true; if (dlg.ShowDialog() != DialogResult.OK) { return; } WaitDialogForm wait = null; try { wait = new WaitDialogForm("", "正在加载数据, 请稍候..."); //System.IO.MemoryStream ms = new System.IO.MemoryStream(obj1.Contents); //// by1 = obj.Contents; string str = ""; str = filename; string fname = filepath + Guid.NewGuid().ToString() + ".xls"; filename = fname; dsoExcelControl1.AxFramerControl.Save(fname, false, null, null); //dsoExcelControl1.FileOpen(fname); //dsoExcelControl1.AxFramerControl.Titlebar = false; //dsoExcelControl1.Onisdispalymenubar(false); //dsoExcelControl1.Onisdispalytoolbar(false); wait.Close(); } catch { wait.Close(); } dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow())); }
private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { if (excelstate) { IsSave(); } if (treeList1.FocusedNode == null) { return; } excelstate = false; string uid = treeList1.FocusedNode["UID"].ToString(); uid1 = uid; PspType obj = Services.BaseService.GetOneByKey <PspType>(uid); WaitDialogForm wait = null; try { wait = new WaitDialogForm("", "正在加载数据, 请稍候..."); System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Contents); //by1 = obj.Contents; string str = ""; str = filename; string fname = filepath + Guid.NewGuid().ToString() + ".xls"; filename = fname; dsoExcelControl1.saveStreamFile(fname, ms.ToArray()); dsoExcelControl1.FileOpen(fname); dsoExcelControl1.AxFramerControl.Titlebar = false; dsoExcelControl1.Onisdispalymenubar(false); dsoExcelControl1.Onisdispalytoolbar(false); if (File.Exists(str)) { File.Delete(str); } // fpSpread1.Open(ms); wait.Close(); //fpSpread1.ActiveSheet.Columns[0, fpSpread1.ActiveSheet.Columns.Count - 1].AllowAutoFilter = true;//查询 //fpSpread1.Sheets[0].SetColumnAllowAutoSort(-1, true);//排序 } catch { wait.Close(); } }
private void InitData() { //if (!isSelect) //{ // switch (smmprog.ProgId) // { // case "64c9efcb-e6cc-402f-b2fc-f5f6f7d296f7": // progName = "负荷特性分析"; // type = "fhtxfx"; // break; // case "a50e1781-e470-4721-a6ee-c4b1294d6bd4": // progName = "电网基础数据"; // type = "dwjcsj"; // break; // case "3630adcc-9d4b-4059-b44e-4f88ccf76b43": // progName = "电网规划基础表"; // type = "dwghjc"; // break; // } //} PspType pt = new PspType(); pt.Col1 = ProjectUID; ilist = Services.BaseService.GetList("SelectPspTypeList", pt); //ilist = Services.BaseService.GetList<PspType>(); dataTable = DataConverter.ToDataTable(ilist, typeof(PspType)); treeList1.DataSource = dataTable; Econ ed = new Econ(); ed.UID = "Excel"; try { bts = Services.BaseService.GetOneByKey <Econ>(ed).ExcelData; } catch { } }
private void barSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.FocusedNode == null) { return; } string uid = treeList1.FocusedNode["UID"].ToString(); PspType obj = Services.BaseService.GetOneByKey <PspType>(uid); try { textBox1.Focus(); dsoExcelControl1.AxFramerControl.Save(filename, true, null, null); obj.Contents = dsoExcelControl1.FileData1(filename); Services.BaseService.Update("UpdatePspTypeBy", obj); excelstate = false; MsgBox.Show("保存成功"); } catch (Exception ex) { MsgBox.Show(ex.Message); } }
private void barSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.FocusedNode == null) { return; } string uid = treeList1.FocusedNode["UID"].ToString(); PspType obj = Services.BaseService.GetOneByKey <PspType>(uid); System.IO.MemoryStream ms = new System.IO.MemoryStream(); try { textBox1.Focus(); fpSpread1.Update(); fpSpread1.Save(ms, false); obj.Contents = ms.GetBuffer(); Services.BaseService.Update("UpdatePspTypeBy", obj); excelstate = false; MsgBox.Show("保存成功"); } catch (Exception ex) { MsgBox.Show(ex.Message); } }
private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { if (excelstate) { IsSave(); } if (treeList1.FocusedNode == null) { return; } //barCheckItem1.Checked = false; //barCheckItem1.Caption = "显示标题栏"; //barCheckItem2.Checked = false; //barCheckItem2.Caption = "显示菜单栏"; //barCheckItem3.Checked = false; //barCheckItem3.Caption = "显示工具栏"; //barCheckItem4.Checked = false; //barCheckItem4.Caption = "显示公式栏"; excelstate = false; string uid = treeList1.FocusedNode["UID"].ToString(); uid1 = uid; PspType obj = Services.BaseService.GetOneByKey <PspType>(uid); this.ctrlRtfAttachFiles1.Category = uid; this.ctrlRtfAttachFiles1.RefreshData(); // WaitDialogForm wait = null; try { //wait = new WaitDialogForm("", "正在加载数据, 请稍候..."); System.IO.MemoryStream ms = new System.IO.MemoryStream(obj.Contents); //by1 = obj.Contents; string str = ""; str = filename; string fname = filepath + Guid.NewGuid().ToString() + ".xls"; //string fname = filepath + "aaabbb.xls"; filename = fname; dsoExcelControl1.saveStreamFile(fname, ms.ToArray()); dsoExcelControl1.FileOpen(fname); //dsoExcelControl1.AxFramerControl.Titlebar = false; //dsoExcelControl1.Onisdispalymenubar(true); //dsoExcelControl1.Onisdispalytoolbar(true); //dsoExcelControl1.OnisdislayFormulaBar(true); try { //dsoExcelControl2.FileNew(); } catch { } if (i == 0) { //Microsoft.Office.Interop.Excel.Workbook book = exc.Application.Workbooks.Add(fname); //引用Excel工作簿 //exc.Visible = false; //使Excel不可视 //i++; } //doc.Application.DisplayFormulaBar = false; if (File.Exists(str)) { File.Delete(str); } //wait.Close(); } catch (Exception ex) { System.Console.WriteLine(ex.Message);//wait.Close(); } }