Exemplo n.º 1
0
        //Edit
        private void toolStripButtonEdit_Click(object sender, EventArgs e)
        {
            var selectrows = problemDataGridView.SelectedRows;

            if (selectrows == null || selectrows.Count == 0)
            {
                SysHelper.ShowMessageWarning("unselect any row, please select at least one row!");
                return;
            }
            foreach (DataGridViewRow row in selectrows)
            {
                var frm = new ProblemInputForm(row.DataBoundItem as Problem);
                if (frm.ShowDialog() == DialogResult.Cancel)
                {
                    continue;
                }
                Problem newproblem = frm.InputProblem;
                row.Cells[1].Value = newproblem.Number;
                row.Cells[2].Value = newproblem.Title;
                row.Cells[3].Value = newproblem.LtUrl;
                row.Cells[4].Value = newproblem.CsdnAddress;
                row.Cells[6].Value = newproblem.Content;
                IEnumerable <string> tagnames = newproblem.Tags.Select(r => r.Name);
                string combinestr             = string.Empty;
                foreach (var str in tagnames)
                {
                    combinestr += str + ";";
                }
                row.Cells[5].Value = combinestr;
                row.Cells[7].Value = newproblem.Tags;
            }
            _problemController.UpdateProblems();
        }
Exemplo n.º 2
0
        //New
        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            ProblemInputForm problemInput = new ProblemInputForm();
            int rowscnt = problemDataGridView.Rows.Count;

            if (problemInput.ShowDialog() == DialogResult.Cancel)
            {
                if (rowscnt - 1 >= 0)
                {
                    problemDataGridView.Rows.RemoveAt(rowscnt - 2);
                }
                return;
            }
            Problem         newproblem = problemInput.InputProblem;
            int             cnt        = problemDataGridView.Rows.Count;
            DataGridViewRow fillrow    = problemDataGridView.Rows[cnt - 2];

            fillrow.Cells[1].Value = newproblem.Number;
            fillrow.Cells[2].Value = newproblem.Title;
            fillrow.Cells[3].Value = newproblem.LtUrl;
            fillrow.Cells[4].Value = newproblem.CsdnAddress;
            fillrow.Cells[6].Value = newproblem.Content;
            IEnumerable <string> tagnames = newproblem.Tags.Select(r => r.Name);
            string combinestr             = string.Empty;

            foreach (var str in tagnames)
            {
                combinestr += str + ";";
            }
            fillrow.Cells[5].Value = combinestr;
            fillrow.Cells[7].Value = newproblem.Tags;

            problemBindingNavigatorSaveItem_Click(problemDataGridView, null);
        }