Exemplo n.º 1
0
        private void btnAddNewAccessory_Click(object sender, RoutedEventArgs e)
        {
            if (!account.MaterialPlan)
            {
                return;
            }
            var window = new AddMaterialPlanForProductNoWindow(productNo, supplierAccessoriesList, null, materialPlanList);

            window.ShowDialog();
            if (window.materialUpdate != null)
            {
                materialPlanList.RemoveAll(r => r.ProductNo == window.materialUpdate.ProductNo && r.SupplierId == window.materialUpdate.SupplierId);
                materialPlanList.Add(window.materialUpdate);
                LoadMaterialPlan(materialPlanList);
            }
        }
Exemplo n.º 2
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (!account.MaterialPlan)
            {
                return;
            }
            btnEditMatsPlan = sender as Button;
            var rowClicked = dgAccessoriesInfor.CurrentItem as MaterialPlanModel;

            if (rowClicked == null)
            {
                return;
            }
            btnEditMatsPlan.IsEnabled = false;
            var window = new AddMaterialPlanForProductNoWindow(productNo, supplierAccessoriesList, rowClicked, materialPlanList);

            window.ShowDialog();
            if (window.materialUpdate != null)
            {
                var indexOf = materialPlanList.IndexOf(rowClicked);
                try
                {
                    if (window.runModeRespone == EExcute.Update)
                    {
                        materialPlanList.RemoveAt(indexOf);
                        materialPlanList.Insert(indexOf, window.materialUpdate);
                        foreach (var matsDelivery in matsInspectionList)
                        {
                            if (matsDelivery.SupplierId.Equals(rowClicked.SupplierId))
                            {
                                matsDelivery.SupplierId = window.materialUpdate.SupplierId;
                            }
                        }
                    }
                    else if (window.runModeRespone == EExcute.Delete)
                    {
                        materialPlanList.RemoveAt(indexOf);
                        matsInspectionList.RemoveAll(r => r.SupplierId.Equals(rowClicked.SupplierId));
                    }
                    LoadMaterialPlan(materialPlanList);
                    LoadInspectionDetail(matsInspectionList);
                }
                catch { }
            }
            btnEditMatsPlan.IsEnabled = true;
        }