public bool sqlExecuteNonQuery(string sql, bool result_message_show, Model.SettingClass settingClass) { try { conn = DBUtils.GetLocalPLCConnection(settingClass.OfflineServer, "ERPSOFT", settingClass.userOffline, settingClass.password); conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); int response = cmd.ExecuteNonQuery(); if (response >= 1) { if (result_message_show) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "Successful!", "Database Responce"); } conn.Close(); return(true); } else { SystemLog.Output(SystemLog.MSG_TYPE.Err, "Database Responce", ""); conn.Close(); return(false); } } catch (Exception ex) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "Database Responce", ex.Message); conn.Close(); return(false); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { SettingClass = new Model.SettingClass(); if (File.Exists(SaveObject.Pathsave)) { SettingClass = (Model.SettingClass)SaveObject.Load_data(SaveObject.Pathsave); } LoadBackgroundWorker(); LoadNotification(); }
public void sqlDataAdapterFillDatatable(string sql, ref DataTable dt, Model.SettingClass settingClass) { try { conn = DBUtils.GetLocalPLCConnection(settingClass.OfflineServer, "ERPSOFT", settingClass.userOffline, settingClass.password); SqlCommand cmd = new SqlCommand(); SqlDataAdapter adapter = new SqlDataAdapter(); { cmd.CommandText = sql; cmd.Connection = conn; adapter.SelectCommand = cmd; adapter.Fill(dt); } } catch (Exception ex) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "Database Responce", ex.Message); } }
public SqlConnection conn = new SqlConnection(); //get from user database public string sqlExecuteScalarString(string sql, Model.SettingClass settingClass) { String outstring; try { conn = DBUtils.GetLocalPLCConnection(settingClass.OfflineServer, "ERPSOFT", settingClass.userOffline, settingClass.password); SqlCommand cmd = new SqlCommand(sql, conn); conn.Open(); outstring = cmd.ExecuteScalar().ToString(); conn.Close(); return(outstring); } catch (Exception ex) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "Database Responce", ex.Message); return(String.Empty); } }