示例#1
0
        void DeleteSt()
        {
            try
            {
                if (grdVwStandarts.SelectedRows.Count < 1)
                {
                    MessageBox.Show("Please Select a row.");
                    return;
                }

                if (MessageBox.Show("Standard will be deleted. Are you sure?", "Confirm", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
                {
                    return;
                }


                string strId = string.Format("{0}", grdVwStandarts.SelectedRows[0].Cells["Id"].Value);
                int    id;
                if (int.TryParse(strId, out id))
                {
                    bool isInUse = schoolMan.IsStandardInNotUse(id);
                    if (isInUse == false)
                    {
                        if (MessageBox.Show("Standard is in use. Are you sure to delete Standard?", "Confirm", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
                        {
                            return;
                        }
                        schoolMan.DeleteStandard(id);
                    }
                    else
                    {
                        schoolMan.DeleteStandard(id);
                    }
                }
                MessageBox.Show("Delete Operation succeed.");
                LoadListToGrid();
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                MessageBox.Show("Delete Operation failed.");
            }
        }