public string ChangeFormulaYear(string tableName,IList<FormulaYear> deleteItems, IList<FormulaYear> updateItems, IList<FormulaYear> insertItems) { try { foreach (var item in deleteItems) { Delete delete = new Delete(tableName); delete.AddCriterions("KeyID","myKeyID", item.KeyID, CriteriaOperator.Equal); delete.AddCriterions("ID","myID", item.ID, CriteriaOperator.Equal); delete.AddSqlOperator(SqlOperator.AND); dataFactory.Remove(delete); } foreach (var item in updateItems) { Update<FormulaYear> update = new Update<FormulaYear>(tableName, item); update.AddCriterion("KeyID", "myKeyID",item.KeyID, CriteriaOperator.Equal); update.AddCriterion("ID", "myID",item.ID, CriteriaOperator.Equal); update.AddSqlOperator(SqlOperator.AND); update.AddExcludeField("Id"); dataFactory.Save<FormulaYear>(update); } foreach (var item in insertItems) { Insert<FormulaYear> insert = new Insert<FormulaYear>(tableName, item); insert.AddExcludeField("Id"); dataFactory.Save<FormulaYear>(insert); } } catch { return "0"; } return "1"; }
public void SavePVFValues(IList<PVFItem> inserted, IList<PVFItem> updated, IList<PVFItem> deleted) { using (TransactionScope scope = new TransactionScope()) { foreach (var item in inserted) { Insert<PVFItem> insert = new Insert<PVFItem>("PeakValleyFlat", item); insert.AddExcludeField("ID"); dataFactory.Save<PVFItem>(insert); } foreach (var item1 in updated) { Update<PVFItem> update = new Update<PVFItem>("PeakValleyFlat", item1); update.AddCriterion("ID", "ID", item1.ID, SqlServerDataAdapter.Infrastruction.CriteriaOperator.Equal); update.AddExcludeField("ID"); dataFactory.Save<PVFItem>(update); } foreach (var item2 in deleted) { Delete delete = new Delete("PeakValleyFlat"); delete.AddCriterions("ID", "ID",item2.ID, SqlServerDataAdapter.Infrastruction.CriteriaOperator.Equal); dataFactory.Remove(delete); } scope.Complete(); } }
public void Remove(ProductLine entity) { Delete delete = new Delete("ProductLine"); delete.AddCriterions("ID", entity.Id, CriteriaOperator.Equal); dataFactory.Remove(delete); }
/// <summary> /// 保存公式 /// </summary> /// <param name="groupId"></param> /// <param name="data"></param> public static void SaveFormulas(Guid groupId, DataTable data) { string connectionString = ConnectionStringFactory.GetNXJCConnectionString(); // 删除现存公式 ISqlServerDataFactory factory = new SqlServerDataFactory(connectionString); Delete delete = new Delete("Formula"); delete.AddCriterions("GroupID", groupId, SqlServerDataAdapter.Infrastruction.CriteriaOperator.Equal); factory.Remove(delete); // 插入所有公式 using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = connection.CreateCommand(); connection.Open(); foreach (DataRow row in data.Rows) { command.CommandText = "INSERT INTO Formula (GroupID, LevelCode, Name, Formula) VALUES ('" + groupId.ToString() + "', '" + row["LevelCode"].ToString() + "','" + row["Name"].ToString() + "','" + row["Formula"].ToString() + "')"; command.ExecuteNonQuery(); } } }
public void Remove(Report entity) { Delete delete = new Delete("Report"); delete.AddCriterions("ID", entity.Id, CriteriaOperator.Equal); dataFactory.Remove(delete); }
public void Remove(TZ entity) { Delete delete = new Delete("TZ"); delete.AddCriterions("KeyID", entity.Id, CriteriaOperator.Equal); dataFactory.Remove(delete); }