/// <summary> /// 更新一条数据 /// </summary> public bool Update(MDL.StockInfoMDL model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update stockinfo set "); strSql.Append("BarCode=@BarCode,"); strSql.Append("MaterialCode=@MaterialCode,"); strSql.Append("MaterialName=@MaterialName,"); strSql.Append("ScannerID=@ScannerID"); strSql.Append(" where TID=@TID"); SQLiteParameter[] parameters = { new SQLiteParameter("@BarCode", model.BarCode), new SQLiteParameter("@MaterialCode", model.MaterialCode), new SQLiteParameter("@MaterialName", model.MaterialName), new SQLiteParameter("@ScannerID", model.ScannerID), new SQLiteParameter("@TID", model.TID) }; int rows = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(MDL.StockInfoMDL model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into stockinfo("); strSql.Append("BarCode,MaterialCode,MaterialName,ScannerID)"); strSql.Append(" values ("); strSql.Append("@BarCode,@MaterialCode,@MaterialName,@ScannerID)"); strSql.Append(";select LAST_INSERT_ROWID()"); SQLiteParameter[] parameters = { new SQLiteParameter("@BarCode", model.BarCode), new SQLiteParameter("@MaterialCode", model.MaterialCode), new SQLiteParameter("@MaterialName", model.MaterialName), new SQLiteParameter("@ScannerID", model.ScannerID) }; object obj = SQLiteHelper.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MDL.StockInfoMDL DataRowToModel(DataRow row) { MDL.StockInfoMDL model = new MDL.StockInfoMDL(); if (row != null) { if (row["TID"] != null && row["TID"].ToString() != "") { model.TID = int.Parse(row["TID"].ToString()); } if (row["BarCode"] != null) { model.BarCode = row["BarCode"].ToString(); } if (row["MaterialCode"] != null) { model.MaterialCode = row["MaterialCode"].ToString(); } if (row["MaterialName"] != null) { model.MaterialName = row["MaterialName"].ToString(); } if (row["ScannerID"] != null) { model.ScannerID = row["ScannerID"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public MDL.StockInfoMDL GetModel(string where) { StringBuilder strSql = new StringBuilder(); strSql.Append("select TID,BarCode,MaterialCode,MaterialName,ScannerID from stockinfo "); if (!string.IsNullOrEmpty(where)) { strSql.Append(" where " + where); } MDL.StockInfoMDL model = new MDL.StockInfoMDL(); DataSet ds = SQLiteHelper.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MDL.StockInfoMDL GetModel(int TID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select TID,BarCode,MaterialCode,MaterialName,ScannerID from stockinfo "); strSql.Append(" where TID=@TID"); SQLiteParameter[] parameters = { new SQLiteParameter("@TID", TID) }; MDL.StockInfoMDL model = new MDL.StockInfoMDL(); DataSet ds = SQLiteHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }