Пример #1
0
 private void Mail_AddItemBtn_Click(object sender, EventArgs e)
 {
     ItemsForm.ShowDialog();
     if (ItemsForm.ItemsList.Tables[0].Rows.Count > 0)
     {
         Regex reg = new Regex("\\d+");
         foreach (DataRow dr in ItemsForm.ItemsList.Tables[0].Rows)
         {
             bool IsRepeatedItem = false;
             foreach (DataGridViewRow dgvRow in Mail_ItemDataGridView.Rows)
             {
                 if (dgvRow.Cells[1].Value.ToString() == dr["entry"].ToString())
                 {
                     IsRepeatedItem = true;
                     if (reg.Match(dgvRow.Cells[3].Value.ToString()).Success)
                     {
                         dgvRow.Cells[3].Value = (Convert.ToInt32(reg.Match(dgvRow.Cells[3].Value.ToString()).Value) + 1).ToString();
                     }
                     else
                     {
                         dgvRow.Cells[3].Value = 1;
                     }
                 }
             }
             if (!IsRepeatedItem)
             {
                 Mail_ItemDataGridView.Rows.Add(new object[] { false, dr["entry"].ToString(), dr["name"].ToString(), "1" });
             }
         }
     }
 }