public CodeTemplate save(CodeTemplate _template) { if (_template.Id == 0) { var id = Db.Insert(_template); _template.Id = id; } else { Db.Update(_template); } return(_template); }
public CodeTemplate save(CodeTemplate _template) { if (_template.Id == 0) { var id = Db.Insert(_template); _template.Id = id; } else { Db.Update(_template); } return _template; }
// SAPINTGUI.AbapCode.Codedb codedb = null; private void userDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } if (dt == null || dt.Rows.Count == 0) { return; } dgvSelectedCell = userDataGridView[e.ColumnIndex, e.RowIndex]; dgvSelectedRow = userDataGridView.Rows[e.RowIndex]; if (dgvSelectedRow.Cells["id"].Value != null) { int id = 0; int.TryParse(dgvSelectedRow.Cells["id"].Value.ToString(), out id); _codeTemplate = codeManager.get(id); } if (_codeTemplate == null || _codeTemplate.Id == 0) { MessageBox.Show("无法读取代码"); return; } else { label2.Text = _codeTemplate.Id.ToString(); textCodeDesc.Text = _codeTemplate.Desc; } try { //if (checkboxAuto.Checked == true) //{ if (this.textResultCode.Focused) { this.textResultCode.Document.Text = _codeTemplate.Content; } else { this.textTemplate.Document.Text = _codeTemplate.Content; } //} } catch (Exception E) { MessageBox.Show(E.Message); } }
private void SaveTemplate2() { if (String.IsNullOrEmpty(this.textCodeDesc.Text)) { MessageBox.Show("请填写代码描述"); return; } if (_codeTemplate == null) { _codeTemplate = new CodeTemplate(); newTemplate = true; } else { newTemplate = false; } _codeTemplate.Content = this.textTemplate.Document.Text; _codeTemplate.Desc = this.textCodeDesc.Text; _codeTemplate = codeManager.save(_codeTemplate); MessageBox.Show("模板保存成功: " + _codeTemplate.Desc); label2.Text = _codeTemplate.Id.ToString(); textCodeDesc.Text = _codeTemplate.Desc; DataRow row = null; if (dt != null && newTemplate == true) { row = dt.NewRow(); row["id"] = _codeTemplate.Id; row["Desc"] = _codeTemplate.Desc; dt.Rows.Add(row); } else if (dgvSelectedRow != null) { var view = dgvSelectedRow.DataBoundItem as DataRowView; row = view.Row; if (row != null) { row["id"] = _codeTemplate.Id; row["Desc"] = _codeTemplate.Desc; } } }
private void SaveTemplate() { var index = -1; if (userDataGridView.SelectedCells[0] != null) { index = userDataGridView.SelectedCells[0].RowIndex; } if (index < 0 || _codeTemplate == null || index >= dt.Rows.Count) { _codeTemplate = new CodeTemplate(); } else { int id; int.TryParse(userDataGridView["id", index].Value.ToString(), out id); _codeTemplate.Desc = userDataGridView["desc", index].Value.ToString(); _codeTemplate.Id = id; } _codeTemplate.Content = textTemplate.Document.Text; _codeTemplate = codeManager.save(_codeTemplate); label2.Text = _codeTemplate.Id.ToString(); textCodeDesc.Text = _codeTemplate.Desc; if (dt != null) { if (index >= dt.Rows.Count || index < 0) { dt.Rows.Add(_codeTemplate.Id, _codeTemplate.Content, _codeTemplate.Desc); //userDataGridView.Rows.Add(_code.Id, _code.Content, _code.Desc); } else { dgvSelectedRow = userDataGridView.Rows[index]; //if (dgvSelectedRow != null) //{ dgvSelectedRow.Cells["id"].Value = _codeTemplate.Id; // dgvSelectedRow.Cells["content"].Value = _code.Content; dgvSelectedRow.Cells["Desc"].Value = _codeTemplate.Desc; //} } } MessageBox.Show("保存成功"); }
private void CreateNewTemplate() { this._codeTemplate = new CodeTemplate(); newTemplate = true; this.label2.Text = ""; this.textCodeDesc.Text = ""; this.textTemplate.Document.Text = ""; //var row = dt.NewRow(); //dgvSelectedRow = userDataGridView.Rows[userDataGridView.RowCount - 1]; // dgvSelectedRow.Selected = true; }