コード例 #1
0
        public override void NewCmd()
        {
            NewsForm newForm = new NewsForm();

            if (newForm.ShowDialog() == DialogResult.OK)
            {
                DataRow newRow = _newsTable.NewRow();
                newRow["manager_id"]   = OMWorkBench.MangerId;
                newRow["title"]        = newForm.NewsTitle;
                newRow["column_id"]    = newForm.NewsCol;
                newRow["publish_time"] = newForm.NewsPublishTime;
                newRow["content"]      = newForm.NewsContent;
                _newsTable.LoadDataRow(newRow.ItemArray, false);

                int rows = OMWorkBench.DataAgent.UpdateNews(_newsTable.GetChanges());
                _newsTable          = OMWorkBench.DataAgent.GetNews();
                _newsBDS.DataSource = _newsTable;
            }
        }
コード例 #2
0
        public override void EditCmd()
        {
            int      newsId  = Convert.ToInt32(newsDGV.CurrentRow.Cells["newsId"].Value);
            NewsForm newForm = new NewsForm();

            DataRow editRow = _newsTable.Select("id=" + newsId)[0];

            newForm.NewsTitle       = editRow["title"].ToString();
            newForm.NewsCol         = Convert.ToInt32(editRow["column_id"]);
            newForm.NewsPublishTime = Convert.ToDateTime(editRow["publish_time"]);
            newForm.NewsContent     = editRow["content"].ToString();
            if (newForm.ShowDialog() == DialogResult.OK)
            {
                editRow["manager_id"]   = OMWorkBench.MangerId;
                editRow["title"]        = newForm.NewsTitle;
                editRow["column_id"]    = newForm.NewsCol;
                editRow["publish_time"] = newForm.NewsPublishTime;
                editRow["content"]      = newForm.NewsContent;

                int rows = OMWorkBench.DataAgent.UpdateNews(_newsTable.GetChanges());
                _newsTable.AcceptChanges();
            }
        }