Form_GroupId.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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_ConstantsEditor2 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_ConstantsEditor2 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. bool result = LoadDataFromDb(MineralGroupDBAddress);
  228. if(result)
  229. {
  230. Grid_FroupId.Redim(MineralGroupDictionary.Count + 1, 2);
  231. Grid_FroupId.Rows.SetHeight(0, 25);
  232. Grid_FroupId.AutoStretchColumnsToFitWidth = true;
  233. Grid_FroupId.Selection.EnableMultiSelection = false;
  234. Grid_FroupId.FixedRows = 1;
  235. Grid_FroupId.Columns[0].Width = 190;
  236. Grid_FroupId.Columns[1].Width = 135;
  237. if (table_GroupId["language"].ToString() == "ZH")
  238. {
  239. Grid_FroupId[0, 0] = new SourceGrid.Cells.Cell("组名称", typeof(string));
  240. Grid_FroupId[0, 1] = new SourceGrid.Cells.Cell("组颜色", typeof(string));
  241. }
  242. else
  243. {
  244. Grid_FroupId[0, 0] = new SourceGrid.Cells.Cell("Group Name", typeof(string));
  245. Grid_FroupId[0, 1] = new SourceGrid.Cells.Cell("Group Color", typeof(string));
  246. }
  247. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  248. view.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
  249. view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
  250. view.BackColor = Color.LightGray;
  251. Grid_FroupId[0, 0].View = view;
  252. Grid_FroupId[0, 1].View = view;
  253. Grid_FroupId[0, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  254. Grid_FroupId[0, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  255. Grid_FroupId[1, 0] = new SourceGrid.Cells.Cell("Default", typeof(string));
  256. Grid_FroupId[1, 1] = new SourceGrid.Cells.Cell("", typeof(string));
  257. Grid_FroupId.Rows[1].Height = 25;
  258. Grid_FroupId[1, 0].Tag = 0;
  259. SourceGrid.Cells.Views.Cell vw = new SourceGrid.Cells.Views.Cell();
  260. vw.BackColor = Attributes.colorHx16toRGB("#C9C9C9");
  261. Grid_FroupId[1, 1].View = vw;
  262. Grid_FroupId[1, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  263. Grid_FroupId[1, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  264. int i = 2;
  265. foreach (KeyValuePair<int, STDGroups> kv in MineralGroupDictionary)
  266. {
  267. if (kv.Key != 0)
  268. {
  269. Grid_FroupId[i, 0] = new SourceGrid.Cells.Cell(kv.Value.name, typeof(string));
  270. Grid_FroupId[i, 1] = new SourceGrid.Cells.Cell("", typeof(string));
  271. Grid_FroupId.Rows[i].Height = 25;
  272. Grid_FroupId[i, 0].Tag = kv.Key;
  273. SourceGrid.Cells.Views.Cell vew = new SourceGrid.Cells.Views.Cell();
  274. vew.BackColor = Attributes.colorHx16toRGB(kv.Value.color);
  275. Grid_FroupId[i, 1].View = vew;
  276. SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
  277. clickEvent.ValueChanged += new EventHandler(clickEvent_ValueChanged);
  278. Grid_FroupId[i, 0].AddController(clickEvent);
  279. SourceGrid.Cells.Controllers.CustomEvents clickEvent2 = new SourceGrid.Cells.Controllers.CustomEvents();
  280. clickEvent2.Click += new EventHandler(clickEvent_Click);
  281. Grid_FroupId[i, 1].AddController(clickEvent2);
  282. i++;
  283. }
  284. }
  285. }
  286. else
  287. {
  288. MessageBox.Show("Failed to read database", "Tip");
  289. }
  290. }
  291. public int AddMineralGroupDictionaryItem()
  292. {
  293. STDGroups new_MineralGroup = new STDGroups();//定义一个TreeNode节点对象
  294. new_MineralGroup.name = "New Group";
  295. new_MineralGroup.color = Attributes.colorRGBtoHx16(Color.Gray.R, Color.Gray.G, Color.Gray.B);
  296. new_MineralGroup.InfoState = (int)DBInfoState.Modify;
  297. int Id = 100;
  298. foreach (KeyValuePair<int, STDGroups> kv in MineralGroupDictionary)
  299. {
  300. if (Id < kv.Key)
  301. {
  302. Id = kv.Key;
  303. }
  304. }
  305. MineralGroupDictionary.Add(Id + 1, new_MineralGroup);
  306. return Id + 1;
  307. }
  308. public void AddNewRow(int Id, string GroupName, Color color)
  309. {
  310. Grid_FroupId.Rows.Insert(Grid_FroupId.Rows.Count);
  311. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 0] = new SourceGrid.Cells.Cell(GroupName, typeof(string));
  312. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 1] = new SourceGrid.Cells.Cell("", typeof(string));
  313. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 0].Tag = Id;
  314. Grid_FroupId.Rows[Grid_FroupId.Rows.Count - 1].Height = 25;
  315. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  316. view.BackColor = color;
  317. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 1].View = view;
  318. SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
  319. clickEvent.ValueChanged += new EventHandler(clickEvent_ValueChanged);
  320. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 0].AddController(clickEvent);
  321. SourceGrid.Cells.Controllers.CustomEvents clickEvent2 = new SourceGrid.Cells.Controllers.CustomEvents();
  322. clickEvent2.Click += new EventHandler(clickEvent_Click);
  323. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 1].AddController(clickEvent2);
  324. Grid_FroupId.Refresh();
  325. Position pos = new Position(Grid_FroupId.Rows.Count - 1, 0);
  326. Grid_FroupId.Selection.Focus(pos, true);
  327. }
  328. public void RemoveMineralGroupDictionaryItem(int Id)
  329. {
  330. //MineralGroupDictionary.Remove(Id);
  331. MineralGroupDictionary[Id].InfoState = (int)DBInfoState.Delete;
  332. }
  333. private void button_Cancel_Click(object sender, EventArgs e)
  334. {
  335. this.DialogResult = DialogResult.Cancel;
  336. this.Close();
  337. }
  338. private void button_OK_Click(object sender, EventArgs e)
  339. {
  340. for (int i = 1; i < Grid_FroupId.RowsCount; i++)
  341. {
  342. for (int j = i+1; j < Grid_FroupId.RowsCount; j++)
  343. {
  344. if(Grid_FroupId[i,0].ToString()== Grid_FroupId[j,0].ToString())
  345. {
  346. Position pos = new Position(i, 0);
  347. Grid_FroupId.Selection.Focus(pos, true);
  348. string DuplicateNames = Grid_FroupId[i, 0].ToString();
  349. MessageBox.Show("The names of groups are reusable which named " + DuplicateNames + ",please modify!", "Tip");
  350. return;
  351. }
  352. }
  353. }
  354. SaveDataIntoDB(MineralGroupDBAddress);
  355. this.DialogResult = DialogResult.Yes;
  356. this.Close();
  357. }
  358. private void 添加组ToolStripMenuItem_Click(object sender, EventArgs e)
  359. {
  360. int Id = AddMineralGroupDictionaryItem();
  361. AddNewRow(Id, "New Group", Color.Gray);
  362. }
  363. private void 删除组ToolStripMenuItem_Click(object sender, EventArgs e)
  364. {
  365. int x = Grid_FroupId.Selection.ActivePosition.Row;
  366. int y = Grid_FroupId.Selection.ActivePosition.Column;
  367. if (x > 0 && (y == 0|| y == 1))
  368. {
  369. bool bexist = false;
  370. foreach (KeyValuePair<int, STDdata> kv in m_MainForm.STDDictionary)
  371. {
  372. if(kv.Value.GroupId.ToString()== Grid_FroupId[x, 0].Tag.ToString())
  373. {
  374. bexist = true;
  375. break;
  376. }
  377. }
  378. if(bexist)
  379. {
  380. MessageBox.Show("There is a grouping in the user standard library that you want to delete!");
  381. return;
  382. }
  383. RemoveMineralGroupDictionaryItem((int)Grid_FroupId[x, 0].Tag);
  384. Grid_FroupId.Rows.Remove(x);
  385. Grid_FroupId.Refresh();
  386. if (Grid_FroupId.RowsCount > 1)
  387. {
  388. Position pos = new Position(1, 0);
  389. Grid_FroupId.Selection.Focus(pos, true);
  390. Grid_FroupId[1, 0].Grid.Select();
  391. }
  392. }
  393. else
  394. {
  395. MessageBox.Show("No gruop is selected!", "Tip");
  396. }
  397. }
  398. private void button_up_Click(object sender, EventArgs e)
  399. {
  400. Grid_FroupId.Focus(true);
  401. int selrow = Grid_FroupId.Selection.ActivePosition.Row;
  402. int id = (int)Grid_FroupId[selrow, 0].Tag;
  403. int id2 = (int)Grid_FroupId[selrow - 1, 0].Tag;
  404. string GroupName = Grid_FroupId[selrow, 0].Value.ToString();
  405. Color color = Grid_FroupId[selrow, 1].View.BackColor;
  406. Grid_FroupId[selrow, 0].Value = Grid_FroupId[selrow - 1, 0].Value;
  407. Grid_FroupId[selrow, 0].Tag = id2;
  408. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  409. view.BackColor = Grid_FroupId[selrow - 1, 1].View.BackColor;
  410. Grid_FroupId[selrow, 1].View = view;
  411. Grid_FroupId[selrow - 1, 0].Value = GroupName;
  412. Grid_FroupId[selrow - 1, 0].Tag = id;
  413. SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
  414. view2.BackColor = color;
  415. Grid_FroupId[selrow - 1, 1].View = view2;
  416. MineralGroupDictionary[id].name = Grid_FroupId[selrow - 1, 0].Value.ToString();
  417. MineralGroupDictionary[id2].name = Grid_FroupId[selrow, 0].Value.ToString();
  418. Grid_FroupId.Refresh();
  419. Position pos = new Position(selrow - 1, 0);
  420. Grid_FroupId[selrow - 1, 0].Grid.Select();
  421. Grid_FroupId.Selection.Focus(pos, true);
  422. button_down.Enabled = true;
  423. if (selrow - 1 == 1)
  424. {
  425. button_up.Enabled = false;
  426. }
  427. }
  428. private void button_down_Click(object sender, EventArgs e)
  429. {
  430. Grid_FroupId.Focus(true);
  431. int selrow = Grid_FroupId.Selection.ActivePosition.Row;
  432. int id = (int)Grid_FroupId[selrow, 0].Tag;
  433. int id2 = (int)Grid_FroupId[selrow + 1, 0].Tag;
  434. string GroupName = Grid_FroupId[selrow, 0].Value.ToString();
  435. Color color = Grid_FroupId[selrow, 1].View.BackColor;
  436. Grid_FroupId[selrow, 0].Value = Grid_FroupId[selrow + 1, 0].Value;
  437. Grid_FroupId[selrow, 0].Tag = (int)Grid_FroupId[selrow + 1, 0].Tag;
  438. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  439. view.BackColor = Grid_FroupId[selrow+1, 1].View.BackColor;
  440. Grid_FroupId[selrow, 1].View = view;
  441. Grid_FroupId[selrow + 1, 0].Value = GroupName;
  442. Grid_FroupId[selrow + 1, 0].Tag = id;
  443. SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
  444. view2.BackColor = color;
  445. Grid_FroupId[selrow + 1, 1].View = view2;
  446. MineralGroupDictionary[id].name = Grid_FroupId[selrow + 1, 0].Value.ToString();
  447. MineralGroupDictionary[id2].name = Grid_FroupId[selrow, 0].Value.ToString();
  448. Grid_FroupId.Refresh();
  449. Position pos = new Position(selrow + 1, 0);
  450. Grid_FroupId[selrow + 1, 0].Grid.Select();
  451. Grid_FroupId.Selection.Focus(pos, true);
  452. button_up.Enabled = true;
  453. if (selrow + 1 == Grid_FroupId.RowsCount - 1)
  454. {
  455. button_down.Enabled = false;
  456. }
  457. }
  458. private void Grid_FroupId_Click(object sender, EventArgs e)
  459. {
  460. SourceGrid.Grid ls_gd = (SourceGrid.Grid)sender;
  461. ls_gd.Focus();
  462. int i = ls_gd.Selection.ActivePosition.Row;
  463. int j = ls_gd.Selection.ActivePosition.Column;
  464. /// 保证鼠标点击的GRID行和列是有效的
  465. if (i >= 0 && j >= 0)
  466. {
  467. if (i == ls_gd.RowsCount - 1)
  468. {
  469. button_down.Enabled = false;
  470. }
  471. else
  472. {
  473. button_down.Enabled = true;
  474. }
  475. if (i == 1)
  476. {
  477. button_up.Enabled = false;
  478. //MessageBox.Show("Group by default, not editable!");
  479. //return;
  480. }
  481. else
  482. {
  483. button_up.Enabled = true;
  484. }
  485. }
  486. }
  487. }
  488. }