Ejemplo n.º 1
0
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(dataGridView1[1, dataGridView1.RowCount - 1].Value.ToString()) && dataGridView1[1, dataGridView1.RowCount - 1].Value.ToString() != "请输入分组名")
     {
         string room_Name = dataGridView1[1, dataGridView1.RowCount - 1].Value.ToString();
         if (!roomInfo.Contains(room_Name))
         {
             roomInfo.Add(room_Name);
             OnGroupingRoomChanged?.Invoke(room_Name, true);
         }
     }
     this.Dispose();
     this.Close();
 }
Ejemplo n.º 2
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 2)
     {
         string room_Name = dataGridView1[1, e.RowIndex].Value.ToString();
         if (e.RowIndex == dataGridView1.RowCount - 1)
         {
             if (!string.IsNullOrWhiteSpace(dataGridView1[1, e.RowIndex].Value.ToString()) && dataGridView1[1, e.RowIndex].Value.ToString() != "请输入分组名")
             {
                 if (!roomInfo.Contains(room_Name))
                 {
                     roomInfo.Add(room_Name);
                     DataRow row = dataTable_Grp.NewRow();
                     row[0] = dataTable_Grp.Rows.Count;
                     row[1] = room_Name;
                     row[2] = ImageToByte(Image.FromFile(Application.StartupPath + "\\resource\\1x\\[email protected]"));
                     dataGridView1[1, e.RowIndex].Value = "请输入分组名";
                     dataTable_Grp.Rows.InsertAt(row, dataTable_Grp.Rows.Count - 1);
                     dataTable_Grp.Rows[dataTable_Grp.Rows.Count - 1][0] = dataTable_Grp.Rows.Count;
                     OnGroupingRoomChanged?.Invoke(room_Name, true);
                 }
                 else
                 {
                     MessageBox.Show("该房间号已经存在", "错误提示", MessageBoxButtons.OK);
                     dataGridView1[1, e.RowIndex].Value = "请输入分组名";
                 }
             }
             else
             {
                 MessageBox.Show("请输入分组名", "操作提示");
             }
         }
         else
         {
             if (room_Name != "设置组")
             {
                 dataTable_Grp.Rows.RemoveAt(e.RowIndex);
                 for (int i = e.RowIndex; i < dataTable_Grp.Rows.Count - 1; i++)
                 {
                     dataTable_Grp.Rows[i][0] = i + 1;
                 }
                 dataTable_Grp.Rows[dataTable_Grp.Rows.Count - 1][0] = dataTable_Grp.Rows.Count;
                 roomInfo.Remove(room_Name);
                 OnGroupingRoomChanged?.Invoke(room_Name, false);
             }
         }
     }
 }