第八篇
SQL操作數據庫的
? #region save dbsql ....
?
public void SaveSheet()
?
private void SaveSheetList()
?
private void SaveSheetListDetails()
?
private void SaveGridListDetails()
?#endregion
?
窗體關閉
?
??????? protected override void OnFormClosing(FormClosingEventArgs e)
??????? {
??????????? if (hasDataChange)
??????????? {
??????????????? DialogResult result = MessageBox.Show("數據有修改你確定要關閉么", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
??????????????? if (result == DialogResult.No)
??????????????? {
??????????????????? e.Cancel = true;
??????????????????? return;
??????????????? }
??????????? }
??????????? base.OnFormClosing(e);
??????? }
?
樹刪除結點? 除自己外都刪了?
?
? private void DeleteNodes(TreeListNode aNode, TreeList aList)
??????? {
??????????? if (aNode == null)
??????????????? return;
??????????? if (!aNode.HasChildren)
??????????? {
??????????????? if (aNode.Level != 0)
??????????????? {
??????????????????? // don't remove self
??????????????????? aList.DeleteNode(aNode);
??????????????? }
??????????? }
??????????? else
??????????? {
??????????????? TreeListNodes Nodes = aNode.Nodes;
??????????????? for (int i = 0; i < Nodes.Count; )??? // remove anode has finish
??????????????? {
??????????????????? // goto loop
??????????????????? DeleteNodes(Nodes[i], aList);
??????????????? }
??????????? }
??????? }
?
?
網格行 自動添加行號
? private int GetMaxLineNo(DataView aView, int ColumnIndex, int maxValue)
??????? {
??????????? int result = 1;
??????????? if (aView == null || aView.Table.Rows.Count == 0)
??????????????? return result;
??????????? foreach (DataRow row in aView.Table.Rows)
??????????? {
??????????????? if (row.RowState != DataRowState.Deleted)
??????????????? {
??????????????????? result = (Convert.ToInt32(row[ColumnIndex]) > result && Convert.ToInt32(row[ColumnIndex]) < maxValue) ? Convert.ToInt32(row[ColumnIndex]) : result;
??????????????? }
??????????????? else
??????????????? {
??????????????????? result = (Convert.ToInt32(row[ColumnIndex, DataRowVersion.Original]) > result && Convert.ToInt32(row[ColumnIndex, DataRowVersion.Original]) < maxValue) ? Convert.ToInt32(row[ColumnIndex, DataRowVersion.Original]) : result;
??????????????? }
??????????? }
??????????? return result + 1;
??????? }
?
?
轉載于:https://www.cnblogs.com/ruyi/archive/2011/07/29/2121338.html
總結
- 上一篇: 侃侃(二)
- 下一篇: equals 与==的不同