/// <summary> /// Save /// </summary> public void Save() { EmployeeNavigatorTDS salesmanNavigatorChanges = (EmployeeNavigatorTDS)Data.GetChanges(); if (salesmanNavigatorChanges.SalesmanNavigator.Rows.Count > 0) { SalesmanNavigatorGateway salesmanNavigatorGateway = new SalesmanNavigatorGateway(salesmanNavigatorChanges); // Update employees foreach (EmployeeNavigatorTDS.SalesmanNavigatorRow row in (EmployeeNavigatorTDS.SalesmanNavigatorDataTable)salesmanNavigatorChanges.SalesmanNavigator) { Salesman salesman = new Salesman(null); if (!row.InDatabase) { string idForProjects = ""; if (!row.IsIdForProjectsNull()) idForProjects = row.IdForProjects; salesman.InsertDirect(row.SalesmanID, idForProjects); } else { int salesmanId = row.SalesmanID; string originalIdForProjects = salesmanNavigatorGateway.GetIdForProjectsOriginal(salesmanId); string newIdForProjects = salesmanNavigatorGateway.GetIdForProjects(salesmanId); salesman.UpdateDirect(salesmanId, originalIdForProjects, newIdForProjects); } } } }
// //////////////////////////////////////////////////////////////////////// // PUBLIC METHODS // /// <summary> /// LoadBySalesmanId /// </summary> /// <param name="salesmanId">salesmanId</param> public void LoadBySalesmanId(int salesmanId) { SalesmanNavigatorGateway salesmanNavigatorGateway = new SalesmanNavigatorGateway(Data); salesmanNavigatorGateway.LoadBySalesmanId(salesmanId); }
private void BindSalesman() { // DataSet int employeeId = Int32.Parse(hdfEmployeeId.Value); SalesmanNavigator salesmanNavigator = new SalesmanNavigator(employeeNavigatorTDS); salesmanNavigator.LoadBySalesmanId(employeeId); // If salesman dont exists before if (salesmanNavigator.Table.Rows.Count == 0) { // Insert salesman salesmanNavigator.Insert(employeeId, ""); } else { SalesmanNavigatorGateway salesmanNavigatorGateway = new SalesmanNavigatorGateway(employeeNavigatorTDS); tbxSalesmanIdForProjects.Text = salesmanNavigatorGateway.GetIdForProjects(employeeId); } // Store dataset Session["employeeNavigatorTDS"] = employeeNavigatorTDS; }