public void SetAppProgramConfig() { try { SQLiteDBHelper dbApp = new SQLiteDBHelper(GlobalShare.stratPath); string sql = @"update AppConfig set Value=@Value where Key=@Key"; SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@Key", "IP"), new SQLiteParameter("@Value", GlobalShare.ipAddress) }; dbApp.ExecuteNonQuery(sql, parameters); parameters = new SQLiteParameter[] { new SQLiteParameter("@Key", "Port"), new SQLiteParameter("@Value", GlobalShare.port) }; dbApp.ExecuteNonQuery(sql, parameters); sql = @"select * from LoginInfo"; DataTable dt = db.ExecuteDataTable(sql, null); if (dt != null && dt.Rows.Count > 0) { sql = @"insert into LoginInfo(LoginID,CreateTime) values(@LoginID,@CreateTime)"; for (int i = 0; i < dt.Rows.Count; i++) { parameters = new SQLiteParameter[] { new SQLiteParameter("@LoginID", dt.Rows[i].ItemArray[1].ToString()), new SQLiteParameter("@CreateTime", dt.Rows[i].ItemArray[2].ToString()) }; dbApp.ExecuteNonQuery(sql, parameters); } } } catch (Exception ex) { } }
/// <summary> /// 初始化 /// </summary> public static bool Init() { try { string dbPath = Environment.CurrentDirectory + "/" + "flow_history.db"; //如果不存在数据库文件,则创建该数据库文件 if (!System.IO.File.Exists(dbPath)) { SQLiteDBHelper.CreateDB(dbPath); } db = new SQLiteDBHelper(dbPath); string sql; sql = "CREATE TABLE IF NOT EXISTS flow(fid integer PRIMARY KEY autoincrement DEFAULT (1),pid integer, flow_up long, flow_down long, note_date date);"; db.ExecuteNonQuery(sql, null); // 创建 flow 表 sql = "CREATE TABLE IF NOT EXISTS program(pid integer PRIMARY KEY autoincrement DEFAULT (1), name varchar(30), path text, describe text);"; db.ExecuteNonQuery(sql, null); // 创建 program 表 } catch (Exception e) { //FM_Info.showError(e); return(false); } return(true); }
public void SaveDetail(int curTotalNum) { try { int otherTotalNum = GetOtherCaseProductTotal(this.prodID, this.caseNumberID); int caseDetailNum = Convert.ToInt32(lblTotalNum.Text); int caseSNum = Convert.ToInt32(lblsNum.Text); if (caseDetailNum > caseSNum) { msg.ShowMessage("实发数量不能超过应发数量", 1); } else { if (!string.IsNullOrEmpty(txtNum.Text) && Convert.ToInt32(txtNum.Text) > 0) { string sql = @"select * from CaseNumberDetail where ProdID=@ProdID and CaseNumberID=@CaseNumberID"; SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@ProdID", this.prodID), new SQLiteParameter("@CaseNumberID", this.caseNumberID) }; DataTable partDt = db.ExecuteDataTable(sql, parameters); if (partDt != null && partDt.Rows.Count > 0) { sql = @"update CaseNumberDetail set Num=@Num where CaseNumberID=@CaseNumberID and ProdID=@ProdID"; parameters = new SQLiteParameter[] { new SQLiteParameter("@Num", (caseDetailNum - otherTotalNum)), new SQLiteParameter("@CaseNumberID", this.caseNumberID), new SQLiteParameter("@ProdID", this.prodID) }; db.ExecuteNonQuery(sql, parameters); } else { if (caseDetailNum - otherTotalNum > 0) { sql = @"insert into CaseNumberDetail(ID,ProdID,Num,CaseNumberID,Barcode,CreateTime,LoginID) values (@ID,@ProdID,@Num,@CaseNumberID,@Barcode,@CreateTime,@LoginID)"; parameters = new SQLiteParameter[] { new SQLiteParameter("@ID", Guid.NewGuid().ToString()), new SQLiteParameter("@ProdID", this.prodID), new SQLiteParameter("@Num", (caseDetailNum - otherTotalNum)), new SQLiteParameter("@CaseNumberID", this.caseNumberID), new SQLiteParameter("@Barcode", this.barcode), new SQLiteParameter("@CreateTime", DateTime.Now.ToString()), new SQLiteParameter("@LoginID", GlobalShare.LoginID) }; db.ExecuteNonQuery(sql, parameters); } } } } } catch (Exception ex) { } }
private void button3_Click(object sender, EventArgs e) { string dbPath = connectionString; //如果不存在改数据库文件,则创建该数据库文件 if (!System.IO.File.Exists(dbPath)) { SQLiteDBHelper.CreateDB(connectionString); } string sqlcreatetab = "CREATE TABLE CriticalData" + "(id integer IDENTITY(1,1) NOT NULL," + "lcNum varchar(1,20) NOT NULL," + "generatorId int NOT NULL," + "oilPress real NOT NULL," + "waterTemp real NOT NULL," + "frequency real NOT NULL," + "motorSpeed real NOT NULL," + "voltage real NOT NULL," + "current real NOT NULL," + "motorPower real NOT NULL," + "powerFactor real ," + "oilMass real NOT NULL," + "alarmValue int NOT NULL," + "dateTime datetime NOT NULL)"; string Inspe = "CREATE TABLE InspectionRecords(" + "id int IDENTITY(1,1) NOT NULL," + "lcNum nchar(20) NOT NULL," + "status nchar(10) NOT NULL," + "planTime datetime NOT NULL," + "recordTime datetime NULL," + "worker nchar(20) NOT NULL," + "remarks nchar(30) NULL)"; StringBuilder temperaturesql = new StringBuilder(); temperaturesql.Append(" CREATE TABLE tab_temperature (lcnum nvarchar(10) NULL,"); for (int i = 1; i <= 57; i++) { temperaturesql.Append("s" + i + " int NULL,t" + i + " real NULL,"); } temperaturesql.Append("sendtime datetime NULL)"); SQLiteDBHelper db = new SQLiteDBHelper(""); bool result1 = db.ExecuteNonQuery(sqlcreatetab, null) > 0; bool result2 = db.ExecuteNonQuery(Inspe, null) > 0; bool result3 = db.ExecuteNonQuery(temperaturesql.ToString(), null) > 0; if (result1 && result2 && result3) { MessageBox.Show("ok"); } }
void detailFrm_CaseDetailMgrWindowBackDegelate() { try { string sql = @"update CaseNumber set Total=(select sum(Num) from CaseNumberDetail where CaseNumber.ID=CaseNumberDetail.CaseNumberID)"; db.ExecuteNonQuery(sql, null); ReloadCaseData(""); } catch (Exception ex) { } hkCaseMgr.Start(); }
/// <summary> /// 持久化需要线上获取的统计信息 /// </summary> /// <param name="functionname"></param> /// <param name="res"></param> public static void updateAsyncData(string functionname, string res) { DataTable dt = SQLiteDBHelper.ExecuteDataTable(string.Format("select * from asyncdata where functionname = '{0}'", functionname)); Console.WriteLine(string.Format("select * from asyncdata where functionname = '{0}'", functionname)); DataRow row = null; if (dt.Rows.Count > 0) { row = dt.Rows[0]; } if (null == row) { string insertsql = string.Format("insert into asyncdata(functionname,res)values('{0}','{1}')", functionname, res ); if (SQLiteDBHelper.ExecuteNonQuery(insertsql) > 0) { Console.WriteLine("新增模板记录成功!"); } } else { string insertsql = string.Format("update asyncdata set res = '{0}' where functionname = '{1}'", res, functionname ); if (SQLiteDBHelper.ExecuteNonQuery(insertsql) > 0) { //Console.WriteLine("修改模板记录成功!"); } } }
public void IsPostAlarmData() {//循环查询未发送到服务端的alram,补发 List <string> IsPostIDList = new List <string>() { }; string EXEPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; string dbPath = EXEPath + "Demo.db3"; string sql = "select * from AlarmLog where IsPost = 0"; string stID = ""; string stAlarmID = ""; SQLiteDBHelper db = new SQLiteDBHelper(dbPath); using (SQLiteDataReader reader = db.ExecuteReader(sql, null)) { while (reader.Read()) { stID = reader["id"].ToString(); stAlarmID = reader["AlarmID"].ToString(); int nWarningID = DTSManager.PostSever.PostWarningData(Convert.ToInt32(stAlarmID)); if (nWarningID != 0) { string sql2 = "UPDATE AlarmLog SET IsPost = @IsPost, ServerWaringID = @ServerWaringID where id = " + stID; SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@IsPost", 1), new SQLiteParameter("@ServerWaringID", nWarningID) }; int DBResult = db.ExecuteNonQuery(sql2, parameters); } } } }
public static string RecordAlarmToDB(AlarmInfo AlaInfo) { string EXEPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; string dbPath = EXEPath + "Demo.db3"; SQLiteDBHelper db = new SQLiteDBHelper(dbPath); string sql2 = "INSERT INTO AlarmLog(datetime,AlarmID,AlarmName,AlarmLevel,HandleAlarmMode,ServerWarningID,IsPost)" + "values(@datetime,@AlarmID,@AlarmName,@AlarmLevel,@HandleAlarmMode,@ServerWarningID,@IsPost)"; SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@datetime", DateTime.Now), new SQLiteParameter("@AlarmID", AlaInfo.AlarmID), new SQLiteParameter("@AlarmName", AlaInfo.AlarmName), new SQLiteParameter("@AlarmLevel", AlaInfo.AlarmLevel), new SQLiteParameter("@HandleAlarmMode", AlaInfo.HandleAlarmMode), new SQLiteParameter("@ServerWarningID", AlaInfo.ServerWarningID), new SQLiteParameter("@IsPost", (AlaInfo.ServerWarningID == 0)?0:1) }; db.ExecuteNonQuery(sql2, parameters); string sql3 = "select max(id) from AlarmLog"; string stID = ""; using (SQLiteDataReader reader = db.ExecuteReader(sql3, null)) { while (reader.Read()) { stID = reader["max(id)"].ToString(); } } return(stID); }
private void button1_Click(object sender, EventArgs e) { string stPeople = PeopletextBox.Text; if ((string.IsNullOrEmpty(stPeople))) { MessageBox.Show("请输入更换人员!"); return; } string EXEPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; XmlDocument XMLalarmInfo = new XmlDocument(); XMLalarmInfo.Load(EXEPath + "ConsumableInfoConfig.xml"); XmlElement el = XMLalarmInfo.DocumentElement; XmlNodeList ConsumableInfoNodes = el.GetElementsByTagName("ConsumableInfo"); foreach (XmlNode node in ConsumableInfoNodes) { XmlNodeList ConsumableNode = node.ChildNodes; string stConsumableID = ((XmlElement)ConsumableNode[0]).InnerText; if (0 == stConsumableID.CompareTo(m_stConsumableID)) { m_stConsumableName = ((XmlElement)ConsumableNode[1]).InnerText; m_stLifetime = ((XmlElement)ConsumableNode[3]).InnerText; break; } } string dbPath = EXEPath + "Demo.db3"; SQLiteDBHelper db = new SQLiteDBHelper(dbPath); int nLifetime = Convert.ToInt32(m_stLifetime) * 60; string sql2 = "INSERT INTO ConsumableLog(datetime,ConsumableID,ConsumableName,Lifetime,WorkingTime,Changetime,ChangePeopleName,Remarks)" + "values(@datetime,@ConsumableID,@ConsumableName,@Lifetime,@WorkingTime,@Changetime,@ChangePeopleName,@Remarks)"; DateTime CurrentDatetime = DateTime.Now; SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@datetime", DateTime.Now), new SQLiteParameter("@ConsumableID", m_stConsumableID), new SQLiteParameter("@ConsumableName", m_stConsumableName), new SQLiteParameter("@Lifetime", nLifetime), new SQLiteParameter("@WorkingTime", "0"), new SQLiteParameter("@Changetime", CurrentDatetime), new SQLiteParameter("@ChangePeopleName", PeopletextBox.Text), new SQLiteParameter("@Remarks", ResultrichTextBox.Text) }; int DBResult = db.ExecuteNonQuery(sql2, parameters); if (DBResult > 0) { MessageBox.Show("易损件更换完成!"); } this.Close(); DTSManager.PostSever.PostConsumableReplaceData(PeopletextBox.Text, Convert.ToInt32(m_stConsumableID), 0, CurrentDatetime.ToString()); }
/// <summary> /// 更新本地数据库组织机构版本信息 /// </summary> public static void UpdateOrgVersion(IMLibrary3.Protocol.OrgVersion orgVersion) { try { if (orgVersion.RoomsVersion == null) { orgVersion.RoomsVersion = ""; } if (orgVersion.GroupsVersion == null) { orgVersion.GroupsVersion = ""; } if (orgVersion.UsersVersion == null) { orgVersion.UsersVersion = ""; } string sql = "update OrgVersion set Password='',GroupsVersion=@GroupsVersion,UsersVersion=@UsersVersion,RoomsVersion=@RoomsVersion"; System.Data.SQLite.SQLiteParameter[] parameters = new System.Data.SQLite.SQLiteParameter[] { new System.Data.SQLite.SQLiteParameter("@GroupsVersion", orgVersion.GroupsVersion), new System.Data.SQLite.SQLiteParameter("@UsersVersion", orgVersion.UsersVersion), new System.Data.SQLite.SQLiteParameter("@RoomsVersion", orgVersion.RoomsVersion), }; SQLiteDBHelper.ExecuteNonQuery(sql, parameters); } catch (Exception ex) { MessageBox.Show(ex.Source + ex.Message); } }
public static void AddRecord(string name) { string sql = "update Demo set rank = rank + 1 where name=@name"; SQLiteDBHelper db = new SQLiteDBHelper(dbPath); SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@name", name) }; db.ExecuteNonQuery(sql, parameters); }
private void DelBtn_Click(object sender, EventArgs e) { int id = 0; if (IdIsNull(ref id)) { MessageBox.Show("请选择具体的行!", "警告"); return; } MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("确定要删除该行数据吗?", "确定", messButton); if (dr == DialogResult.OK)//如果点击“确定”按钮 { string sql = "delete from Sip2Info where id = @id"; // 获取基目录,它由程序集冲突解决程序用来探测程序集。 string dbPath = AppDomain.CurrentDomain.BaseDirectory + "Sip2Info.db"; SQLiteDBHelper db = new SQLiteDBHelper(dbPath); SQLiteParameter[] ps = { new SQLiteParameter() { ParameterName = "id", Value = id } }; db.ExecuteNonQuery(sql, ps); this.Reload(); } else//如果点击“取消”按钮 { } }
public void DeleteByName(string name) { string sql = "delete from CodeMass where CodeName=" + name; SQLiteDBHelper db = new SQLiteDBHelper(path); db.ExecuteNonQuery(sql, null); return; }
public string DeleteSelectedColumn(List <string> arr) { string resultStr = ""; string str = "("; if (arr.Count > 0) { for (var a = 0; a < arr.Count; a++) { str += "'" + arr[a] + "',"; } } str = str.Substring(0, str.Length - 1) + ")"; string sqlString = "delete from led_info where id in" + str; try { SQLiteDBHelper.ExecuteNonQuery(sqlString, null); resultStr = "删除成功!"; } catch (Exception e) { Console.Out.WriteLine("" + e.Message); resultStr = "删除失败,请联系管理员!"; } return(resultStr); }
/// <summary> /// 更新书源 /// </summary> /// <param name="bookSource"></param> /// <returns></returns> public static bool SourceUpdate(BookSource bookSource) { string sql = "update BookSource set 'Title'='" + bookSource.Title + "','Url'='" + bookSource.Url + "','SearchUrl'='" + bookSource.SearchUrl + "','AddressRangeRegular'='" + bookSource.AddressRangeRegular + "','AddressCuttingRegular'='" + bookSource.AddressCuttingRegular + "','AddressRegular'='" + bookSource.AddressRegular + "','BookNameRegular'='" + bookSource.BookNameRegular + "','AuthorRegular'='" + bookSource.AuthorRegular + "','UpdateRegular'='" + bookSource.UpdateRegular + "','NewestRegular'='" + bookSource.NewestRegular + "','DetailsRegular'='" + bookSource.DetailsRegular + "','StateRegular'='" + bookSource.StateRegular + "','DirectoryScopeRegular'='" + bookSource.DirectoryScopeRegular + "','DirectoryCuttingRegular'='" + bookSource.DirectoryCuttingRegular + "','DirectoryTieleRegular'='" + bookSource.DirectoryTieleRegular + "','DirectoryUrlRegular'='" + bookSource.DirectoryUrlRegular + "','ContentTitleRegular'='" + bookSource.ContentTitleRegular + "','ContentRegular'='" + bookSource.ContentRegular + "','ImageRegular'='" + bookSource.ImageRegular + "' where Id=" + bookSource.Id; //TempData.UpdateBookSourceS(); return((SQLiteDBHelper.ExecuteNonQuery(sql, null) <= 0) ? false : true); }
/// <summary> /// 更新全部书籍 /// </summary> public static void BooksUpdate(object ob) { //获取全部书籍 DataTable dt = SQLiteDBHelper.ExecuteDataTable("select *from Books", null); List <Book> Books = ModelConvertHelper <Book> .DataTableToList(dt); foreach (Book book in Books) { //获取初始搜索文本 string html = GetHtml.GetHttpWebRequest(book.Url); BookSource bs = GetBookSource(book.Source); //检测书源有效性 if (bs.Title is null) { Tips tips = new Tips(book.Name + "的书源不存在,请检查书源是否已经被删除掉?"); tips.Show(); return; } //获取最新章节 string LatestChapters = Tool.GetRegexStr(html, bs.NewestRegular).Trim(); //获取更新时间 string Update = Tool.GetRegexStr(html, bs.UpdateRegular).Trim(); SQLiteDBHelper.ExecuteNonQuery("Update Books set 'Newest' = '" + LatestChapters + "', 'Update' = '" + Tool.GetUpdataDate(Update) + "' where Id =" + book.Id, null); } ((MainWindow)ob).Dispatcher.Invoke(new Action(() => { ((MainWindow)ob).DataContext = DataFetch.GetBooks(); })); }
public void addArc(Point center, int radius, int startAngle, int sweepAngle, int index) { string sql = @"INSERT INTO arcTable(indexNo,Ox,Oy,startAngle,sweepAngle,endAngle,radius,ownerMap) values(@index,@Ox,@Oy,@startAngle,@sweepAngle,@endAngle,@radius,@ownerMap)"; SQLiteDBHelper db = getDataBase(); SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@index", index), new SQLiteParameter("@Ox", center.X), new SQLiteParameter("@Oy", center.Y), new SQLiteParameter("@startAngle", startAngle), new SQLiteParameter("@sweepAngle", sweepAngle), new SQLiteParameter("@endAngle", startAngle + sweepAngle), new SQLiteParameter("@radius", radius), new SQLiteParameter("@ownerMap", mapName), }; try { db.ExecuteNonQuery(sql, parameters); } catch (Exception x) { Console.WriteLine(x.Message); } }
public void modifyArc(Point center, int radius, int startAngle, int sweepAngle, int index) { string sql = @"UPDATE arcTable SET radius = @radius,Ox=@Ox,Oy = @Oy, startAngle = @startAngle,sweepAngle = @sweepAngle, endAngle = @endAngle WHERE (indexNo = @index) and (ownerMap=@ownerMap)"; SQLiteDBHelper db = getDataBase(); SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@index", index), new SQLiteParameter("@Ox", center.X), new SQLiteParameter("@Oy", center.Y), new SQLiteParameter("@startAngle", startAngle), new SQLiteParameter("@sweepAngle", sweepAngle), new SQLiteParameter("@endAngle", startAngle + sweepAngle), new SQLiteParameter("@radius", radius), new SQLiteParameter("@ownerMap", mapName), }; try { db.ExecuteNonQuery(sql, parameters); } catch (Exception x) { Console.WriteLine(x.Message); } }
//保存巡检记录 public bool SaveInspectionRecord(Model._XJmodel inspectionRecord) { SQLiteParameter[] sqlParams = new SQLiteParameter[6]; sqlParams[0] = new SQLiteParameter(PARAM_LCNUM, DbType.String, 20); sqlParams[1] = new SQLiteParameter(PARAM_STATUS, DbType.String, 10); sqlParams[2] = new SQLiteParameter(PARAM_PTIME, DbType.DateTime, 8); sqlParams[3] = new SQLiteParameter(PARAM_RTIME, DbType.DateTime, 8); sqlParams[4] = new SQLiteParameter(PARAM_WORKER, DbType.String, 20); sqlParams[5] = new SQLiteParameter(PARAM_REMARKS, DbType.String, 30); sqlParams[0].Value = inspectionRecord.lcNumber; sqlParams[1].Value = inspectionRecord.getStatus; sqlParams[2].Value = inspectionRecord.getBjtime; if (inspectionRecord.getRecordTime == null) { sqlParams[3].Value = DBNull.Value; } else { sqlParams[3].Value = inspectionRecord.getRecordTime; } sqlParams[4].Value = inspectionRecord.getWorker; sqlParams[5].Value = inspectionRecord.getContent == null ? "" : inspectionRecord.getContent; SQLiteDBHelper sdb = new SQLiteDBHelper(Program.g_dbPath); return(sdb.ExecuteNonQuery(INSERT_XJ, sqlParams) > 0); }
private void btnOK_Click(object sender, EventArgs e) { try { //获取用户设置的配置内容,并保存到数据库,数据库ledscreen,表名 setting_info string execSql = "delete from setting_info"; SQLiteDBHelper.ExecuteNonQuery(execSql); string serialPort = this.cbxSerialPort.Text.Trim(); string baudRate = this.cbxBaudRate.Text.Trim(); string oddEvenValid = this.cbxValidate.Text.Trim(); string sql = "insert into setting_info(port,baud_rate,odd_even_valid) values('" + serialPort + "','" + baudRate + "','" + oddEvenValid + "')"; int count = SQLiteDBHelper.ExecuteNonQuery(sql); if (count > 0) { MessageBox.Show("参数设置成功!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("参数设置失败!", "错误", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } } catch { MessageBox.Show("参数设置出错", "错误", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } }
/// <summary> /// 更换书籍的源 /// </summary> /// <param name="book">书籍信息</param> /// <returns>返回更改结果</returns> public static bool UpdateBookSource(Book book) { string sql = "update Books set Url='" + book.Url + "',UpdateState = '" + book.UpdateState + "',Details = '" + book.Details + "',Author = '" + book.Author + "',Source = '" + book.Source + "',Image = '" + book.Image + "',Newest = '" + book.Newest + "','Update' = '" + book.Update + "' where Id = " + book.Id; return((SQLiteDBHelper.ExecuteNonQuery(sql, null) <= 0) ? false : true); //需要更新作者、更新日期、最新章节、书籍地址、书源信息、封面图 }
private void button1_Click(object sender, EventArgs e) { string stPeople = PeopletextBox.Text; string stResult = ResultrichTextBox.Text; if ((string.IsNullOrEmpty(stPeople)) || (string.IsNullOrEmpty(stResult))) { MessageBox.Show("请输入处理人员和处理结果!"); return; } string EXEPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; string dbPath = EXEPath + "Demo.db3"; SQLiteDBHelper db = new SQLiteDBHelper(dbPath); string sql2 = "UPDATE AlarmLog SET HandleTime = @HandleTime,HandlePeopleName = @HandlePeopleName,HandleResult = @HandleResult where id = " + m_DBid; SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@HandleTime", DateTime.Now), new SQLiteParameter("@HandlePeopleName", stPeople), new SQLiteParameter("@HandleResult", stResult) }; int DBResult = db.ExecuteNonQuery(sql2, parameters); if (DBResult > 0) { MessageBox.Show("报警处理完成!"); } string ServerWarningID = ""; string stdatetime = ""; string stHandleTime = ""; string stHandleResult = ""; string sql = "select * from AlarmLog where id = " + m_DBid;; using (SQLiteDataReader reader = db.ExecuteReader(sql, null)) { while (reader.Read()) { string stID = reader["id"].ToString(); stdatetime = reader["datetime"].ToString(); string stAlarmID = reader["AlarmID"].ToString(); string stAlarmName = reader["AlarmName"].ToString(); string stAlarmLevel = reader["AlarmLevel"].ToString(); string stHandleAlarmMode = reader["HandleAlarmMode"].ToString(); ServerWarningID = reader["ServerWarningID"].ToString(); stHandleTime = reader["HandleTime"].ToString(); string stHandlePeopleName = reader["HandlePeopleName"].ToString(); stHandleResult = reader["HandleResult"].ToString(); } } DateTime Handletime = Convert.ToDateTime(stHandleTime); DateTime datetime = Convert.ToDateTime(stdatetime); TimeSpan Span = Handletime - datetime; int nDuration = Span.Seconds; DTSManager.PostSever.PostWarningFixedData(ServerWarningID, stHandleTime, stHandleResult, nDuration); this.Close(); }
public void DeleteByID(int id) { string sql = "delete from CodeMass where ID="+id.ToString(); SQLiteDBHelper db = new SQLiteDBHelper(path); db.ExecuteNonQuery(sql, null); return; }
/// <summary> /// 加入或者移出养肥区 /// </summary> /// <param name="id">书籍ID</param> /// <param name="state">true为加入养肥区</param> /// <returns></returns> public static bool Add_MoveOut(int id, bool state = false) { int fatten = state ? 1 : 0; string sql = "update Books set Fattening=" + fatten + " where Id=" + id; return((SQLiteDBHelper.ExecuteNonQuery(sql, null) <= 0) ? false : true); }
public void DeleteByID(int id) { string sql = "delete from CodeMass where ID=" + id.ToString(); SQLiteDBHelper db = new SQLiteDBHelper(path); db.ExecuteNonQuery(sql, null); return; }
/// <summary> /// 增加书源 /// </summary> /// <param name="bookSource">书源内容</param> /// <returns>返回结果</returns> public static bool SourceAdd(BookSource bookSource) { string sql = "INSERT INTO BookSource('Title','Url','SearchUrl','AddressRangeRegular','AddressCuttingRegular','AddressRegular','BookNameRegular','AuthorRegular','UpdateRegular','NewestRegular','DetailsRegular','StateRegular','DirectoryScopeRegular','DirectoryCuttingRegular','DirectoryTieleRegular','DirectoryUrlRegular','ContentTitleRegular','ContentRegular','ImageRegular','State') VALUES('" + bookSource.Title + "', '" + bookSource.Url + "', '" + bookSource.SearchUrl + "', '" + bookSource.AddressRangeRegular + "', '" + bookSource.AddressCuttingRegular + "', '" + bookSource.AddressRegular + "','" + bookSource.BookNameRegular + "', '" + bookSource.AuthorRegular + "', '" + bookSource.UpdateRegular + "', '" + bookSource.NewestRegular + "', '" + bookSource.DetailsRegular + "', '" + bookSource.StateRegular + "', '" + bookSource.DirectoryScopeRegular + "', '" + bookSource.DirectoryCuttingRegular + "', '" + bookSource.DirectoryTieleRegular + "', '" + bookSource.DirectoryUrlRegular + "', '" + bookSource.ContentTitleRegular + "', '" + bookSource.ContentRegular + "', '" + bookSource.ImageRegular + "'," + bookSource.State + ")"; TempData.UpdateBookSourceS(); return((SQLiteDBHelper.ExecuteNonQuery(sql, null) <= 0) ? false : true); }
public void getUserInfo(string message, int type) { string sql = "select * from worker where identityId = '" + message + "';"; DataTable table = SQLiteDBHelper.ExecuteDataTable(sql); if (table.Rows.Count == 0) { //不存在则远程获取 GetUserInfo(message, ConfigurationManager.AppSettings["prorealname"].ToString(), type); //Console.WriteLine("查无数据,可能正在远程获取,请确保项目名和身份证号录入正确!"); return; } DataRow row = table.Rows[0]; string userInfo = string.Format("{0} [{1}]\n{2}({3})", row["username"].ToString(), row["job"].ToString(), DateTime.Now.ToString("MM月dd日 HH:mm:ss"), (type == 1 ? "进场" : "出场")); string updateuser = string.Format("update worker set checkinState = {0},checkinTime = '{1}' where identityId = '{2}';", type, DateTime.Now.ToString("yyyy-MM-dd"), message); SQLiteDBHelper.ExecuteNonQuery(updateuser); string base64 = "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgG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NSm6bGi/RRRWYwr4f/AOCnPx+ufBfgiw+Cvhu9MOp+Lo2udWeN8PFpittEfHI85wwPqsUinhq+4K/EH9sf4iTfEz9pHxvrv2jzbSy1F9IscHKiC1/cgr7MyM/1c1tQjzSu+gmeL0UUV3khRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABX6Qf8Etfjtc6hZav8A/EF6XOnxtq+gmRuRCWAuIFz2DMsigc/PKegr8369S/Zd8ezfDT9oLwJ4tSfyoYdZgtbts8fZbg+RNn1xHIx+oFRVjzxaGj91KKKK80op6zqMej6RfatLjZZW0tw2fRFLH+Vfz13t5caheT393IZJ7mVppXPVnYkk/maKK68L1EyGiiiuokKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKfFLJBKk0LlJI2DKw6gjkGiigD+hTQNR/tjQdN1fj/TrSG546fOgb+tFFFeUyz//2Q=="; if ("" != row["identityPhoto"].ToString()) { base64 = row["identityPhoto"].ToString(); } if (this.lstBoxWorker.Items.Count > 3) { this.lstBoxWorker.Items.Clear(); //this.images.Clear(); } LoopUser u = new LoopUser(); Bitmap b = new Bitmap(new MemoryStream(Convert.FromBase64String(base64))); //this.images.Add(b); u.info = userInfo; u.photo = base64; this.lstBoxWorker.Items.Insert(0, u); if (type == 1) { this.inuser.BackgroundImage = b; this.nowinname.Text = row["username"].ToString(); this.nowindate.Text = DateTime.Now.ToString("MM月dd日"); this.nowingroup.Text = row["job"].ToString() + "组"; this.nowinjob.Text = row["job"].ToString(); this.nowintime.Text = DateTime.Now.ToString("HH:mm"); } else { this.outuser.BackgroundImage = b; this.nowoutname.Text = row["username"].ToString(); this.nowoutdate.Text = DateTime.Now.ToString("MM月dd日"); this.nowoutgroup.Text = row["job"].ToString() + "组"; this.nowoutjob.Text = row["job"].ToString(); this.nowouttime.Text = DateTime.Now.ToString("HH:mm"); } }
private void button2_Click(object sender, EventArgs e) { String sql = String.Format(@"Drop table if exists '{0}'; CREATE TABLE '{0}'( 'realname' CHAR(50), 'name' CHAR(50), 'type' SMALLINT, 'connectrealname' CHAR(50), 'connectname' CHAR(50), 'remark' TEXT);", t_Name); try { db.ExecuteNonQuery(sql, null); foreach (string k in pic.Keys) { sql = @"Insert into '{0}' values ('{1}','{2}',{3},'{4}','{5}','{6}')"; if (pic[k].类型 == 设备.部件) { sql = String.Format(sql, t_Name, pic[k].Name, pic[k].name, pic[k].类型, null, null, null); } else if (pic[k].类型 == 设备.接口头) { if (pic[k].连接设备 == null) { sql = String.Format(sql, t_Name, pic[k].Name, pic[k].name, pic[k].类型, null, null, null); } else { sql = String.Format(sql, t_Name, pic[k].Name, pic[k].name, pic[k].类型, pic[k].连接设备.Name, pic[k].连接设备.name, null); } } else if (pic[k].类型 == 设备.线缆) { sql = String.Format(sql, t_Name, pic[k].Name, pic[k].name, pic[k].类型, null, null, null); } db.ExecuteNonQuery(sql, null); } } catch { MessageBox.Show("数据库异常,保存失败"); } }
public static void InitConsumableRecord() { try { string EXEPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; string dbPath = EXEPath + "Demo.db3"; SQLiteDBHelper db = new SQLiteDBHelper(dbPath); XmlDocument XMLalarmInfo = new XmlDocument(); XMLalarmInfo.Load(EXEPath + "ConsumableInfoConfig.xml"); XmlElement el = XMLalarmInfo.DocumentElement; XmlNodeList ConsumableInfoNodes = el.GetElementsByTagName("ConsumableInfo"); foreach (XmlNode node in ConsumableInfoNodes) { XmlNodeList ConsumableNode = node.ChildNodes; string ConsumableID = ((XmlElement)ConsumableNode[0]).InnerText; string ConsumableName = ((XmlElement)ConsumableNode[1]).InnerText; string stLifetime = ((XmlElement)ConsumableNode[3]).InnerText; int nLifetime = Convert.ToInt32(stLifetime); nLifetime = nLifetime * 60; bool bIsInit = false; string sql1 = "select * from ConsumableLog where ConsumableID = " + ConsumableID; using (SQLiteDataReader reader = db.ExecuteReader(sql1, null)) { while (reader.Read()) { bIsInit = true; } } if (!bIsInit) { DateTime Now = DateTime.Now; string sql2 = "INSERT INTO ConsumableLog(datetime,ConsumableID,ConsumableName,Lifetime,WorkingTime,Changetime,ChangePeopleName)" + "values(@datetime,@ConsumableID,@ConsumableName,@Lifetime,@WorkingTime,@Changetime,@ChangePeopleName)"; SQLiteParameter[] parameters = new SQLiteParameter[] { new SQLiteParameter("@datetime", Now), new SQLiteParameter("@ConsumableID", ConsumableID), new SQLiteParameter("@ConsumableName", ConsumableName), new SQLiteParameter("@Lifetime", nLifetime), new SQLiteParameter("@WorkingTime", "0"), new SQLiteParameter("@Changetime", Now), new SQLiteParameter("@ChangePeopleName", "初始") }; db.ExecuteNonQuery(sql2, parameters); DTSManager.PostSever.PostConsumableReplaceData("初始", Convert.ToInt32(ConsumableID), 0, Now.ToString()); } } } catch (XmlException ex) { MessageBox.Show(ex.Message); } }
private void Db_Delte_Sync(string fullpath) { DataTable dt = db.ExecuteDataTable("select 编号 from db_File where 编号=(select 编号 from db_File where 路径='" + fullpath + "')", null); if (dt.Rows.Count == 1)//如果该任务只包含这一个文件,则要把对应任务也删除 { string code = dt.Rows[0][0].ToString(); db.ExecuteNonQuery("delete from XW_FileOrderinfo where 编号='" + code + "'", null); db.ExecuteNonQuery("delete from db_File where 路径 like '" + fullpath + "%'", null); if (TaskType == "刊盘") { db.ExecuteNonQuery("delete from db_State where 编号='" + code + "'", null); } } else if (dt.Rows.Count > 1) { db.ExecuteNonQuery("delete from db_File where 路径 like '" + fullpath + "%'", null); } }
private void submit_Click(object sender, EventArgs e) { if (moduleText.Text == "") { MessageBox.Show("模板内容必填!"); return; } if (moduleType.Text == "") { MessageBox.Show("模板类型必填!"); return; } string sql = ""; try { if (this.minfo == null) { string checkSql = "select * from led_module where module_type='" + moduleType.Text + "'"; DataTable table = SQLiteDBHelper.ExecuteDataTable(checkSql); if (table != null && table.Rows.Count > 0) { MessageBox.Show("此类型模板已存在,请前往列表页进行操作!"); return; } sql = "insert into led_module (module_type,module_text) values ('" + moduleType.Text + "','" + moduleText.Text.Trim() + "')"; } else { if (minfo.Module_type != moduleType.Text) { string checkSql = "select * from led_module where module_type='" + moduleType.Text + "'"; DataTable table = SQLiteDBHelper.ExecuteDataTable(checkSql); if (table != null && table.Rows.Count > 0) { MessageBox.Show("此类型模板已存在,请前往列表页进行操作!"); return; } else { sql = "update led_module set module_type ='" + moduleType.Text + "',module_text='" + moduleText.Text.Trim() + "' where id=" + this.minfo.Id; } } sql = "update led_module set module_type ='" + moduleType.Text + "',module_text='" + moduleText.Text.Trim() + "' where id=" + this.minfo.Id; } SQLiteDBHelper.ExecuteNonQuery(sql); MessageBox.Show("保存成功!"); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception) { MessageBox.Show("保存失败,请联系管理员!"); return; } }
//更新报警记录 public bool updateAlarmRecord(Model.AlarmInfo alarmInfo) { SQLiteParameter[] sqlParams = new SQLiteParameter[2]; sqlParams[0] = new SQLiteParameter(PARAM_ISUPLOAD, DbType.String, 20); sqlParams[1] = new SQLiteParameter(PARAM_LCNUM, DbType.String, 10); sqlParams[0].Value = "ture"; sqlParams[1].Value = "T401"; SQLiteDBHelper sdb = new SQLiteDBHelper(Program.g_dbPath); return(sdb.ExecuteNonQuery(UPDATE_ALARM, sqlParams) > 0); }
public static void CreateTable() { //如果不存在改数据库文件,则创建该数据库文件 if (!System.IO.File.Exists(dbPath)) { SQLiteDBHelper.CreateDB(dbPath); } SQLiteDBHelper db = new SQLiteDBHelper(dbPath); string sql = "CREATE TABLE Test3(id integer NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE," + "Name char(3),TypeName varchar(50),AddDate datetime,UpdateTime Date,Time time,Comments blob)"; db.ExecuteNonQuery(sql, null); }
public void Run() { if (!File.Exists("SpinRepository.db3")) { SQLiteDBHelper.CreateDB("SpinRepository.db3"); SQLiteDBHelper dbHelper = new SQLiteDBHelper("SpinRepository.db3"); long returnValue = dbHelper.ExecuteNonQuery(TableCreateSQL.CreateMachineTable, null); Trace.WriteLine(string.Format("Create Machine table result : {0}", returnValue), "GT"); returnValue = dbHelper.ExecuteNonQuery(TableCreateSQL.CreateProductTable, null); Trace.WriteLine(string.Format("Create Product table result : {0}", returnValue), "GT"); returnValue = dbHelper.ExecuteNonQuery(TableCreateSQL.CreatePlanHeaderTable, null); Trace.WriteLine(string.Format("Create PlanHeader table result : {0}", returnValue), "GT"); returnValue = dbHelper.ExecuteNonQuery(TableCreateSQL.CreatePlanLineTable, null); Trace.WriteLine(string.Format("Create PlanLine table result : {0}", returnValue), "GT"); //SQLiteParameter[] parameters = new SQLiteParameter[]{ // new SQLiteParameter("@NAME","M_1001"), // new SQLiteParameter("@ENABLED",1), // new SQLiteParameter("@CREATEDBY","admin"), // new SQLiteParameter("@UPDATEDBY","admin"), // new SQLiteParameter("@CREATEDDATETIME",DateTime.Now), // new SQLiteParameter("@UPDATEDDATETIME",DateTime.Now) //}; //returnValue = dbHelper.ExecuteNonQuery(TableActionSQL.InsertMachineTable, parameters); //Trace.WriteLine(string.Format("Insert data to Machine table result : {0}", returnValue), "ID"); //SQLiteDataReader dataReader = dbHelper.ExecuteReader("SELECT * from machine ", null); //while (dataReader.Read()) //{ // Trace.WriteLine(string.Format("ID:{0},NAME:{1}", dataReader.GetInt64(0), dataReader.GetString(1)), "SD"); //} } }
/// <summary> /// 执行查询SQL,返回受影响行数 /// </summary> /// <param name="sql">sql语句</param> /// <param name="parameters">参数</param> /// <returns></returns> public int IntQuery(string sql, SQLiteParameter[] parameters) { int result = 0; try { SQLiteDBHelper dbHelper = new SQLiteDBHelper(); result = dbHelper.ExecuteNonQuery(sql, parameters); } catch { } return result; }
/// <summary> /// 执行查询SQL,返回受影响行数 /// </summary> /// <param name="sql">sql语句</param> /// <param name="parameters">参数</param> /// <returns></returns> public int IntQuery(string sql, SQLiteParameter[] parameters) { int result = 0; try { SQLiteDBHelper dbHelper = new SQLiteDBHelper(); result = dbHelper.ExecuteNonQuery(sql, parameters); } catch (Exception exMsg) { //Log.Error("ExecuteNonQuery出错:" + exMsg.ToString()); } return result; }
/// <summary> /// 根据序号ID更新指定的数据 /// </summary> /// <param name="name">用户名</param> /// <param name="email">email地址</param> /// <param name="ID">序号</param> /// <returns>更新的行数</returns> public static int Update(string name, string email, int ID) { try { StringBuilder strSQL = new StringBuilder(); strSQL.AppendFormat("UPDATE user SET name = '{0}', email = '{1}' WHERE ID = {2}", name, email, ID); SQLiteDBHelper sqliteDB = new SQLiteDBHelper(); return Convert.ToInt32(sqliteDB.ExecuteNonQuery(strSQL.ToString())); } catch { return 0; } }
/// <summary> /// 根据序号ID删除数据 /// </summary> /// <param name="ID">序号</param> /// <returns>删除的行数</returns> public static int Delete(int ID) { try { StringBuilder strSQL = new StringBuilder(); strSQL.AppendFormat("DELETE FROM user WHERE ID = {0}", ID); SQLiteDBHelper sqliteDB = new SQLiteDBHelper(); return Convert.ToInt32(sqliteDB.ExecuteNonQuery(strSQL.ToString())); } catch { return 0; } }
public static void InsertData() { string sql = "INSERT INTO Test3(Name,TypeName,AddDate,UpdateTime,Time,Comments)" + "values(@Name,@TypeName,@AddDate,@UpdateTime,@Time,@Comments)"; SQLiteDBHelper db = new SQLiteDBHelper("D:\\Demo.db3"); for (char c = 'A'; c <= 'Z'; c++) { for (int i = 0; i < 100; i++) { SQLiteParameter[] parameters = new SQLiteParameter[]{ new SQLiteParameter("@Name",c+i.ToString()), new SQLiteParameter("@TypeName",c.ToString()), new SQLiteParameter("@AddDate",DateTime.Now), new SQLiteParameter("@UpdateTime",DateTime.Now.Date), new SQLiteParameter("@Time",DateTime.Now.ToShortTimeString()), new SQLiteParameter("@Comments","Just a Test"+i) }; db.ExecuteNonQuery(sql, parameters); } } }
public static void InsertData(Data data) { string sql = "INSERT INTO Demo(Name,Rank,Comments)values(@Name,@Rank,@Comments)"; SQLiteDBHelper db = new SQLiteDBHelper(dbPath); SQLiteParameter[] parameters = new SQLiteParameter[]{ new SQLiteParameter("@Name",SqliteEscape(data.Name)), new SQLiteParameter("@Rank",data.Rank), new SQLiteParameter("@Comments",SqliteEscape(data.Comments)) }; db.ExecuteNonQuery(sql, parameters); }
public void InsertData(string name, string language, string code, string comments) { string sql = "INSERT INTO CodeMass(CodeName,Language,Comments,AddTime,UpdateTime,Source_Code)values(@CodeName,@Language,@Comments,@AddTime,@UpdateTime,@Source_Code)"; SQLiteDBHelper db = new SQLiteDBHelper(path); SQLiteParameter[] parameters = new SQLiteParameter[]{ new SQLiteParameter("@CodeName",name), new SQLiteParameter("@Language",language), new SQLiteParameter("@Comments",comments), new SQLiteParameter("@AddTime",DateTime.Now), new SQLiteParameter("@UpdateTime",DateTime.Now.Date), new SQLiteParameter("@Source_Code",code) }; db.ExecuteNonQuery(sql, parameters); }
public void UpdateData(int id,string name, string code, string comments) { //string sql = String.Format("update CodeMass set CodeName='{0}',Comments='{1}',UpdateTime={2},Source_Code='{3}' where ID={4} ", name, comments, DateTime.Now.Date, code, id); string sql = "UPDATE CodeMass Set CodeName=@CodeName,Comments=@Comments,UpdateTime=@UpdateTime,Source_Code=@Source_Code where ID=" + id.ToString(); SQLiteDBHelper db = new SQLiteDBHelper(path); SQLiteParameter[] parameters = new SQLiteParameter[]{ new SQLiteParameter("@CodeName",name), new SQLiteParameter("@Comments",comments), new SQLiteParameter("@UpdateTime",DateTime.Now.Date), new SQLiteParameter("@Source_Code",code) }; db.ExecuteNonQuery(sql, parameters); }
void GetDataBase() { path = GetCurrentPath(); if (File.Exists(path)) { db = new SQLiteDBHelper(path); } else { SQLiteDBHelper.CreateDB(path); db = new SQLiteDBHelper(path); string sql = "CREATE TABLE CodeMass(ID integer NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE," + "CodeName char(40)," + "Language char(3)," + "Comments varchar(100),"+ "AddTime datetime,UpdateTime Date," + "Source_Code Text)"; db.ExecuteNonQuery(sql, null); } }