public static bool Update(ProductTypeViewModel model) { if (model == null) { return(false); } string sql = "update ProductTypes set ProductName=@ProductName,UpdateTime=@UpdateTime where Id=@Id "; List <SQLiteParameter> ps = new List <SQLiteParameter>(); ps.Add(new SQLiteParameter() { ParameterName = EProductTypes.Id.ToString(), Value = model.Id }); ps.Add(new SQLiteParameter() { ParameterName = EProductTypes.ProductName.ToString(), Value = model.ProductName }); ps.Add(new SQLiteParameter() { ParameterName = EProductTypes.UpdateTime.ToString(), Value = model.UpdateTime }); int count = ManagerSqlite.ExecuteNonQuery(sql, ps.ToArray()); if (count > 0) { return(true); } else { return(false); } }
public static bool Insert(ProductViewModel model) { if (model == null) { return(false); } string sql = string.Empty;; List <SQLiteParameter> ps = new List <SQLiteParameter>(); sql = "INSERT INTO Products (" + EProducts.Name.ToString() + "," + EProducts.Price.ToString() + "," + EProducts.ProductType_Id.ToString() + "," + EProducts.AddedTime.ToString() + "," + EProducts.UpdateTime.ToString() + ") VALUES (" + "@" + EProducts.Name.ToString() + "," + "@" + EProducts.Price.ToString() + "," + "@" + EProducts.ProductType_Id.ToString() + "," + "@" + EProducts.AddedTime.ToString() + "," + "@" + EProducts.UpdateTime.ToString() + ");"; ps.Add(new SQLiteParameter() { ParameterName = EProducts.Name.ToString(), Value = model.Name }); ps.Add(new SQLiteParameter() { ParameterName = EProducts.Price.ToString(), Value = model.Price }); ps.Add(new SQLiteParameter() { ParameterName = EProducts.ProductType_Id.ToString(), Value = model.ProductType_Id }); ps.Add(new SQLiteParameter() { ParameterName = EProducts.AddedTime.ToString(), Value = model.AddedTime }); ps.Add(new SQLiteParameter() { ParameterName = EProducts.UpdateTime.ToString(), Value = model.UpdateTime }); int count = ManagerSqlite.ExecuteNonQuery(sql, ps.ToArray()); if (count > 0) { return(true); } else { return(false); } }
public static bool Delete(List <int> ids) { List <string> sqls = new List <string>(); foreach (var item in ids) { sqls.Add("delete from Products where Id = " + item); } return(ManagerSqlite.ExecuteNonQuery(sqls, null)); }
public static bool Insert(UsersViewModel model) { if (model == null) { return(false); } string sql = string.Empty;; List <SQLiteParameter> ps = new List <SQLiteParameter>(); sql = "INSERT INTO Users (" + EUsers.userName.ToString() + "," + EUsers.password.ToString() + "," + EUsers.isRemmber.ToString() + "," + EUsers.UpdateTime.ToString() + ") VALUES (" + "@" + EUsers.userName.ToString() + "," + "@" + EUsers.password.ToString() + "," + "@" + EUsers.isRemmber.ToString() + "," + "@" + EUsers.UpdateTime.ToString() + ");"; ps.Add(new SQLiteParameter() { ParameterName = EUsers.userName.ToString(), Value = model.userName }); ps.Add(new SQLiteParameter() { ParameterName = EUsers.password.ToString(), Value = model.password }); ps.Add(new SQLiteParameter() { ParameterName = EUsers.isRemmber.ToString(), Value = model.isRemmber }); ps.Add(new SQLiteParameter() { ParameterName = EUsers.UpdateTime.ToString(), Value = model.UpdateTime }); int count = ManagerSqlite.ExecuteNonQuery(sql, ps.ToArray()); if (count > 0) { return(true); } else { return(false); } }
public static bool Delete(int id) { string sql = "delete from ProductTypes where Id = " + id; int count = ManagerSqlite.ExecuteNonQuery(sql, null); if (count > 0) { return(true); } else { return(false); } }
public static bool Delete(List <int> ids) { if (ids == null || ids.Count == 0) { return(false); } List <string> sqls = new List <string>(); foreach (var item in ids) { sqls.Add("delete from ProductTypes where Id = " + item); } return(ManagerSqlite.ExecuteNonQuery(sqls, null)); }
public static bool UpdateBySql(List <KaMiViewModel> models) { if (models == null || models.Count == 0) { return(false); } List <string> sqls = new List <string>(); foreach (var item in models) { sqls.Add("update Kamis set State=" + (int)KamiState.Used + ",Remark='" + item.Remark + "',Trade_No='" + item.Trade_No + "' where Id = " + item.Id); } return(ManagerSqlite.ExecuteNonQuery(sqls, null)); }
public static bool Update(string sql) { if (string.IsNullOrEmpty(sql)) { return(false); } int count = ManagerSqlite.ExecuteNonQuery(sql, null); if (count > 0) { return(true); } else { return(false); } }
public static bool Insert(OrderViewModel model) { if (model == null) { return(false); } string sql = string.Empty;; List <SQLiteParameter> ps = new List <SQLiteParameter>(); sql = "INSERT INTO Orders (" + EOrders.NO.ToString() + "," + EOrders.Product_Id.ToString() + "," + EOrders.Type.ToString() + "," + EOrders.Status.ToString() + "," + EOrders.Price.ToString() + "," + EOrders.Count.ToString() + "," + EOrders.LocalStatus.ToString() + "," + EOrders.Remark.ToString() + "," + EOrders.UpdateTime.ToString() + ") VALUES (" + "@" + EOrders.NO.ToString() + "," + "@" + EOrders.Product_Id.ToString() + "," + "@" + EOrders.Type.ToString() + "," + "@" + EOrders.Status.ToString() + "," + "@" + EOrders.Price.ToString() + "," + "@" + EOrders.Count.ToString() + "," + "@" + EOrders.LocalStatus.ToString() + "," + "@" + EOrders.Remark.ToString() + "," + "@" + EOrders.UpdateTime.ToString() + ");"; ps.Add(new SQLiteParameter() { ParameterName = EOrders.Id.ToString(), Value = model.Id }); ps.Add(new SQLiteParameter() { ParameterName = EOrders.NO.ToString(), Value = model.NO }); ps.Add(new SQLiteParameter() { ParameterName = EOrders.Product_Id.ToString(), Value = model.Product_Id }); ps.Add(new SQLiteParameter() { ParameterName = EOrders.Type.ToString(), Value = model.Type }); ps.Add(new SQLiteParameter() { ParameterName = EOrders.Status.ToString(), Value = model.Status }); ps.Add(new SQLiteParameter() { ParameterName = EOrders.Price.ToString(), Value = model.Price }); ps.Add(new SQLiteParameter() { ParameterName = EOrders.Count.ToString(), Value = model.Count }); ps.Add(new SQLiteParameter() { ParameterName = EOrders.LocalStatus.ToString(), Value = model.LocalStatus }); ps.Add(new SQLiteParameter() { ParameterName = EOrders.Remark.ToString(), Value = model.Remark }); ps.Add(new SQLiteParameter() { ParameterName = EOrders.UpdateTime.ToString(), Value = model.UpdateTime }); int count = ManagerSqlite.ExecuteNonQuery(sql, ps.ToArray()); if (count > 0) { return(true); } else { return(false); } }
public static bool Update(KaMiViewModel model) { if (model == null) { return(false); } StringBuilder sb = new StringBuilder(2048); List <SQLiteParameter> ps = new List <SQLiteParameter>(); sb.Append("UPDATE Kamis SET "); sb.Append(EKamis.Content.ToString() + "=@" + EKamis.Content.ToString() + ","); ps.Add(new SQLiteParameter() { ParameterName = EKamis.Content.ToString(), Value = model.Content }); sb.Append(EKamis.State.ToString() + "=@" + EKamis.State.ToString() + ","); ps.Add(new SQLiteParameter() { ParameterName = EKamis.State.ToString(), Value = model.State }); sb.Append(EKamis.Product_Id.ToString() + "=@" + EKamis.Product_Id.ToString() + ","); ps.Add(new SQLiteParameter() { ParameterName = EKamis.Product_Id.ToString(), Value = model.Product_Id }); sb.Append(EKamis.ProductType_Id.ToString() + "=@" + EKamis.ProductType_Id.ToString() + ","); ps.Add(new SQLiteParameter() { ParameterName = EKamis.ProductType_Id.ToString(), Value = model.ProductType_Id }); sb.Append(EKamis.Trade_No.ToString() + "=@" + EKamis.Trade_No.ToString() + ","); ps.Add(new SQLiteParameter() { ParameterName = EKamis.Trade_No.ToString(), Value = model.Trade_No }); sb.Append(EKamis.Remark.ToString() + "=@" + EKamis.Remark.ToString() + ","); ps.Add(new SQLiteParameter() { ParameterName = EKamis.Remark.ToString(), Value = model.Remark }); sb.Append(EKamis.UpdateTime.ToString() + "=@" + EKamis.UpdateTime.ToString()); ps.Add(new SQLiteParameter() { ParameterName = EKamis.UpdateTime.ToString(), Value = model.UpdateTime }); sb.Append(" where "); sb.Append(EKamis.Id.ToString() + "=@" + EKamis.Id.ToString()); ps.Add(new SQLiteParameter() { ParameterName = EKamis.Id.ToString(), Value = model.Id }); string sql = sb.ToString(); int count = ManagerSqlite.ExecuteNonQuery(sql, ps.ToArray()); if (count > 0) { return(true); } else { return(false); } }
public static bool Insert(KaMiViewModel model) { if (model == null) { return(false); } string sql = string.Empty; List <SQLiteParameter> ps = new List <SQLiteParameter>(); sql = "INSERT INTO Kamis (" + EKamis.Content.ToString() + "," + EKamis.State.ToString() + "," + EKamis.Product_Id.ToString() + "," + EKamis.ProductType_Id.ToString() + "," + EKamis.Trade_No.ToString() + "," + EKamis.Remark.ToString() + "," + EKamis.AddedTime.ToString() + "," + EKamis.UpdateTime.ToString() + ") VALUES (" + "@" + EKamis.Content.ToString() + "," + "@" + EKamis.State.ToString() + "," + "@" + EKamis.Product_Id.ToString() + "," + "@" + EKamis.ProductType_Id.ToString() + "," + "@" + EKamis.Trade_No.ToString() + "," + "@" + EKamis.Remark.ToString() + "," + "@" + EKamis.AddedTime.ToString() + "," + "@" + EKamis.UpdateTime.ToString() + ");"; ps.Add(new SQLiteParameter() { ParameterName = EKamis.Id.ToString(), Value = model.Id }); ps.Add(new SQLiteParameter() { ParameterName = EKamis.Content.ToString(), Value = model.Content }); ps.Add(new SQLiteParameter() { ParameterName = EKamis.State.ToString(), Value = model.State }); ps.Add(new SQLiteParameter() { ParameterName = EKamis.Product_Id.ToString(), Value = model.Product_Id }); ps.Add(new SQLiteParameter() { ParameterName = EKamis.ProductType_Id.ToString(), Value = model.ProductType_Id }); ps.Add(new SQLiteParameter() { ParameterName = EKamis.Trade_No.ToString(), Value = model.Trade_No }); ps.Add(new SQLiteParameter() { ParameterName = EKamis.Remark.ToString(), Value = model.Remark }); ps.Add(new SQLiteParameter() { ParameterName = EKamis.AddedTime.ToString(), Value = model.AddedTime }); ps.Add(new SQLiteParameter() { ParameterName = EKamis.UpdateTime.ToString(), Value = model.UpdateTime }); int count = ManagerSqlite.ExecuteNonQuery(sql, ps.ToArray()); if (count > 0) { return(true); } else { return(false); } }