/// <summary> /// ɾ��������� /// </summary> public void DeleteObject() { //��ȡ������� PowerStuffList obj = FocusedObject; if (obj == null) { return; } PowerStuff pp = new PowerStuff(); pp.PowerLineUID = obj.UID; IList<PowerStuff> li = Services.BaseService.GetList<PowerStuff>("SelectPowerStuffList", pp); if (li.Count > 0) { MsgBox.Show("�÷��������������豸���¼����ɾ��"); return; } //����ȷ�� if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes) { return; } //ִ��ɾ������ try { Services.BaseService.Delete<PowerStuffList>(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(); }
/// <summary> /// ��Ӷ��� /// </summary> public void AddObject() { int count = 0; string parentid = ""; if (treeList1.FocusedNode != null) { parentid = treeList1.FocusedNode["ParentID"].ToString(); } object objs = Services.BaseService.GetObject("SelectPowerStuffBySortID", parentid); if (objs != null) count = (int)objs; PowerStuff obj = new PowerStuff(); obj.SortID= count + 1; obj.ParentID = parentid; obj.PowerLineUID = lineuid; using (FrmPowerStuffDialog dlg = new FrmPowerStuffDialog()) { dlg.IsCreate = true; //�����½���־ dlg.Object = obj; if (dlg.ShowDialog() != DialogResult.OK) { return; } } dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow())); }
/// <summary> /// �Ľ������ /// </summary> public void UpdateObject() { if (treeList1.FocusedNode == null) return; string uid = treeList1.FocusedNode["UID"].ToString(); PowerStuff obj = Services.BaseService.GetOneByKey<PowerStuff>(uid); PowerStuff objCopy = new PowerStuff(); DataConverter.CopyTo<PowerStuff>(obj, objCopy); FrmPowerStuffDialog dlg = new FrmPowerStuffDialog(); dlg.Object = objCopy; if (dlg.ShowDialog() != DialogResult.OK) { return; } DataConverter.CopyTo<PowerStuff>(objCopy, obj); treeList1.FocusedNode.SetValue("StuffName", obj.StuffName); 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); }
private void ����ToolStripMenuItem_Click(object sender, EventArgs e) { 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; PowerStuff obj = new PowerStuff(); obj.SortID = count; obj.ParentID = parentid; obj.PowerLineUID = lineuid; using (FrmPowerStuffDialog dlg = new FrmPowerStuffDialog()) { dlg.IsCreate = true; //�����½���־ dlg.Object = obj; dlg.IsInsert = true; if (dlg.ShowDialog() != DialogResult.OK) { return; } } dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow())); }
/// <summary> /// ˢ�±���е����� /// </summary> /// <returns>ture:�ɹ� false:ʧ��</returns> public bool RefreshData() { try { try { ilist.Clear(); PowerStuff ps = new PowerStuff(); ps.PowerLineUID = lineuid; ilist = Services.BaseService.GetList<PowerStuff>("SelectPowerStuffList", ps); } catch (Exception ex) { MsgBox.Show(ex.Message); } dataTable = new DataTable(); dataTable = DataConverter.ToDataTable((IList)ilist, typeof(PowerStuff)); treeList1.DataSource = dataTable; this.treeList1.ExpandAll(); treeList1.MoveFirst(); //this.treeList1.DataSource = dataTable; } catch (Exception exc) { Debug.Fail(exc.Message); HandleException.TryCatch(exc); return false; } return true; }