private void crud_modalTransfer_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { // Selecteditem_movement = itemMovement.item_movement; item_request_detail item_request_detail = (item_request_detail)item_requestitem_request_detailViewSource.View.CurrentItem; if (crud_modal.Visibility == Visibility.Hidden) { desion desion = (desion)item_request_decisionmovementDataGrid.SelectedItem; desion.decisionState = state.modified; item_request_decision item_request_decision = new global::entity.item_request_decision(); item_request_decision.movement_id = (int)itemMovement.item_movement.id_movement; item_request_decision.IsSelected = true; item_request_decision.id_location = desion.id_location; item_request_decision.quantity = desion.decisionqty; item_request_decision.decision = global::entity.item_request_decision.Decisions.Transfer; item_request_detail.item_request_decision.Add(item_request_decision); item_request_detail.item_request.GetTotalDecision(); item_request_detail.RaisePropertyChanged("balance"); dbContext.SaveChanges(); item_requestViewSource.View.MoveCurrentToLast(); item_requestViewSource.View.MoveCurrentTo(item_request_detail.item_request); item_request_detailitem_request_decisionViewSource.View.Refresh(); toolBar_btnEdit_Click(sender); } }
private void item_request_decisionproductionDataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { CollectionViewSource item_requestitem_request_detailViewSource = ((CollectionViewSource)(FindResource("item_requestitem_request_detailViewSource"))); item_request_detail item_request_detail = item_requestitem_request_detailViewSource.View.CurrentItem as item_request_detail; if (item_request_decisionproductionDataGrid.SelectedItem != null) { desion desion = (desion)item_request_decisionproductionDataGrid.SelectedItem; if (desion.decisionState == state.added) { desion.decisionState = state.modified; item_request_decision item_request_decision = new global::entity.item_request_decision(); item_request_decision.IsSelected = true; item_request_decision.quantity = desion.decisionqty; item_request_decision.decision = global::entity.item_request_decision.Decisions.Production; item_request_detail.item_request_decision.Add(item_request_decision); } } item_request_detail.item_request.GetTotalDecision(); item_request_detail.RaisePropertyChanged("balance"); dbContext.SaveChanges(); item_requestViewSource.View.MoveCurrentToLast(); item_requestViewSource.View.MoveCurrentTo(item_request_detail.item_request); item_request_detailitem_request_decisionViewSource.View.Refresh(); toolBar_btnEdit_Click(sender); }
private void item_request_decisionDataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { CollectionViewSource item_requestitem_request_detailViewSource = ((CollectionViewSource)(FindResource("item_requestitem_request_detailViewSource"))); item_request_detail item_request_detail = (item_request_detail)item_requestitem_request_detailViewSource.View.CurrentItem; if (item_request_decisionmovementDataGrid.SelectedItem != null) { desion desion = (desion)item_request_decisionmovementDataGrid.SelectedItem; if (desion.avlqty < desion.decisionqty) { toolBar.msgWarning("quantity is greater than available quantity"); return; } if (desion.decisionState == state.added) { if (dbContext.items.Where(x => x.id_item == item_request_detail.id_item).FirstOrDefault().item_dimension.Count() > 0) { crud_modal.Children.Clear(); itemMovement.id_item = item_request_detail.id_item; itemMovement.id_location = desion.id_location; itemMovement.db = dbContext; crud_modal.Visibility = Visibility.Visible; crud_modal.Children.Add(itemMovement); } else { desion.decisionState = state.modified; item_request_decision item_request_decision = new global::entity.item_request_decision(); item_request_decision.IsSelected = true; item_request_decision.id_location = desion.id_location; item_request_decision.quantity = desion.decisionqty; item_request_decision.decision = global::entity.item_request_decision.Decisions.Movement; item_request_detail.item_request_decision.Add(item_request_decision); } } else { } } item_request_detail.item_request.GetTotalDecision(); item_request_detail.RaisePropertyChanged("balance"); dbContext.SaveChanges(); item_requestViewSource.View.MoveCurrentToLast(); item_requestViewSource.View.MoveCurrentTo(item_request_detail.item_request); item_request_detailitem_request_decisionViewSource.View.Refresh(); toolBar_btnEdit_Click(sender); }
private void item_request_detailMovementDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { entity.Properties.Settings setting = new entity.Properties.Settings(); int id_branch = setting.branch_ID; CollectionViewSource item_requestitem_request_detailViewSource = ((CollectionViewSource)(FindResource("item_requestitem_request_detailViewSource"))); item_request_detail item_request_detail = (item_request_detail)item_requestitem_request_detailViewSource.View.CurrentItem; if (item_request_detail != null) { item _item = dbContext.items.Where(x => x.id_item == item_request_detail.id_item).FirstOrDefault(); var movement = (from items in dbContext.item_movement where items.status == Status.Stock.InStock && items.item_product.id_item == item_request_detail.id_item && items.app_location.id_branch == id_branch group items by new { items.app_location } into last select new { id_location = last.Key.app_location.id_location, location = last.Key.app_location.name, quntitiy = last.Sum(x => x.credit != null ? x.credit : 0) - last.Sum(x => x.debit != null ? x.debit : 0), }).ToList(); List <desion> list_desion = new List <desion>(); foreach (dynamic item in movement) { // int id_location = (int)item.location; desion desion = new desion(); desion.id_item = _item.id_item; desion.id_location = item.id_location; desion.location = item.location; desion.name = _item.name; desion.avlqty = item.quntitiy; desion.decisionqty = 0; desion.decisionState = state.added; list_desion.Add(desion); } item_request_decisionmovementDataGrid.ItemsSource = list_desion; var transfer = //(from items in dbContext.item_transfer_detail // where items.item_product.id_item == item_request_detail.id_item // group items by new { items.item_transfer.app_branch_destination } // into last // select new // { // id_location = last.Key.app_branch_destination.app_location.Where(x => x.is_default).FirstOrDefault().id_location, // branch = last.Key.app_branch_destination.name, // quntitiy = last.Sum(x => x.quantity_destination != null ? x.quantity_destination : 0), // }).ToList(); (from items in dbContext.item_movement where items.status == Status.Stock.InStock && items.item_product.id_item == item_request_detail.id_item group items by new { items.app_location.app_branch } into last select new { id_location = last.Key.app_branch.app_location.Where(x => x.is_default).FirstOrDefault().id_location, branch = last.Key.app_branch.name, quntitiy = last.Sum(x => x.credit != null ? x.credit : 0) - last.Sum(x => x.debit != null ? x.debit : 0), }).ToList(); List <desion> list_desion_transfer = new List <desion>(); foreach (dynamic item in transfer) { desion desion = new desion(); desion.branch = item.branch; desion.id_location = item.id_location; desion.id_item = _item.id_item; desion.name = _item.name; desion.avlqty = item.quntitiy; desion.decisionqty = 0; desion.decisionState = state.added; list_desion_transfer.Add(desion); } item_request_decisiontransferDataGrid.ItemsSource = list_desion_transfer; List <desion> list_desion_purchase = new List <desion>(); desion purchasedesion = new desion(); purchasedesion.decisionState = state.added; purchasedesion.decisionqty = 0; list_desion_purchase.Add(purchasedesion); item_request_decisionpurchaseDataGrid.ItemsSource = list_desion_purchase; List <desion> list_desion_production = new List <desion>(); desion productiondesion = new desion(); productiondesion.name = item_request_detail.item.name; productiondesion.RaisePropertyChanged("name"); productiondesion.decisionqty = 0; productiondesion.decisionState = state.added; list_desion_production.Add(productiondesion); item_request_decisionproductionDataGrid.ItemsSource = list_desion_production; } }