//private string _ConnectionString = ConfigurationManager.ConnectionStrings["MyDBConnectionString"].ConnectionString; void btnOK_Click(object sender, EventArgs e) { var _Name = txtTemplateField.Text; Dictionary <string, object> _dic = new Dictionary <string, object>(); _dic.Add("Name", _Name); _dic.Add("Decription", _Name); var _service = new TemplateService(); int result = _service.Create_Template(_dic); if (result == 1) { this.Close(); } }
void btnAdd_Click(object sender, EventArgs e) { if (txtTemplateName.Text != "" && txtMarkers.Text != "") { var _dic = new Dictionary <string, object>(); var rect = T_Rectangle; var m_Sort = mericSort.Value; _dic.Add("Name", txtTemplateName.Text); _dic.Add("Marked", txtMarkers.Text.Replace("\r\n", "")); _dic.Add("Rect_Bottom", rect.Bottom); _dic.Add("Rect_Left", rect.Left); _dic.Add("Rect_Top", rect.Top); _dic.Add("Rect_Right", rect.Right); _dic.Add("Path", m_strPath); _dic.Add("Sort", m_Sort); _dic.Add("X", rect.X); _dic.Add("Y", rect.Y); _dic.Add("Width", rect.Width); _dic.Add("Height", rect.Height); var _service = new TemplateService(); var result = _service.Create_Template(_dic); if (result != -1) { MessageBox.Show("Record Inserted Successfully"); AddItemListView(); txtTemplate_ID.Text = result.ToString(); label5.Text = txtTemplateName.Text; dataGridView(result); Int32 index = dataGridView2.Rows.Count - 1; int iColumn = dataGridView2.CurrentCell.ColumnIndex; dataGridView2.ClearSelection(); dataGridView2.CurrentCell = dataGridView2.Rows[index].Cells[iColumn]; dataGridView2.Rows[index].Selected = true; btnAddField.Enabled = true; } } else { MessageBox.Show("Please Provide Details!"); } }