public bool UnassignBatteryItem(BatteryItemAssignment assignment) { // bool result = false; try { result = executeNonQuery(USP_BATTERY_UNASSIGN, new object[] { assignment.ItemID, assignment.AssignedDate, assignment.AssignedUser, assignment.RowVersion }); } catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while unassigning battery item.", ex))); } return(result); }
private void OnFormLoad(object sender, System.EventArgs e) { //Initialize controls - set default values this.Cursor = Cursors.WaitCursor; try { //Show early this.Visible = true; Application.DoEvents(); #region Grid control this.grdAssignments.DisplayLayout.CaptionAppearance.FontData.SizeInPoints = 8; this.grdAssignments.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.True; this.grdAssignments.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.True; this.grdAssignments.DisplayLayout.Bands[0].Override.CellClickAction = CellClickAction.Edit; this.grdAssignments.DisplayLayout.Bands[0].Columns["Assign"].CellActivation = Activation.AllowEdit; this.grdAssignments.DisplayLayout.Bands[0].Override.RowFilterMode = RowFilterMode.AllRowsInBand; this.grdAssignments.DisplayLayout.Bands[0].Columns["AssignedDate"].SortIndicator = SortIndicator.Descending; this.grdAssignments.DisplayLayout.Bands[0].Columns["AssignedDate"].EditorComponent = this.dtGrid; this.grdAssignments.DisplayLayout.Bands[0].Columns["AssignedDate"].CellActivation = Activation.AllowEdit; #endregion this._chkShowUnassigned.Checked = this.mDriver.IsActive == 1; this._chkShowUnassigned.Enabled = this.mDriver.IsActive == 1; this.mDriverAssignments = new BatteryItemAssignments(); for (int i = 0; i < this.mDriver.Assignments.Count; i++) { BatteryItemAssignment assignment = new BatteryItemAssignment(); assignment.ItemID = this.mDriver.Assignments[i].ItemID; assignment.DriverID = this.mDriver.Assignments[i].DriverID; assignment.AssignedDate = this.mDriver.Assignments[i].AssignedDate; assignment.AssignedUser = this.mDriver.Assignments[i].AssignedUser; assignment.Comments = this.mDriver.Assignments[i].Comments; assignment.RowVersion = this.mDriver.Assignments[i].RowVersion; this.mDriverAssignments.Add(assignment); } BatteryItems items = MobileDevicesProxy.GetUnassignedBatteryItems(this.mDriver.TerminalID); for (int i = 0; i < items.Count; i++) { BatteryItemAssignment assignment = new BatteryItemAssignment(); assignment.ItemID = items[i].ItemID; assignment.Comments = items[i].Comments; assignment.RowVersion = items[i].RowVersion; this.mDriverAssignments.Add(assignment); } this.mAssignments.DataSource = this.mDriverAssignments; OnShowUnassignedBatteries(null, null); this.txtBatteryInput.Focus(); } catch (Exception ex) { App.ReportError(ex, true, Argix.Terminals.LogLevel.Error); } finally { this.btnOK.Enabled = false; this.Cursor = Cursors.Default; } }
public static bool UnassignBatteryItem(BatteryItemAssignment assignment) { bool ret = false; try { _Client = new MobileDevicesServiceClient(); assignment.AssignedDate = DateTime.Now; assignment.AssignedUser = Environment.UserName; ret = _Client.UnassignBatteryItem(assignment); _Client.Close(); } catch (FaultException fe) { throw new ApplicationException("UnassignBatteryItem() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("UnassignBatteryItem() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("UnassignBatteryItem() communication error.", ce); } return(ret); }
public LocalDriver GetDriver(int driverID) { //Get an exisitng driver LocalDriver driver = null; try { LocalDrivers drivers = GetDrivers(0, true); for (int i = 0; i < drivers.Count; i++) { if (drivers[i].DriverID == driverID) { driver = drivers[i]; ItemDS itemDS = new ItemDS(); DataSet ds = fillDataset(USP_BATTERY_ASSIGNMENTS, TBL_BATTERY_ASSIGNMENTS, new object[] { }); if (ds != null) { itemDS.Merge(ds); BatteryItemAssignments assignments = new BatteryItemAssignments(); ItemDS.BatteryItemAssignmentTableRow[] da = (ItemDS.BatteryItemAssignmentTableRow[])itemDS.BatteryItemAssignmentTable.Select("DriverID=" + driver.DriverID); for (int j = 0; j < da.Length; j++) { BatteryItemAssignment assignment = new BatteryItemAssignment(da[j]); assignments.Add(assignment); } driver.Assignments = assignments; } break; } } //DataContractSerializer dcs = new DataContractSerializer(typeof(LocalDriver)); //System.IO.MemoryStream ms = new System.IO.MemoryStream(); //dcs.WriteObject(ms,driver); //ms.Seek(0,System.IO.SeekOrigin.Begin); //System.IO.StreamReader sr = new System.IO.StreamReader(ms); //string xml = sr.ReadToEnd(); } catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading enterprise driver.", ex))); } return(driver); }
public LocalDrivers GetBatteryItemAssignments() { //Get a collection of battery item assignments LocalDrivers drivers = null; try { drivers = new LocalDrivers(); DataSet ds1 = fillDataset(USP_BATTERY_DRIVERS, TBL_BATTERY_DRIVERS, new object[] { }); if (ds1 != null) { ItemDS itemDS = new ItemDS(); DataSet ds2 = fillDataset(USP_BATTERY_ASSIGNMENTS, TBL_BATTERY_ASSIGNMENTS, new object[] { }); if (ds2 != null) { itemDS.Merge(ds2); } LocalDriverDS driverDS = new LocalDriverDS(); driverDS.Merge(ds1); for (int i = 0; i < driverDS.LocalDriverTable.Rows.Count; i++) { LocalDriver driver = new LocalDriver(driverDS.LocalDriverTable[i]); BatteryItemAssignments assignments = new BatteryItemAssignments(); ItemDS.BatteryItemAssignmentTableRow[] da = (ItemDS.BatteryItemAssignmentTableRow[])itemDS.BatteryItemAssignmentTable.Select("DriverID=" + driver.DriverID); for (int j = 0; j < da.Length; j++) { BatteryItemAssignment assignment = new BatteryItemAssignment(da[j]); assignments.Add(assignment); } driver.Assignments = assignments; drivers.Add(driver); } } } catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading battery item assignments.", ex))); } return(drivers); }