private void btnSettingPort1_Click(object sender, EventArgs e) { if (cmbSettingPort1.SelectedItem == null) { return; } string query = string.Empty; string value = string.Empty; string insertQuery = "insert into ScreenCommon(Commtrack1,commBaud1) values('{0}','{1}')"; string updateQuery = "update ScreenCommon set Commtrack1='{0}',commBaud1='{1}'"; if (ScreenCommonRecordCount() > 0) { query = updateQuery; } else { query = insertQuery; } using (var db = new DBEngine()) { db.ExecuteNonQuery(string.Format(query, cmbSettingPort1.SelectedItem.ToString(), txtSettingBaudRate1.Text)); } MessageBox.Show("Records Saved Successfully"); }
private void SaveDefaultValue() { string insertQuery = "insert into [Default](Product, Source,Destination,Type) values('{0}','{1}','{2}','{3}')"; string updateQuery = "update [Default] set Product='{0}', Source='{1}', Destination='{2}', Type='{3}'"; string selectQuery = "select count(*) from [Default]"; int cnt = 0; string query = string.Empty; string value = string.Empty; using (var db = new DBEngine()) { cnt = (int)db.ExecuteScalar(string.Format(selectQuery), null); } if (cnt > 0) { query = updateQuery; } else { query = insertQuery; } using (var db = new DBEngine()) { db.ExecuteNonQuery(string.Format(query, cmbCommodity.SelectedItem.ToString(), cmbSource.SelectedItem.ToString(), cmbDestination.SelectedItem.ToString(), lstWagonType.SelectedItem.ToString())); } }
private void btnSetWeightUpdate_Click(object sender, EventArgs e) { bool value = false; //chkSettingMultiEnable, chkSettingMultiDisable //IsMultiWeigh if (chkSettingMultiEnable.Checked) { value = true; } if (chkSettingMultiDisable.Checked) { value = true; } bool motionValue = false; if (radInMotionDS505.Checked) { motionValue = false; } if (radStaicWeighing.Checked) { motionValue = true; } string query = string.Empty; string insertQuery = "insert into ScreenCommon(IsMultiWeigh,IsStaticDynamic) values('{0}','{1}')"; string updateQuery = "update ScreenCommon set IsMultiWeigh='{0}', IsStaticDynamic='{1}'"; if (ScreenCommonRecordCount() > 0) { query = updateQuery; } else { query = insertQuery; } using (var db = new DBEngine()) { db.ExecuteNonQuery(string.Format(query, value, motionValue)); } MessageBox.Show("Record Saved"); }