SQLite
Posted AI爱可明
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQLite相关的知识,希望对你有一定的参考价值。
delete from TableName 清空数据,不删除表
参数化语句 ???
public bool AddNoTask(PDAScanOperationRecords model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into PDAScanOperationRecords(");
strSql.Append("ID,Flag,TaskID,MatID,MatCode,MatDesc,LocationCode,Location,Batch,BatchAmt,UomID,UomCode,Uom,PackUnitID,PackUnitCode,PackUnit,TransferPersonCode,TransferPerson,EquCode,EquDesc,EquLeaderCode,EquLeader,BilledUserCode,BiiledBy,ReturnPersonCode,ReturnPerson,InOutType,UserID ,UserCode,UserName,BussinessTypeId,BussinessType,WarehouseId,WarehouseCode ,WarehouseDesc,TeamCode,TeamDesc,CreatedOn)");
strSql.Append(" values (");
strSql.Append("‘" + Guid.NewGuid().ToString() + "‘,2,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,‘" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "‘)");Code,@BiiledBy,@ReturnPersonCode,@ReturnPerson,@InOutType,@UserID,@UserCode,@UserName,@BussinessTypeId ,@BussinessType,@WarehouseId,@WarehouseCode,@WarehouseDesc,@TeamCode,@TeamDesc,‘" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "‘)");
SqlParameter[] parameters = {
new SqlParameter("@TaskID", SqlDbType.Int,4),
new SqlParameter("@MatID", SqlDbType.Int,4),
new SqlParameter("@MatCode", SqlDbType.VarChar,200),
new SqlParameter("@MatDesc", SqlDbType.VarChar,200),
new SqlParameter("@LocationCode ",SqlDbType.VarChar,200),
new SqlParameter("@Location", SqlDbType.VarChar,50),
new SqlParameter("@Batch", SqlDbType.VarChar,200),
new SqlParameter("@BatchAmt", SqlDbType.VarChar,200),
new SqlParameter("@UomID", SqlDbType.Int,4),
new SqlParameter("@UomCode", SqlDbType.VarChar,200),
new SqlParameter("@Uom", SqlDbType.VarChar,200),
new SqlParameter("@PackUnitID",SqlDbType.Int,4),
new SqlParameter("@PackUnitCode", SqlDbType.VarChar,200),
new SqlParameter("@PackUnit", SqlDbType.VarChar,200),
new SqlParameter("@TransferPersonCode", SqlDbType.VarChar,200),
new SqlParameter("@TransferPerson", SqlDbType.VarChar,200),
new SqlParameter("@EquCode ",SqlDbType.VarChar,200),
new SqlParameter("@EquDesc", SqlDbType.VarChar,200),
new SqlParameter("@EquLeaderCode ", SqlDbType.VarChar,200),
new SqlParameter("@EquLeader", SqlDbType.VarChar,200),
new SqlParameter("@BilledUserCode", SqlDbType.VarChar,200),
new SqlParameter("@BiiledBy", SqlDbType.Int,4),
new SqlParameter("@ReturnPersonCode", SqlDbType.VarChar,200),
new SqlParameter("@ReturnPerson",SqlDbType.VarChar,200),
new SqlParameter("@InOutType", SqlDbType.Int,4),
new SqlParameter("@UserID", SqlDbType.Int,4),
new SqlParameter("@UserCode", SqlDbType.VarChar,200),
new SqlParameter("@UserName", SqlDbType.VarChar,200),
new SqlParameter("@BussinessTypeId ",SqlDbType.Int,4),
new SqlParameter("@BussinessType", SqlDbType.VarChar,200),
new SqlParameter("@WarehouseId ", SqlDbType.Int,4),
new SqlParameter("@WarehouseCode", SqlDbType.VarChar,200),
new SqlParameter("@WarehouseDesc", SqlDbType.VarChar,100),
new SqlParameter("@TeamCode", SqlDbType.VarChar,200),
new SqlParameter("@TeamDesc", SqlDbType.VarChar,200)};
parameters[0].Value = model.TaskID;
parameters[1].Value = model.MatID;
parameters[2].Value = model.MatCode;
parameters[3].Value = model.MatDesc;
parameters[4].Value = model.LocationCode;
parameters[5].Value = model.Location;
parameters[6].Value = model.Batch;
parameters[7].Value = model.BatchAmt;
parameters[8].Value = model.UomID;
parameters[9].Value = model.UomCode;
parameters[10].Value = model.Uom;
parameters[11].Value = model.PackUnitID;
parameters[12].Value = model.PackUnitCode;
parameters[13].Value = model.PackUnit;
parameters[14].Value = model.TransferPersonCode;
parameters[15].Value = model.TransferPerson;
parameters[16].Value = model.EquCode;
parameters[17].Value = model.EquDesc;
parameters[18].Value = model.EquLeaderCode;
parameters[19].Value = model.EquLeader;
parameters[20].Value = model.BilledUserCode;
parameters[21].Value = model.BiiledBy;
parameters[22].Value = model.ReturnPersonCode;
parameters[23].Value = model.ReturnPerson;
parameters[24].Value = model.InOutType;
parameters[25].Value = model.UserID;
parameters[26].Value = model.UserCode;
parameters[27].Value = model.UserName;
parameters[28].Value = model.BussinessTypeId;
parameters[29].Value = model.BussinessType;
parameters[30].Value = model.WarehouseId;
parameters[31].Value = model.WarehouseCode;
parameters[32].Value = model.WarehouseDesc;
parameters[33].Value = model.TeamCode;
parameters[34].Value = model.TeamDesc;
public bool AddNoTask(PDAScanOperationRecords model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into PDAScanOperationRecords(");
strSql.Append("ID,Flag,TaskID,MatID,MatCode,MatDesc,LocationCode,Location,Batch,BatchAmt,UomID,UomCode,Uom,PackUnitID,PackUnitCode,PackUnit,TransferPersonCode,TransferPerson,EquCode,EquDesc,EquLeaderCode,EquLeader,BilledUserCode,BiiledBy,ReturnPersonCode,ReturnPerson,InOutType,UserID ,UserCode,UserName,BussinessTypeId,BussinessType,WarehouseId,WarehouseCode ,WarehouseDesc,TeamCode,TeamDesc,CreatedOn)");
strSql.Append(" values (");
strSql.Append("‘" + Guid.NewGuid().ToString() + "‘,2,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,‘" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "‘)");Code,@BiiledBy,@ReturnPersonCode,@ReturnPerson,@InOutType,@UserID,@UserCode,@UserName,@BussinessTypeId ,@BussinessType,@WarehouseId,@WarehouseCode,@WarehouseDesc,@TeamCode,@TeamDesc,‘" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "‘)");
SqlParameter[] parameters = {
new SqlParameter("@TaskID", SqlDbType.Int,4),
new SqlParameter("@MatID", SqlDbType.Int,4),
new SqlParameter("@MatCode", SqlDbType.VarChar,200),
new SqlParameter("@MatDesc", SqlDbType.VarChar,200),
new SqlParameter("@LocationCode ",SqlDbType.VarChar,200),
new SqlParameter("@Location", SqlDbType.VarChar,50),
new SqlParameter("@Batch", SqlDbType.VarChar,200),
new SqlParameter("@BatchAmt", SqlDbType.VarChar,200),
new SqlParameter("@UomID", SqlDbType.Int,4),
new SqlParameter("@UomCode", SqlDbType.VarChar,200),
new SqlParameter("@Uom", SqlDbType.VarChar,200),
new SqlParameter("@PackUnitID",SqlDbType.Int,4),
new SqlParameter("@PackUnitCode", SqlDbType.VarChar,200),
new SqlParameter("@PackUnit", SqlDbType.VarChar,200),
new SqlParameter("@TransferPersonCode", SqlDbType.VarChar,200),
new SqlParameter("@TransferPerson", SqlDbType.VarChar,200),
new SqlParameter("@EquCode ",SqlDbType.VarChar,200),
new SqlParameter("@EquDesc", SqlDbType.VarChar,200),
new SqlParameter("@EquLeaderCode ", SqlDbType.VarChar,200),
new SqlParameter("@EquLeader", SqlDbType.VarChar,200),
new SqlParameter("@BilledUserCode", SqlDbType.VarChar,200),
new SqlParameter("@BiiledBy", SqlDbType.Int,4),
new SqlParameter("@ReturnPersonCode", SqlDbType.VarChar,200),
new SqlParameter("@ReturnPerson",SqlDbType.VarChar,200),
new SqlParameter("@InOutType", SqlDbType.Int,4),
new SqlParameter("@UserID", SqlDbType.Int,4),
new SqlParameter("@UserCode", SqlDbType.VarChar,200),
new SqlParameter("@UserName", SqlDbType.VarChar,200),
new SqlParameter("@BussinessTypeId ",SqlDbType.Int,4),
new SqlParameter("@BussinessType", SqlDbType.VarChar,200),
new SqlParameter("@WarehouseId ", SqlDbType.Int,4),
new SqlParameter("@WarehouseCode", SqlDbType.VarChar,200),
new SqlParameter("@WarehouseDesc", SqlDbType.VarChar,100),
new SqlParameter("@TeamCode", SqlDbType.VarChar,200),
new SqlParameter("@TeamDesc", SqlDbType.VarChar,200)};
parameters[0].Value = model.TaskID;
parameters[1].Value = model.MatID;
parameters[2].Value = model.MatCode;
parameters[3].Value = model.MatDesc;
parameters[4].Value = model.LocationCode;
parameters[5].Value = model.Location;
parameters[6].Value = model.Batch;
parameters[7].Value = model.BatchAmt;
parameters[8].Value = model.UomID;
parameters[9].Value = model.UomCode;
parameters[10].Value = model.Uom;
parameters[11].Value = model.PackUnitID;
parameters[12].Value = model.PackUnitCode;
parameters[13].Value = model.PackUnit;
parameters[14].Value = model.TransferPersonCode;
parameters[15].Value = model.TransferPerson;
parameters[16].Value = model.EquCode;
parameters[17].Value = model.EquDesc;
parameters[18].Value = model.EquLeaderCode;
parameters[19].Value = model.EquLeader;
parameters[20].Value = model.BilledUserCode;
parameters[21].Value = model.BiiledBy;
parameters[22].Value = model.ReturnPersonCode;
parameters[23].Value = model.ReturnPerson;
parameters[24].Value = model.InOutType;
parameters[25].Value = model.UserID;
parameters[26].Value = model.UserCode;
parameters[27].Value = model.UserName;
parameters[28].Value = model.BussinessTypeId;
parameters[29].Value = model.BussinessType;
parameters[30].Value = model.WarehouseId;
parameters[31].Value = model.WarehouseCode;
parameters[32].Value = model.WarehouseDesc;
parameters[33].Value = model.TeamCode;
parameters[34].Value = model.TeamDesc;
int intHistory = DataAccess.SqliteHelper.ExecuteNonQuery(strSql.ToString(), parameters);
string strDelete = "delete from PDAScanOperationRecordsHistory where RowNumber < (select Max(RowNumber) from PDAScanOperationRecordsHistory) - 1000 ";
int intDelete = DataAccess.SqliteHelper.ExecuteNonQuery(strDelete, null);
if (intHistory > 0)
{
return true;
}
else
{
return false;
}
}
string strDelete = "delete from PDAScanOperationRecordsHistory where RowNumber < (select Max(RowNumber) from PDAScanOperationRecordsHistory) - 1000 ";
int intDelete = DataAccess.SqliteHelper.ExecuteNonQuery(strDelete, null);
if (intHistory > 0)
{
return true;
}
else
{
return false;
}
}