コード例 #1
0
        private void deleteMedia()
        {
            //get selection
            if (activeMediaRow == null)
            {
                MessageBox.Show("please select row corrently using the left selector column");
                return;
            }
            else
            {
                // cell[0] is the id index
                string idAsStr = activeMediaRow.Cells[0].Value.ToString();
                bool   result  = int.TryParse(idAsStr, out int id); //try parse idAsStr to int id

                //delete selection
                if (result)
                {
                    //string[] resultArr = mediaLogic.deleteMediabyId(id);
                    string[] resultArr = dtFunc.getStrArray(ws.deleteMediaById(id));

                    if (resultArr[0] == "true")
                    {
                        MessageBox.Show("Media item successfully deleted");
                        getAndShowDataGridViews();
                    }
                    else
                    {
                        MessageBox.Show(resultArr[1]);
                    }
                }
                else
                {
                    MessageBox.Show("Media: error converting id string to id int");
                }
            }
        }