Пример #1
0
        public static void SaveTerritoryMap(int varEmployeeID, string[] itemList)
        {
            QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
            //delete out the existing
            QueryCommand cmdDel = new QueryCommand("DELETE FROM [EmployeeTerritories] WHERE [EmployeeTerritories].[EmployeeID] = @EmployeeID", Employee.Schema.Provider.Name);

            cmdDel.AddParameter("@EmployeeID", varEmployeeID, DbType.Int32);
            coll.Add(cmdDel);
            DataService.ExecuteTransaction(coll);
            foreach (string item in itemList)
            {
                EmployeeTerritory varEmployeeTerritory = new EmployeeTerritory();
                varEmployeeTerritory.SetColumnValue("EmployeeID", varEmployeeID);
                varEmployeeTerritory.SetColumnValue("TerritoryID", item);
                varEmployeeTerritory.Save();
            }
        }
Пример #2
0
        public static void SaveEmployeeMap(string varTerritoryID, EmployeeCollection items)
        {
            QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
            //delete out the existing
            QueryCommand cmdDel = new QueryCommand("DELETE FROM [EmployeeTerritories] WHERE [EmployeeTerritories].[TerritoryID] = @TerritoryID", Territory.Schema.Provider.Name);

            cmdDel.AddParameter("@TerritoryID", varTerritoryID, DbType.String);
            coll.Add(cmdDel);
            DataService.ExecuteTransaction(coll);
            foreach (Employee item in items)
            {
                EmployeeTerritory varEmployeeTerritory = new EmployeeTerritory();
                varEmployeeTerritory.SetColumnValue("TerritoryID", varTerritoryID);
                varEmployeeTerritory.SetColumnValue("EmployeeID", item.GetPrimaryKeyValue());
                varEmployeeTerritory.Save();
            }
        }
Пример #3
0
        public static void SaveEmployeeMap(string varTerritoryID, System.Web.UI.WebControls.ListItemCollection itemList)
        {
            QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
            //delete out the existing
            QueryCommand cmdDel = new QueryCommand("DELETE FROM [EmployeeTerritories] WHERE [EmployeeTerritories].[TerritoryID] = @TerritoryID", Territory.Schema.Provider.Name);

            cmdDel.AddParameter("@TerritoryID", varTerritoryID, DbType.String);
            coll.Add(cmdDel);
            DataService.ExecuteTransaction(coll);
            foreach (System.Web.UI.WebControls.ListItem l in itemList)
            {
                if (l.Selected)
                {
                    EmployeeTerritory varEmployeeTerritory = new EmployeeTerritory();
                    varEmployeeTerritory.SetColumnValue("TerritoryID", varTerritoryID);
                    varEmployeeTerritory.SetColumnValue("EmployeeID", l.Value);
                    varEmployeeTerritory.Save();
                }
            }
        }