Form_GroupId.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. using SourceGrid;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace OTSPartA_STDEditor
  12. {
  13. public partial class Form_GroupId : Form
  14. {
  15. public Form_Main m_MainForm = null;
  16. //国际化
  17. Language lan;
  18. System.Collections.Hashtable table_GroupId;
  19. string MineralGroupDBAddress = Application.StartupPath + "\\Config\\SysData\\" + "OTSCleanlinesSTD.db";
  20. Dictionary<int,STDGroups> MineralGroupDictionary = new Dictionary<int, STDGroups>();
  21. //Dictionary<int, STDGroups> MineralGroupDictionaryInitial = new Dictionary<int, STDGroups>();
  22. /// <summary>
  23. ///数据库修改状态
  24. /// </summary>
  25. public enum DBInfoState
  26. {
  27. Add = 0,
  28. Modify = 1,
  29. Delete = 2
  30. }
  31. object Clone(Dictionary<int, STDGroups> Dictionary)
  32. {
  33. Dictionary<int, STDGroups> DictionaryInitial = new Dictionary<int, STDGroups>();
  34. foreach (var key in Dictionary.Keys)
  35. {
  36. STDGroups DGroups = new STDGroups();
  37. DGroups = DGroups.Clone(Dictionary[key]) as STDGroups;
  38. DictionaryInitial.Add(key,DGroups);
  39. }
  40. return DictionaryInitial;
  41. }
  42. bool LoadDataFromDb(string DBaddress)
  43. {
  44. try
  45. {
  46. System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBaddress + "'");
  47. m_dbConnection.Open();
  48. System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from STDGroups order by iorder", m_dbConnection);
  49. DataSet ds = new DataSet();
  50. m_dataAdapter.Fill(ds);
  51. DataTable dt = ds.Tables[0];
  52. if (dt != null)
  53. {
  54. STDGroups new_data = new STDGroups();
  55. new_data.name = "Default";
  56. new_data.color = "#C9C9C9";
  57. new_data.iorder = 999;
  58. MineralGroupDictionary.Add(0, new_data);
  59. if (dt.Rows.Count > 0)
  60. {
  61. foreach (DataRow item in dt.Rows)
  62. {
  63. if (item["name"].ToString() != "Default")
  64. {
  65. STDGroups new_STDdata = new STDGroups();
  66. new_STDdata.name = item["name"].ToString();
  67. new_STDdata.color = item["color"].ToString();
  68. new_STDdata.iorder = int.Parse(item["iorder"].ToString());
  69. MineralGroupDictionary.Add(int.Parse(item["id"].ToString()), new_STDdata);
  70. }
  71. }
  72. }
  73. }
  74. m_dbConnection.Close();
  75. return true;
  76. }
  77. catch(Exception ee)
  78. {
  79. MessageBox.Show(ee.ToString());
  80. return false;
  81. }
  82. }
  83. private void clickEvent_Click(object sender, EventArgs e)
  84. {
  85. SourceGrid.CellContext context = (SourceGrid.CellContext)sender;
  86. int i = context.Position.Row;
  87. int j = context.Position.Column;
  88. /// 保证鼠标点击的GRID行和列是有效的
  89. if (i >= 0 && j == 1)
  90. {
  91. ColorDialog cd = new ColorDialog();
  92. cd.FullOpen = true;//自定义颜色界面打开
  93. DialogResult result = cd.ShowDialog();
  94. if (result == DialogResult.OK)
  95. {
  96. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  97. view.BackColor = cd.Color;
  98. Grid_FroupId[i, 1].View = view;
  99. MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].color = Attributes.colorRGBtoHx16(Grid_FroupId[i, 1].View.BackColor.R, Grid_FroupId[i, 1].View.BackColor.G, Grid_FroupId[i, 1].View.BackColor.B);
  100. }
  101. }
  102. Grid_FroupId.Refresh();
  103. }
  104. void clickEvent_ValueChanged(object sender, EventArgs e)
  105. {
  106. SourceGrid.CellContext context = (SourceGrid.CellContext)sender;
  107. int i = context.Position.Row;
  108. int j = context.Position.Column;
  109. if (i >= 0 && j == 0)
  110. {
  111. MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].name = Grid_FroupId[i, 0].Value.ToString();
  112. MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].InfoState = (int)DBInfoState.Modify;
  113. }
  114. }
  115. //查询数据是否存在
  116. protected bool WhetherExistsInDBById(System.Data.SQLite.SQLiteConnection m_dbConnection, int id)
  117. {
  118. bool selResult = false;
  119. System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from STDGroups where id=" + id.ToString() + "", m_dbConnection);
  120. DataSet ds = new DataSet();
  121. m_dataAdapter.Fill(ds);
  122. DataTable dt = ds.Tables[0];
  123. if (dt != null)
  124. {
  125. if (dt.Rows.Count > 0)
  126. {
  127. selResult = true;
  128. }
  129. }
  130. return selResult;
  131. }
  132. bool AddIntoDB(System.Data.SQLite.SQLiteConnection m_dbConnection,int id,string name,string color,int iorder)
  133. {
  134. System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
  135. try
  136. {
  137. string insertstr = "Insert into STDGroups(id,name,color,iorder)";
  138. string aa = "values(" + id + ",'" + name + "','" + color + "'," + iorder+ ")";
  139. cmm.CommandText = insertstr + aa;
  140. cmm.ExecuteNonQuery();
  141. return true;
  142. }
  143. catch /*(Exception ex)*/
  144. {
  145. return false;
  146. }
  147. }
  148. bool UpdataInDB(System.Data.SQLite.SQLiteConnection m_dbConnection, int id, string name, string color, int iorder)
  149. {
  150. System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
  151. try
  152. {
  153. string insertstr = "update STDGroups set name='" + name + "',color='"+ color + "',iorder=" + iorder+ " where id=" + id + ";";
  154. cmm.CommandText = insertstr;
  155. cmm.ExecuteNonQuery();
  156. return true;
  157. }
  158. catch /*(Exception ex)*/
  159. {
  160. return false;
  161. }
  162. }
  163. bool DeleteInDB(System.Data.SQLite.SQLiteConnection m_dbConnection, int id, string name, string color, int iorder)
  164. {
  165. System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
  166. try
  167. {
  168. string insertstr = "delete from STDGroups where id=" + id + ";";
  169. cmm.CommandText = insertstr;
  170. cmm.ExecuteNonQuery();
  171. return true;
  172. }
  173. catch /*(Exception ex)*/
  174. {
  175. return false;
  176. }
  177. }
  178. void SaveDataIntoDB(string DBAddress)
  179. {
  180. for (int i = 2; i < Grid_FroupId.RowsCount; i++)
  181. {
  182. MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].iorder = i-1;
  183. }
  184. System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
  185. m_dbConnection.Open();
  186. foreach (KeyValuePair<int, STDGroups> kv in MineralGroupDictionary)
  187. {
  188. int infoState = kv.Value.InfoState;
  189. if (infoState == (int)DBInfoState.Modify)
  190. {
  191. bool result = WhetherExistsInDBById(m_dbConnection, kv.Key);
  192. if (!result)
  193. {
  194. if (!AddIntoDB(m_dbConnection, kv.Key, kv.Value.name, kv.Value.color, kv.Value.iorder))
  195. {
  196. MessageBox.Show("Failed to add into database!", "Tip");
  197. }
  198. }
  199. else
  200. {
  201. if (!UpdataInDB(m_dbConnection, kv.Key, kv.Value.name, kv.Value.color, kv.Value.iorder))
  202. {
  203. MessageBox.Show("Failed to update to database!", "Tip");
  204. }
  205. }
  206. }
  207. else if (infoState == (int)DBInfoState.Delete)
  208. {
  209. if (!DeleteInDB(m_dbConnection, kv.Key, kv.Value.name, kv.Value.color, kv.Value.iorder))
  210. {
  211. MessageBox.Show("Failed to delete data in database!", "Tip");
  212. }
  213. }
  214. }
  215. m_dbConnection.Close();
  216. }
  217. public Form_GroupId(string DBAddress, Form_Main mainForm)
  218. {
  219. InitializeComponent();
  220. MineralGroupDBAddress = DBAddress;
  221. m_MainForm = mainForm;
  222. }
  223. private void Form_GroupId_Load(object sender, EventArgs e)
  224. {
  225. lan = new Language(this);
  226. table_GroupId = lan.GetNameTable("Form_GroupId");
  227. button_up.Enabled = false;
  228. button_down.Enabled = false;
  229. bool result = LoadDataFromDb(MineralGroupDBAddress);
  230. if(result)
  231. {
  232. Grid_FroupId.Redim(MineralGroupDictionary.Count + 1, 2);
  233. Grid_FroupId.Rows.SetHeight(0, 25);
  234. Grid_FroupId.AutoStretchColumnsToFitWidth = true;
  235. Grid_FroupId.Selection.EnableMultiSelection = false;
  236. Grid_FroupId.FixedRows = 1;
  237. Grid_FroupId.Columns[0].Width = 190;
  238. Grid_FroupId.Columns[1].Width = 135;
  239. if (table_GroupId["language"].ToString() == "ZH")
  240. {
  241. Grid_FroupId[0, 0] = new SourceGrid.Cells.Cell("组名称", typeof(string));
  242. Grid_FroupId[0, 1] = new SourceGrid.Cells.Cell("组颜色", typeof(string));
  243. }
  244. else
  245. {
  246. Grid_FroupId[0, 0] = new SourceGrid.Cells.Cell("Group Name", typeof(string));
  247. Grid_FroupId[0, 1] = new SourceGrid.Cells.Cell("Group Color", typeof(string));
  248. }
  249. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  250. view.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
  251. view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
  252. view.BackColor = Color.LightGray;
  253. Grid_FroupId[0, 0].View = view;
  254. Grid_FroupId[0, 1].View = view;
  255. Grid_FroupId[0, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  256. Grid_FroupId[0, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  257. Grid_FroupId[1, 0] = new SourceGrid.Cells.Cell("Default", typeof(string));
  258. Grid_FroupId[1, 1] = new SourceGrid.Cells.Cell("", typeof(string));
  259. Grid_FroupId.Rows[1].Height = 25;
  260. Grid_FroupId[1, 0].Tag = 0;
  261. SourceGrid.Cells.Views.Cell vw = new SourceGrid.Cells.Views.Cell();
  262. vw.BackColor = Attributes.colorHx16toRGB("#C9C9C9");
  263. Grid_FroupId[1, 1].View = vw;
  264. Grid_FroupId[1, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  265. Grid_FroupId[1, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  266. int i = 2;
  267. foreach (KeyValuePair<int, STDGroups> kv in MineralGroupDictionary)
  268. {
  269. if (kv.Key != 0)
  270. {
  271. Grid_FroupId[i, 0] = new SourceGrid.Cells.Cell(kv.Value.name, typeof(string));
  272. Grid_FroupId[i, 1] = new SourceGrid.Cells.Cell("", typeof(string));
  273. Grid_FroupId.Rows[i].Height = 25;
  274. Grid_FroupId[i, 0].Tag = kv.Key;
  275. SourceGrid.Cells.Views.Cell vew = new SourceGrid.Cells.Views.Cell();
  276. vew.BackColor = Attributes.colorHx16toRGB(kv.Value.color);
  277. Grid_FroupId[i, 1].View = vew;
  278. SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
  279. clickEvent.ValueChanged += new EventHandler(clickEvent_ValueChanged);
  280. Grid_FroupId[i, 0].AddController(clickEvent);
  281. SourceGrid.Cells.Controllers.CustomEvents clickEvent2 = new SourceGrid.Cells.Controllers.CustomEvents();
  282. clickEvent2.Click += new EventHandler(clickEvent_Click);
  283. Grid_FroupId[i, 1].AddController(clickEvent2);
  284. i++;
  285. }
  286. }
  287. }
  288. else
  289. {
  290. MessageBox.Show("Failed to read database", "Tip");
  291. }
  292. }
  293. public int AddMineralGroupDictionaryItem()
  294. {
  295. STDGroups new_MineralGroup = new STDGroups();//定义一个TreeNode节点对象
  296. new_MineralGroup.name = "New Group";
  297. new_MineralGroup.color = Attributes.colorRGBtoHx16(Color.Gray.R, Color.Gray.G, Color.Gray.B);
  298. new_MineralGroup.InfoState = (int)DBInfoState.Modify;
  299. int Id = 100;
  300. foreach (KeyValuePair<int, STDGroups> kv in MineralGroupDictionary)
  301. {
  302. if (Id < kv.Key)
  303. {
  304. Id = kv.Key;
  305. }
  306. }
  307. MineralGroupDictionary.Add(Id + 1, new_MineralGroup);
  308. return Id + 1;
  309. }
  310. public void AddNewRow(int Id, string GroupName, Color color)
  311. {
  312. Grid_FroupId.Rows.Insert(Grid_FroupId.Rows.Count);
  313. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 0] = new SourceGrid.Cells.Cell(GroupName, typeof(string));
  314. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 1] = new SourceGrid.Cells.Cell("", typeof(string));
  315. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 0].Tag = Id;
  316. Grid_FroupId.Rows[Grid_FroupId.Rows.Count - 1].Height = 25;
  317. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  318. view.BackColor = color;
  319. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 1].View = view;
  320. SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
  321. clickEvent.ValueChanged += new EventHandler(clickEvent_ValueChanged);
  322. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 0].AddController(clickEvent);
  323. SourceGrid.Cells.Controllers.CustomEvents clickEvent2 = new SourceGrid.Cells.Controllers.CustomEvents();
  324. clickEvent2.Click += new EventHandler(clickEvent_Click);
  325. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 1].AddController(clickEvent2);
  326. Grid_FroupId.Refresh();
  327. Position pos = new Position(Grid_FroupId.Rows.Count - 1, 0);
  328. Grid_FroupId.Selection.Focus(pos, true);
  329. }
  330. public void RemoveMineralGroupDictionaryItem(int Id)
  331. {
  332. //MineralGroupDictionary.Remove(Id);
  333. MineralGroupDictionary[Id].InfoState = (int)DBInfoState.Delete;
  334. }
  335. private void button_Cancel_Click(object sender, EventArgs e)
  336. {
  337. this.DialogResult = DialogResult.Cancel;
  338. this.Close();
  339. }
  340. private void button_OK_Click(object sender, EventArgs e)
  341. {
  342. for (int i = 1; i < Grid_FroupId.RowsCount; i++)
  343. {
  344. for (int j = i+1; j < Grid_FroupId.RowsCount; j++)
  345. {
  346. if(Grid_FroupId[i,0].ToString()== Grid_FroupId[j,0].ToString())
  347. {
  348. Position pos = new Position(i, 0);
  349. Grid_FroupId.Selection.Focus(pos, true);
  350. string DuplicateNames = Grid_FroupId[i, 0].ToString();
  351. MessageBox.Show("The names of groups are reusable which named " + DuplicateNames + ",please modify!", "Tip");
  352. return;
  353. }
  354. }
  355. }
  356. SaveDataIntoDB(MineralGroupDBAddress);
  357. this.DialogResult = DialogResult.Yes;
  358. this.Close();
  359. }
  360. private void 添加组ToolStripMenuItem_Click(object sender, EventArgs e)
  361. {
  362. int Id = AddMineralGroupDictionaryItem();
  363. AddNewRow(Id, "New Group", Color.Gray);
  364. }
  365. private void 删除组ToolStripMenuItem_Click(object sender, EventArgs e)
  366. {
  367. int x = Grid_FroupId.Selection.ActivePosition.Row;
  368. int y = Grid_FroupId.Selection.ActivePosition.Column;
  369. if (x > 0 && (y == 0|| y == 1))
  370. {
  371. bool bexist = false;
  372. foreach (KeyValuePair<int, STDdata> kv in m_MainForm.STDDictionary)
  373. {
  374. if(kv.Value.GroupId.ToString()== Grid_FroupId[x, 0].Tag.ToString())
  375. {
  376. bexist = true;
  377. break;
  378. }
  379. }
  380. if(bexist)
  381. {
  382. MessageBox.Show("There is a grouping in the user standard library that you want to delete!");
  383. return;
  384. }
  385. RemoveMineralGroupDictionaryItem((int)Grid_FroupId[x, 0].Tag);
  386. Grid_FroupId.Rows.Remove(x);
  387. Grid_FroupId.Refresh();
  388. if (Grid_FroupId.RowsCount > 1)
  389. {
  390. Position pos = new Position(1, 0);
  391. Grid_FroupId.Selection.Focus(pos, true);
  392. Grid_FroupId[1, 0].Grid.Select();
  393. }
  394. }
  395. else
  396. {
  397. MessageBox.Show("No gruop is selected!", "Tip");
  398. }
  399. }
  400. private void button_up_Click(object sender, EventArgs e)
  401. {
  402. Grid_FroupId.Focus(true);
  403. int selrow = Grid_FroupId.Selection.ActivePosition.Row;
  404. int id = (int)Grid_FroupId[selrow, 0].Tag;
  405. int id2 = (int)Grid_FroupId[selrow - 1, 0].Tag;
  406. string GroupName = Grid_FroupId[selrow, 0].Value.ToString();
  407. Color color = Grid_FroupId[selrow, 1].View.BackColor;
  408. Grid_FroupId[selrow, 0].Value = Grid_FroupId[selrow - 1, 0].Value;
  409. Grid_FroupId[selrow, 0].Tag = id2;
  410. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  411. view.BackColor = Grid_FroupId[selrow - 1, 1].View.BackColor;
  412. Grid_FroupId[selrow, 1].View = view;
  413. Grid_FroupId[selrow - 1, 0].Value = GroupName;
  414. Grid_FroupId[selrow - 1, 0].Tag = id;
  415. SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
  416. view2.BackColor = color;
  417. Grid_FroupId[selrow - 1, 1].View = view2;
  418. MineralGroupDictionary[id].name = Grid_FroupId[selrow - 1, 0].Value.ToString();
  419. MineralGroupDictionary[id2].name = Grid_FroupId[selrow, 0].Value.ToString();
  420. Grid_FroupId.Refresh();
  421. Position pos = new Position(selrow - 1, 0);
  422. Grid_FroupId[selrow - 1, 0].Grid.Select();
  423. Grid_FroupId.Selection.Focus(pos, true);
  424. button_down.Enabled = true;
  425. if (selrow - 1 == 1)
  426. {
  427. button_up.Enabled = false;
  428. }
  429. }
  430. private void button_down_Click(object sender, EventArgs e)
  431. {
  432. Grid_FroupId.Focus(true);
  433. int selrow = Grid_FroupId.Selection.ActivePosition.Row;
  434. int id = (int)Grid_FroupId[selrow, 0].Tag;
  435. int id2 = (int)Grid_FroupId[selrow + 1, 0].Tag;
  436. string GroupName = Grid_FroupId[selrow, 0].Value.ToString();
  437. Color color = Grid_FroupId[selrow, 1].View.BackColor;
  438. Grid_FroupId[selrow, 0].Value = Grid_FroupId[selrow + 1, 0].Value;
  439. Grid_FroupId[selrow, 0].Tag = (int)Grid_FroupId[selrow + 1, 0].Tag;
  440. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  441. view.BackColor = Grid_FroupId[selrow+1, 1].View.BackColor;
  442. Grid_FroupId[selrow, 1].View = view;
  443. Grid_FroupId[selrow + 1, 0].Value = GroupName;
  444. Grid_FroupId[selrow + 1, 0].Tag = id;
  445. SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
  446. view2.BackColor = color;
  447. Grid_FroupId[selrow + 1, 1].View = view2;
  448. MineralGroupDictionary[id].name = Grid_FroupId[selrow + 1, 0].Value.ToString();
  449. MineralGroupDictionary[id2].name = Grid_FroupId[selrow, 0].Value.ToString();
  450. Grid_FroupId.Refresh();
  451. Position pos = new Position(selrow + 1, 0);
  452. Grid_FroupId[selrow + 1, 0].Grid.Select();
  453. Grid_FroupId.Selection.Focus(pos, true);
  454. button_up.Enabled = true;
  455. if (selrow + 1 == Grid_FroupId.RowsCount - 1)
  456. {
  457. button_down.Enabled = false;
  458. }
  459. }
  460. private void Grid_FroupId_Click(object sender, EventArgs e)
  461. {
  462. SourceGrid.Grid ls_gd = (SourceGrid.Grid)sender;
  463. ls_gd.Focus();
  464. int i = ls_gd.Selection.ActivePosition.Row;
  465. int j = ls_gd.Selection.ActivePosition.Column;
  466. /// 保证鼠标点击的GRID行和列是有效的
  467. if (i >= 0 && j >= 0)
  468. {
  469. if (i == ls_gd.RowsCount - 1)
  470. {
  471. button_down.Enabled = false;
  472. }
  473. else
  474. {
  475. button_down.Enabled = true;
  476. }
  477. if (i == 1)
  478. {
  479. button_up.Enabled = false;
  480. //MessageBox.Show("Group by default, not editable!");
  481. //return;
  482. }
  483. else
  484. {
  485. button_up.Enabled = true;
  486. }
  487. }
  488. }
  489. }
  490. }