Example #1
0
        private void Delete(object sender, EventArgs e)
        {
            if (((MainForm)this.MdiParent).ActiveMdiChild == this)
            {
                if (MessageBox.Show("공장을 삭제 하시겠습니까?", "", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }

                try
                {
                    dgvFactorylist.EndEdit();

                    List <int> CheckList = new List <int>();

                    foreach (DataGridViewRow row in dgvFactorylist.Rows)
                    {
                        DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)dgvFactorylist[0, row.Index];

                        if (chk.Value == null)
                        {
                            continue;
                        }

                        else if ((bool)chk.Value == true)
                        {
                            CheckList.Add(dgvFactorylist[2, row.Index].Value.ToInt());
                        }
                    }

                    int factory_id = Convert.ToInt32(dgvFactorylist.SelectedRows[0].Cells[2].Value);

                    if (CheckList.Count > 0)
                    {
                        service.FactoryDelete(CheckList);

                        LoadData();
                    }
                    else
                    {
                        MessageBox.Show("다시 선택해주세요");
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message);
                }
            }
        }