Ejemplo n.º 1
0
        public static void SaveSalesPersonMap(int varTerritoryID, int[] itemList)
        {
            QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
            //delete out the existing
            QueryCommand cmdDel = new QueryCommand("DELETE FROM SalesTerritoryHistory WHERE TerritoryID=@TerritoryID", SalesTerritory.Schema.Provider.Name);

            cmdDel.AddParameter("@TerritoryID", varTerritoryID);
            coll.Add(cmdDel);
            DataService.ExecuteTransaction(coll);
            foreach (int item in itemList)
            {
                SalesTerritoryHistory varSalesTerritoryHistory = new SalesTerritoryHistory();
                varSalesTerritoryHistory.SetColumnValue("TerritoryID", varTerritoryID);
                varSalesTerritoryHistory.SetColumnValue("SalesPersonID", item);
                varSalesTerritoryHistory.Save();
            }
        }
Ejemplo n.º 2
0
        public static void SaveSalesTerritoryMap(int varSalesPersonID, System.Web.UI.WebControls.ListItemCollection itemList)
        {
            QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
            //delete out the existing
            QueryCommand cmdDel = new QueryCommand("DELETE FROM SalesTerritoryHistory WHERE SalesPersonID=@SalesPersonID", SalesPerson.Schema.Provider.Name);

            cmdDel.AddParameter("@SalesPersonID", varSalesPersonID);
            coll.Add(cmdDel);
            DataService.ExecuteTransaction(coll);
            foreach (System.Web.UI.WebControls.ListItem l in itemList)
            {
                if (l.Selected)
                {
                    SalesTerritoryHistory varSalesTerritoryHistory = new SalesTerritoryHistory();
                    varSalesTerritoryHistory.SetColumnValue("SalesPersonID", varSalesPersonID);
                    varSalesTerritoryHistory.SetColumnValue("TerritoryID", l.Value);
                    varSalesTerritoryHistory.Save();
                }
            }
        }