private void AssignUserSelection(ListViewItem assignedLVItem) { string userName = assignedLVItem.Text; if (!string.IsNullOrEmpty(userName) && assignedLVItem.SubItems != null && assignedLVItem.SubItems.Count > 0) { string typeName = assignedLVItem.SubItems[1].Text; if (!string.IsNullOrEmpty(typeName)) { PairType <CashDrawerUserVO, List <CashDrawerUserVO> > cDrawerEntry = this.cashDrawerUserMap[this.cashDrawerSelection]; if (typeName.Equals(PRIMARY, StringComparison.OrdinalIgnoreCase)) { this.assignedUserSelection = cDrawerEntry.Left; return; } if (CollectionUtilities.isNotEmpty(cDrawerEntry.Right)) { foreach (CashDrawerUserVO cdUsr in cDrawerEntry.Right) { if (cdUsr == null) { continue; } if (cdUsr.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase)) { this.assignedUserSelection = cdUsr; return; } } } } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void availableUsersListView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (e == null) { return; } if (e.IsSelected && e.Item != null && this.cashDrawerSelection != null) { ListViewItem assignedLVItem = e.Item; string userName = assignedLVItem.Text; if (!string.IsNullOrEmpty(userName) && assignedLVItem.SubItems != null && assignedLVItem.SubItems.Count > 0) { string userId = assignedLVItem.SubItems[0].Text; if (!string.IsNullOrEmpty(userId)) { int availUserIdx = this.availableUsers.FindIndex(delegate(CashDrawerUserVO cdu) { return(cdu.UserName.Equals(userId, StringComparison.OrdinalIgnoreCase)); }); if (availUserIdx >= 0) { this.availableUserSelection = this.availableUsers[availUserIdx]; return; } } } } this.availableUserSelection = null; }
/// <summary> /// /// </summary> /// <param name="cvo"></param> /// <param name="clearFirst"></param> private void addUserToAssignedUserListView(CashDrawerUserVO cvo, bool clearFirst) { if (clearFirst) { this.assignedUserListView.Items.Clear(); this.assignedUserListView.Update(); } ListViewItem viewItem = new ListViewItem(cvo.UserName); viewItem.SubItems.Add(((clearFirst) ? PRIMARY : AUXILIARY)); this.assignedUserListView.Items.Add(viewItem); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addUserButton_Click(object sender, EventArgs e) { if (this.availableUserSelection == null || this.cashDrawerSelection == null) { if (this.availableUserSelection == null && this.cashDrawerSelection != null) { MessageBox.Show("Please select a user from the available user list.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (this.cashDrawerSelection == null && this.assignedUserSelection != null) { MessageBox.Show("Please select a cash drawer.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("Please select a cash drawer and a user from the available user list.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } //Get the cash drawer user map PairType <CashDrawerUserVO, List <CashDrawerUserVO> > mapping = this.cashDrawerUserMap[this.cashDrawerSelection]; if (mapping.Left == null) { mapping.Left = this.availableUserSelection; } else { mapping.Right.Add(this.availableUserSelection); } updatedCashDrawerId.Add(this.cashDrawerSelection.Id); this.cashDrawerUserMap[this.cashDrawerSelection] = mapping; this.availableUsers.Remove(this.availableUserSelection); this.updateAvailableUserList(); this.updateAssignedUserList(this.cashDrawerSelection); //Clear selection this.availableUserSelection = null; this.assignedUserSelection = null; //Set pending changes this.pendingChanges = true; if (this.submitButton.Enabled == false) { this.submitButton.Enabled = true; this.submitButton.Update(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void assignedUserListView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (e == null) { return; } if (e.IsSelected && e.Item != null && this.cashDrawerSelection != null) { ListViewItem assignedLVItem = e.Item; AssignUserSelection(assignedLVItem); return; } this.assignedUserSelection = null; }
public ShopCashMgr() { InitializeComponent(); this.NavControlBox = new NavBox(); this.assignedUserSelection = null; this.availableUserSelection = null; this.cashDrawerSelection = null; this.cashDrawers = new List <CashDrawerVO>(); this.availableUsers = new List <CashDrawerUserVO>(); this.assignedPrimaryUsers = new List <CashDrawerUserVO>(); this.assignedAuxiliaryUsers = new List <CashDrawerUserVO>(); this.cashDrawerUserMap = new Dictionary <CashDrawerVO, PairType <CashDrawerUserVO, List <CashDrawerUserVO> > >(); this.cashDrawerDeleteMap = new Dictionary <CashDrawerVO, List <CashDrawerUserVO> >(); deleteMapping = new List <CashDrawerUserVO>(); updatedCashDrawerId = new List <string>(); }
/// <summary> /// /// </summary> /// <param name="dR"></param> /// <returns></returns> private CashDrawerUserVO getCashDrawerUser(DataRow dR) { if (dR == null) { return(null); } CashDrawerUserVO cDrawUsr = new CashDrawerUserVO(); cDrawUsr.Id = Utilities.GetStringValue(dR["id"]); cDrawUsr.UserId = Utilities.GetIntegerValue(dR["userid"]); cDrawUsr.UserName = Utilities.GetStringValue(dR["username"]); cDrawUsr.BranchId = Utilities.GetStringValue(dR["branchid"]); cDrawUsr.NetName = Utilities.GetStringValue(dR["netname"]); return(cDrawUsr); }
private void assignedUserListView_SelectedIndexChanged(object sender, EventArgs e) { if (e == null) { return; } if (this.cashDrawerSelection != null) { //Madhu - fix for BZ # 124 if (assignedUserListView.SelectedItems.Count > 0) { ListViewItem assignedLVItem = assignedUserListView.SelectedItems[0]; AssignUserSelection(assignedLVItem); return; } } this.assignedUserSelection = null; }
/// <summary> /// /// </summary> /// <returns></returns> private bool retrieveCashDrawerDetails() { DesktopSession cds = GlobalDataAccessor.Instance.DesktopSession; this.cashDrawers = new List <CashDrawerVO>(); string storeNumber = cds.CurrentSiteId.StoreNumber; DataTable storeCashDrawerList; DataTable availCashDrawerUsersList; DataTable assignCashDrawerUsersList; DataTable auxCashDrawerUsersList; string errorCode; string errorText; if (!ShopProcedures.ExecuteGetCashDrawerDetails( GlobalDataAccessor.Instance.OracleDA, storeNumber, out storeCashDrawerList, out availCashDrawerUsersList, out assignCashDrawerUsersList, out auxCashDrawerUsersList, out errorCode, out errorText)) { MessageBox.Show("Cannot retrieve cash drawer details for this store"); return(false); } //Load cash drawers if (storeCashDrawerList != null && storeCashDrawerList.IsInitialized && storeCashDrawerList.Rows != null && storeCashDrawerList.Rows.Count > 0) { foreach (DataRow dR in storeCashDrawerList.Rows) { if (Utilities.GetStringValue(dR["name"]).Contains("SAFE") || Utilities.GetStringValue(dR["name"]).Contains("safe")) { continue; } CashDrawerVO cDrawer = new CashDrawerVO(); cDrawer.Id = Utilities.GetStringValue(dR["id"]); cDrawer.Name = Utilities.GetStringValue(dR["name"]); cDrawer.OpenFlag = Utilities.GetStringValue(dR["openflag"]); cDrawer.RegisterUserId = Utilities.GetStringValue(dR["registeruserid"]); cDrawer.NetName = Utilities.GetStringValue(dR["netname"]); cDrawer.BranchId = Utilities.GetStringValue(dR["branchid"]); this.cashDrawers.Add(cDrawer); } } //Load available cash drawer users this.availableUsers = new List <CashDrawerUserVO>(); if (availCashDrawerUsersList != null && availCashDrawerUsersList.IsInitialized && availCashDrawerUsersList.Rows != null && availCashDrawerUsersList.Rows.Count > 0) { foreach (DataRow dR in availCashDrawerUsersList.Rows) { CashDrawerUserVO cDrawUsr = getCashDrawerUser(dR); this.availableUsers.Add(cDrawUsr); } } //Load assigned cash drawer users if (assignCashDrawerUsersList != null && assignCashDrawerUsersList.IsInitialized && assignCashDrawerUsersList.Rows != null && assignCashDrawerUsersList.Rows.Count > 0) { foreach (DataRow dR in assignCashDrawerUsersList.Rows) { CashDrawerUserVO cDrawUsr = getCashDrawerUser(dR); this.assignedPrimaryUsers.Add(cDrawUsr); } } //Load auxiliary assigned cash drawer users if (auxCashDrawerUsersList != null && auxCashDrawerUsersList.IsInitialized && auxCashDrawerUsersList.Rows != null && auxCashDrawerUsersList.Rows.Count > 0) { foreach (DataRow dR in auxCashDrawerUsersList.Rows) { CashDrawerUserVO cDrawUsr = getCashDrawerUser(dR); cDrawUsr.ConnectedId = Utilities.GetStringValue(dR["ccduid"]); cDrawUsr.RegisterId = Utilities.GetStringValue(dR["cashdrawerid"]); this.assignedAuxiliaryUsers.Add(cDrawUsr); } } //Build user map this.buildInitalAssignedUserMap(); //Load data into shop cash mgmt form this.loadDataIntoForm(); return(true); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void removeUserButton_Click(object sender, EventArgs e) { bool primaryDeleted = false; if (this.assignedUserSelection == null || this.cashDrawerSelection == null) { if (this.assignedUserSelection == null && this.cashDrawerSelection != null) { MessageBox.Show("Please select a user from the assigned user list.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (this.cashDrawerSelection == null && this.assignedUserSelection != null) { MessageBox.Show("Please select a cash drawer.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("Please select a cash drawer and a user from the assigned user list.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } //Get the cash drawer user map PairType <CashDrawerUserVO, List <CashDrawerUserVO> > mapping = this.cashDrawerUserMap[this.cashDrawerSelection]; //Get the cash drawer delete map entry deleteMapping = this.cashDrawerDeleteMap[this.cashDrawerSelection]; //Remove the user in either the primary or auxiliary position if (mapping != null) { if (mapping.Left != null && mapping.Left == this.assignedUserSelection) { if (mapping.Right.Count >= 1) { mapping.Left = mapping.Right[0]; mapping.Right.Remove(mapping.Right[0]); } else { primaryDeleted = true; mapping.Left.RegisterId = null; mapping.Left.UserName = null; mapping.Left.UserId = 0; } } else { mapping.Right.Remove(this.assignedUserSelection); } if (!deleteMapping.Contains(this.assignedUserSelection) && !string.IsNullOrEmpty(this.assignedUserSelection.ConnectedId)) { deleteMapping.Add(this.assignedUserSelection); } //Update available users this.availableUsers.Add(this.assignedUserSelection); //Update user map this.cashDrawerUserMap[this.cashDrawerSelection] = mapping; if (!updatedCashDrawerId.Any(s => s == this.cashDrawerSelection.Id)) { updatedCashDrawerId.Add(this.cashDrawerSelection.Id); } //Update views this.updateAssignedUserList(this.cashDrawerSelection); this.updateAvailableUserList(); //Clear selections this.assignedUserSelection = null; this.availableUserSelection = null; if (primaryDeleted) { if (assignedUserListView.Items.Count == 0) { this.submitButton.Enabled = false; } } //Set pending changes this.pendingChanges = true; if (this.submitButton.Enabled == false) { this.submitButton.Enabled = true; this.submitButton.Update(); } } }