private void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxX1.Text)) { textBoxX1.Text = _name; textBoxX1.SelectAll(); return; } if (textBoxX1.Text == _name) { return; } try { EditElectronicPaper.UpdatePaperName(textBoxX1.Text, _id); _new_name = textBoxX1.Text; } catch (Exception ex) { MsgBox.Show(ex.Message); } this.DialogResult = DialogResult.OK; }
private void btnDelete_Click(object sender, EventArgs e) { if (dgvPaperList.SelectedRows.Count <= 0) { return; } DataGridViewRow row = dgvPaperList.SelectedRows[0]; if (MsgBox.Show("您確定要刪除「" + row.Cells[colName.Index].Value + "」嗎?", "刪除確認", MessageBoxButtons.YesNo) == DialogResult.No) { return; } try { EditElectronicPaper.Delete("" + row.Cells[colID.Index].Value); } catch (Exception ex) { MsgBox.Show(ex.Message); } LoadElectronicPaper(cboSchoolYear.Text, cboSemester.Text); //dgvPaperList.ClearSelection(); }
public void Dispatch(ElectronicPaper ePaper) { string epaperId = EditElectronicPaper.Insert( ePaper.Name, ePaper.SchoolYear, ePaper.Semester, ePaper.ViewerType.ToString(), ePaper.Metadata); List <DSXmlHelper> requests = new List <DSXmlHelper>(); DSXmlHelper papers = null; int count = 0; IProgressReceiver receiver = ePaper.ProgressReceiver; if (receiver == null) { receiver = new ElectronicPaperProgress(); } foreach (PaperItem eachPaper in ePaper) { if (eachPaper.Viewers.Count <= 0) { throw new ArgumentException("每一張電子報表至少要有一個 Viewer。"); } if (count % 10 == 0) { papers = new DSXmlHelper("Request"); requests.Add(papers); } DSXmlHelper paper = new DSXmlHelper(papers.AddElement("Paper")); foreach (string eachViewer in eachPaper.Viewers) { paper.AddElement(".", "RefElectronicPaperID", epaperId); paper.AddElement(".", "Format", eachPaper.Format); paper.AddElement(".", "Content", eachPaper.Content); //paper.AddElement(".", "ViewerType", ePaper.ViewerType.ToString()); paper.AddElement(".", "ViewerID", eachViewer); count++; } } if (count > 0) { if (receiver != null) { receiver.ProcessStart(); } int current = 1; foreach (DSXmlHelper each in requests) { EditElectronicPaper.InsertPaperItem(each); if (receiver != null) { receiver.ProcessProgress((int)(((float)current / (float)requests.Count) * 100f)); } current++; } if (receiver != null) { receiver.ProcessEnd(); } } }