private void btnInsertOrModify_Click(object sender, EventArgs e) { bool bReturn = true; if ((txtGoldBarRate.Text == "") || (txtGoldOrnamentRate.Text == "") || (txtSilverRate.Text == "")) { MessageBox.Show("input is empty"); bReturn = false; } if (bReturn == true) { DialogResult dialogResult = MessageBox.Show("Your are trying to Insert/Modify record", "Insert", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.No) { bReturn = false; } } if (bReturn == true) { string strQuery = ""; int nCategoryId = 1; string strDataValue = ""; nCategoryId = 1; strDataValue = GetDataValue(nCategoryId); if (String.IsNullOrEmpty(strDataValue) == true) { //strQuery = InsertStatement(nCategoryId, txtGoldBarRate.Text); strQuery = SingletonSonar.Instance.SettingInsertQuery(nCategoryId, txtGoldBarRate.Text); } else { //strQuery = UpdateStatement(nCategoryId, txtGoldBarRate.Text); strQuery = SingletonSonar.Instance.SettingUpdateQueryWithDate(nCategoryId, txtGoldBarRate.Text); } bReturn = dbConnect.ExecuteGeneral(strQuery); if (bReturn == true) { nCategoryId = 2; strDataValue = GetDataValue(nCategoryId); if (String.IsNullOrEmpty(strDataValue) == true) { //strQuery = InsertStatement(nCategoryId, txtGoldOrnamentRate.Text); strQuery = SingletonSonar.Instance.SettingInsertQuery(nCategoryId, txtGoldOrnamentRate.Text); } else { //strQuery = UpdateStatement(nCategoryId, txtGoldOrnamentRate.Text); strQuery = SingletonSonar.Instance.SettingUpdateQueryWithDate(nCategoryId, txtGoldOrnamentRate.Text); } bReturn = dbConnect.ExecuteGeneral(strQuery); } if (bReturn == true) { nCategoryId = 3; strDataValue = GetDataValue(nCategoryId); if (String.IsNullOrEmpty(strDataValue) == true) { //strQuery = InsertStatement(nCategoryId, txtSilverRate.Text); strQuery = SingletonSonar.Instance.SettingInsertQuery(nCategoryId, txtSilverRate.Text); } else { //strQuery = UpdateStatement(nCategoryId, txtSilverRate.Text); strQuery = SingletonSonar.Instance.SettingUpdateQueryWithDate(nCategoryId, txtSilverRate.Text); } bReturn = dbConnect.ExecuteGeneral(strQuery); } if (bReturn == true) { MessageBox.Show("Records Inserted"); ClearData(); DisplayData(); } } }