示例#1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Are you sure to save this brand?", "Save Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             cn.Close();
             cn.Open();
             cm = new SqlCommand("INSERT INTo tblBrand(Brand)VALUEs(@brand)", cn);
             cm.Parameters.AddWithValue("@brand", txtBrand.Text);
             cm.ExecuteNonQuery();
             cn.Close();
             MessageBox.Show("Record has been successfully saved.", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
             clear();
             frmlist.loadRecords();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }