private void InsertLineData1() { if (ctrlPowerEachTotalList1.FocusedObject == null) { MsgBox.Show("没有项目存在,无法导入!"); return; } string UID = ""; try { TreeListNode tln = this.ctrlPowerEachTotal1.ZHJ.FocusedNode; UID = tln["UID"].ToString(); } catch { } string a = ""; try { DataTable dts = new DataTable(); OpenFileDialog op = new OpenFileDialog(); op.Filter = "Excel文件(*.xls)|*.xls"; if (op.ShowDialog() == DialogResult.OK) { dts = GetExcel(op.FileName); for (int i = 0; i < dts.Rows.Count; i++) { if (dts.Rows[i][0].ToString() != "") { PowerEachTotal li = new PowerEachTotal(); //PowerEachTotalList li1 = (PowerEachTotalList)Itop.Client.Common.Services.BaseService.GetObject("SelectPowerEachTotalListList", ""); object obj = Services.BaseService.GetObject("SelectPowerEachTotalList1", ""); li.PowerLineUID = ctrlPowerEachTotal1.LineUID; li.Remark = ctrlPowerEachTotal1.LineName; li.StuffName = dts.Rows[i][0].ToString(); li.Lengths = dts.Rows[i][1].ToString(); li.LCount = dts.Rows[i][2].ToString(); li.Total = dts.Rows[i][3].ToString(); li.Volume = dts.Rows[i][4].ToString(); li.Type = dts.Rows[i][5].ToString(); li.IsSum = Convert.ToDouble(dts.Rows[i][6].ToString()); li.ItSum = Convert.ToDouble(dts.Rows[i][7].ToString()); li.ParentID = UID; Services.BaseService.Create <PowerEachTotal>(li); } } this.ctrlPowerEachTotal1.RefreshData(); } } catch { MsgBox.Show("导入格式不正确!"); } }
/// <summary> /// 修改焦点对象 /// </summary> public void UpdateObject() { if (treeList1.FocusedNode == null) { return; } string uid = treeList1.FocusedNode["UID"].ToString(); PowerEachTotal obj = Services.BaseService.GetOneByKey <PowerEachTotal>(uid); //PowerEachTotal objCopy = new PowerEachTotal(); //DataConverter.CopyTo<PowerEachTotal>(obj, objCopy); FormTypeTitle frm = new FormTypeTitle(); frm.Text = "修改项目"; frm.TypeTitle = obj.StuffName; if (frm.ShowDialog() == DialogResult.OK) { obj.StuffName = frm.TypeTitle; try { Services.BaseService.Update <PowerEachTotal>(obj); treeList1.FocusedNode.SetValue("StuffName", obj.StuffName); //dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow())); //psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPowerTypes", psp_Type); //dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow())); } catch (Exception ex) { MsgBox.Show("增加项目出错:" + ex.Message); } } //////Services.BaseService.Update<PowerEachTotal>(obj); //////FrmPowerEachTotalDialog dlg = new FrmPowerEachTotalDialog(); //////dlg.Object = objCopy; //////if (dlg.ShowDialog() != DialogResult.OK) //////{ ////// return; //////} //DataConverter.CopyTo<PowerEachTotal>(objCopy, obj); //treeList1.FocusedNode.SetValue("StuffName", obj.StuffName); //treeList1.FocusedNode.SetValue("LCount", obj.LCount); //treeList1.FocusedNode.SetValue("Lengths", obj.Lengths); //treeList1.FocusedNode.SetValue("Volume", obj.Volume); //treeList1.FocusedNode.SetValue("Type", obj.Type); //treeList1.FocusedNode.SetValue("Total", obj.Total); //treeList1.FocusedNode.SetValue("Remark", obj.Remark); //treeList1.FocusedNode.SetValue("IsSum", obj.IsSum); //treeList1.FocusedNode.SetValue("ItSum", obj.ItSum); }
/// <summary> /// 删除焦点对象 /// </summary> public void DeleteObject() { //获取焦点对象 PowerEachTotalList obj = FocusedObject; if (obj == null) { return; } PowerEachTotal pt = new PowerEachTotal(); pt.PowerLineUID = obj.UID; IList <PowerEachTotal> li = Services.BaseService.GetList <PowerEachTotal>("SelectPowerEachTotalList", pt); if (li.Count > 0) { MsgBox.Show("该分类下面有汇总表记录,无法删除"); return; } //请求确认 if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes) { return; } //执行删除操作 try { Services.BaseService.Delete <PowerEachTotalList>(obj); } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return; } this.gridView.BeginUpdate(); //记住当前焦点行索引 int iOldHandle = this.gridView.FocusedRowHandle; //从链表中删除 ObjectList.Remove(obj); //刷新表格 gridControl.RefreshDataSource(); //设置新的焦点行索引 GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle); this.gridView.EndUpdate(); }
private void SaveValue(string uid, string lengths, string lcount, string total, string volume, string type, string issum, string itsum) { PowerEachTotal pet = Services.BaseService.GetOneByKey <PowerEachTotal>(uid); pet.Lengths = lengths; pet.LCount = lcount; pet.Total = total; pet.Volume = volume; pet.Type = type; if (issum != string.Empty) { pet.IsSum = double.Parse(issum); } if (itsum != string.Empty) { pet.ItSum = double.Parse(itsum); } Services.BaseService.Update <PowerEachTotal>(pet); }
public void InsertData() { int count = 0; string parentid = ""; if (treeList1.FocusedNode == null) { return; } if (treeList1.FocusedNode != null) { parentid = treeList1.FocusedNode["ParentID"].ToString(); count = int.Parse(treeList1.FocusedNode["SortID"].ToString()); } //object objs = Services.BaseService.GetObject("SelectPowerProjectBySortID", parentid); //if (objs != null) // count = (int)objs; PowerEachTotal obj = new PowerEachTotal(); obj.SortID = count; obj.ParentID = parentid; obj.PowerLineUID = lineuid; using (FrmPowerEachTotalDialog dlg = new FrmPowerEachTotalDialog()) { dlg.IsCreate = true; //设置新建标志 dlg.Object = obj; dlg.IsInsert = true; if (dlg.ShowDialog() != DialogResult.OK) { return; } } dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow())); this.treeList1.DataSource = dataTable; }
/// <summary> /// 刷新表格中的数据 /// </summary> /// <returns>ture:成功 false:失败</returns> public bool RefreshData() { try { PowerEachTotal pet = new PowerEachTotal(); pet.PowerLineUID = lineuid; list.Clear(); dataTable = new DataTable(); list = Services.BaseService.GetList <PowerEachTotal>("SelectPowerEachTotalList", pet); dataTable = DataConverter.ToDataTable((IList)list, typeof(PowerEachTotal)); this.treeList1.DataSource = dataTable; this.treeList1.ExpandAll(); treeList1.MoveFirst(); } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return(false); } return(true); }
/// <summary> /// 添加对象 /// </summary> public void AddObject1() { int count = 0; string parentid = ""; if (treeList1.FocusedNode == null) { return; } if (treeList1.FocusedNode != null) { parentid = treeList1.FocusedNode["UID"].ToString(); } object objs = Services.BaseService.GetObject("SelectPowerEachTotalBySortID", parentid); if (objs != null) { count = (int)objs; } FormTypeTitle frm = new FormTypeTitle(); frm.Text = "增加项目"; if (frm.ShowDialog() == DialogResult.OK) { PowerEachTotal obj = new PowerEachTotal(); obj.SortID = count + 1; obj.ParentID = parentid; obj.PowerLineUID = lineuid; obj.StuffName = frm.TypeTitle; try { Services.BaseService.Create <PowerEachTotal>(obj); dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow())); //psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPowerTypes", psp_Type); //dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow())); } catch (Exception ex) { MsgBox.Show("增加项目出错:" + ex.Message); } } //////PowerEachTotal obj = new PowerEachTotal(); //////obj.SortID = count + 1; //////obj.ParentID = parentid; //////obj.PowerLineUID = lineuid; //////using (FrmPowerEachTotalDialog dlg = new FrmPowerEachTotalDialog()) //////{ ////// dlg.IsCreate = true; //设置新建标志 ////// dlg.Object = obj; ////// if (dlg.ShowDialog() != DialogResult.OK) ////// { ////// return; ////// } //////} //////dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow())); }