示例#1
0
        public ActionResult Delete(CategoryClass cate)
        {
            CategoryList cateList = new CategoryList();

            cateList.DeleteCategory(cate);
            return(RedirectToAction("Index"));
        }
示例#2
0
        private void deleteRow_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count == 0)
            {
                MessageBox.Show("Please choose a row to delete");
                return;
            }
            string       dePath = this.dataGridView1.SelectedCells[4].Value.ToString();
            DialogResult rslt   = MessageBox.Show("Are you sure you want to delete this record no : " +
                                                  this.dataGridView1.SelectedCells[0].Value + " ?", "[Confirmation]", MessageBoxButtons.YesNo);

            if (rslt == DialogResult.Yes)
            {
                string item;
                item = this.dataGridView1.SelectedCells[0].Value.ToString();
                CategoryList.DeleteCategory(item);
            }
            else
            {
                return;
            }
            int count = 0;

            foreach (char c in dePath)
            {
                if (c == '|')
                {
                    count++;
                }
            }
            string tpath;

            for (int i = 0; i <= count; i++)
            {
                if (dePath.Contains('|'))
                {
                    tpath  = dePath.Substring(0, dePath.IndexOf('|'));
                    dePath = dePath.Substring(dePath.IndexOf('|') + 1);
                }
                else
                {
                    tpath = dePath;
                }
                if (File.Exists(tpath))
                {
                    File.Delete(tpath);
                }
                if (Directory.Exists(Path.GetDirectoryName(tpath)))
                {
                    if (Directory.GetFiles(Path.GetDirectoryName(tpath)).Length == 0 &&
                        Directory.GetDirectories(Path.GetDirectoryName(tpath)).Length == 0)
                    {
                        Directory.Delete(Path.GetDirectoryName(tpath));
                    }
                }
            }
            populate(search.Text);
        }
示例#3
0
        private void delete_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count == 0)
            {
                MessageBox.Show("Please choose a row to delete");
                return;
            }
            try
            {
                MessageBox.Show(this.dataGridView1.SelectedCells[3].Value.ToString());
                DialogResult rslt = MessageBox.Show("Are sure want to delete this record no : " +
                                                    this.dataGridView1.SelectedCells[0].Value + " ?", "[Confirmation]", MessageBoxButtons.YesNo);
                if (rslt == DialogResult.Yes)
                {
                    string item;
                    item = this.dataGridView1.SelectedCells[0].Value.ToString();
                    CategoryList.DeleteCategory(item);
                }
            }
            catch (Exception exp)
            {
                string strExp = "Record " + this.dataGridView1.SelectedCells[5].Value + " failed delete to datasource\n Message : " + exp.Message;
                MessageBox.Show(strExp, "[Status Dialog]", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            /*if (MessageBox.Show("Do you want to remove this row?", "Remove Line",
             * MessageBoxButtons.YesNo, MessageBoxIcon.Question)
             * == DialogResult.Yes)
             * {
             * DataGridViewRow row = this.dataGridView1.SelectedRows[0];
             * this.dataGridView1.Rows.Remove(row);
             * this.fileListBindingSource.EndEdit();
             * this.fileListTableAdapter.Update(database1DataSet.fileList);
             * fileListTableAdapter.Fill(this.database1DataSet.fileList);
             * } */
        }