private void InitDtGridView() { SQLiteDBHelper sqliteHelper = new SQLiteDBHelper(); try { string sqlSelectTickets = @"SELECT CreateTime,StepNo,Operation,Comment,ImagePathCircuit,ImagePathCapacity FROM OperationSteps"; dtGridView = sqliteHelper.ExecuteDataTable(sqlSelectTickets, null); dtGridView.Clear(); } catch (Exception ex) { } }
private void btnComplete_Click(object sender, EventArgs e) { SQLiteDBHelper sqliteHelper = new SQLiteDBHelper(); string sqlInsertTickets = string.Format(@"INSERT INTO Tickets (No,Name,Task,OperationDate,User,StartTime,EndTime,CreateTime,CreateComment) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", this.txtNo.Text, this.txtTicketName.Text, this.txtTaskName.Text, this.txtOperationDate.Text, this.txtOperationUser.Text, this.txtStarttime.Text, this.txtEndtime.Text, this.txtCreateTime.Text, createTicket.CreateComment); string sqlInsertOperationSteps = string.Format("INSERT INTO OperationSteps (CreateTime,StepNo,Operation,Comment,ImagePathCircuit,ImagePathCapacity) VALUES (@CreateTime,@StepNo,@Operation,@Comment,@ImagePathCircuit,@ImagePathCapacity)"); try { sqliteHelper.ExecuteNonQuery(sqlInsertTickets); SQLiteParameter[] parameters = { new SQLiteParameter("@CreateTime"), new SQLiteParameter("@StepNo"), new SQLiteParameter("@Operation"), new SQLiteParameter("@Comment"), new SQLiteParameter("@ImagePathCircuit"), new SQLiteParameter("@ImagePathCapacity"), }; foreach (DataRow row in dtGridView.Rows) { parameters[0].Value = row["CreateTime"]; parameters[1].Value = row["StepNo"]; parameters[2].Value = row["Operation"]; parameters[3].Value = row["Comment"]; parameters[4].Value = row["ImagePathCircuit"]; parameters[5].Value = row["ImagePathCapacity"]; sqliteHelper.ExecuteNonQuery(sqlInsertOperationSteps, parameters); } PublicStaticMember.OperationTicketsMain.RefreshUI(); this.Close(); PublicStaticMember.OperationTicketsMain.Show(); createTicket.Close(); } catch (Exception ex) { XtraMessageBox.Show("新增操作票失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }