private void btnSave_Click(object sender, EventArgs e) { try { string Id = txtID.Text.Trim(); string tName = txtName.Text.Trim(); string qty = txtPrice.Text.Trim(); if (string.IsNullOrEmpty(Id) || string.IsNullOrEmpty(tName)) { MessageBox.Show("Please define Id and Name!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { VarModel data = new VarModel() { ID = Convert.ToInt32(Id), TITLE = tName, PRICE = Convert.ToInt32(qty) }; Insert_Data(data); } txtID.Text = string.Empty; txtName.Text = string.Empty; txtPrice.Text = string.Empty; txtID.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Insert_Data(VarModel data) { try { string sql = "EXEC UXFMUNI..Z_POTEST @TYPE = 'INSERT_TITLE'"; sql = sql + string.Format(",@ID = '{0}'", data.ID); sql = sql + string.Format(",@FTYPENAME = '{0}'", data.TITLE); sql = sql + string.Format(",@QTY = '{0}'", data.PRICE); DB.execSQL(sql); MessageBox.Show("Insert completed!", "Successful!"); tabControl1.SelectedTab = tabPage1; btn_Find_Click(null, null); } catch (Exception ex) { MessageBox.Show(ex.Message); } }