public frmCase_SingleForm(UDT.Case Case, List<DataItems.CloudFileUrlItem> googleDocsRowSource) { InitializeComponent(); this.Case = Case; this.GoogleDocsRowSource = googleDocsRowSource; Access = new AccessHelper(); this.ErrorProvider = new ErrorProvider(); this.dgvData.CellEnter += new DataGridViewCellEventHandler(dgvData_CellEnter); this.dgvData.CurrentCellDirtyStateChanged += new EventHandler(dgvData_CurrentCellDirtyStateChanged); this.dgvData.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dgvData_EditingControlShowing); this.dgvData.DataError += new DataGridViewDataErrorEventHandler(dgvData_DataError); this.dgvData.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dgvData_ColumnHeaderMouseClick); this.dgvData.RowHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dgvData_RowHeaderMouseClick); this.dgvData.MouseClick += new System.Windows.Forms.MouseEventHandler(this.dgvData_MouseClick); this.Load += new EventHandler(frmCase_SingleForm_Load); }
private void Save_Click(object sender, EventArgs e) { this.DialogResult = System.Windows.Forms.DialogResult.OK; if (!this.Validated()) { MessageBox.Show("請修正錯誤再儲存。"); this.DialogResult = System.Windows.Forms.DialogResult.None; return; } if (this.Case == null) this.Case = new UDT.Case(); this.Case.EnglishName = this.txtEnglishName.Text.Trim(); this.Case.Name = this.txtName.Text.Trim(); this.Case.No = this.txtCaseNo.Text.Trim(); this.Case.Author = this.txtAuthor.Text.Trim(); this.Case.PublishSchool = this.txtSchool.Text.Trim(); this.Case.Memo = this.txtMemo.Text.Trim(); StringBuilder sb = new StringBuilder("<CaseDocuments>"); foreach (DataGridViewRow row in this.dgvData.Rows) { if (row.IsNewRow) continue; string Url = row.Cells[1].Value + ""; byte[] array = Encoding.UTF8.GetBytes(Url); string Url_Encode = Convert.ToBase64String(array); sb.Append(string.Format(@"<CaseDocument FileName=""{0}"" URL=""{1}"" Memo=""{2}"" />", row.Cells[0].FormattedValue + "", Url_Encode, row.Cells[2].Value + "")); } sb.Append("</CaseDocuments>"); this.Case.UrlList = sb.ToString(); this.Case.Save(); this.Close(); }