private void MaterialAssign_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int selectedIndex = CB_Material.SelectedIndex;

                float f;
                var   text = Input_Quantity.Text;

                if (selectedIndex >= 0 && text != "" &&
                    float.TryParse(text, out f) &&
                    Convert.ToDouble(text) <= (double)materialList[selectedIndex].Quantity &&
                    Convert.ToDouble(text) > 0)
                {
                    MaterialItemService.assignMaterialToItem(item.Id, materialList[selectedIndex].Id, Convert.ToDecimal(text), (int)materialList[selectedIndex].Rate);
                    MessageBox.Show("Material Assigned ");
                    getData();
                }
                else
                {
                    MessageBox.Show("Please Select Material and Add Quantity ( Less than Remaining Quantity) ");
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("ERROR :" + err.ToString());
            }
        }
        void AssignBundle(MaterialBundle bundle, decimal Multiplier = 1)
        {
            if (bundle.Id == 7)
            {
                AssignBundle(MaterialBundleService.getMaterialBundleById(5), (decimal)(3.0 / 2.0));
            }
            if (bundle.Id == 8)
            {
                AssignBundle(MaterialBundleService.getMaterialBundleById(5), (decimal)(5.0 / 4.0));
            }

            if (bundle.Id <= 3)
            {
                bundle.MaterialBundleItems.ToList().ForEach(x =>
                {
                    MaterialItemService.assignMaterialToItem(item.Id, (int)x.MaterialId, (decimal)x.Quantity * Multiplier * (decimal)item.JobItem.Article.Multiple, (int)x.Material.Rate);
                });
            }
            else
            {
                bundle.MaterialBundleItems.ToList().ForEach(x =>
                {
                    MaterialItemService.assignMaterialToItem(item.Id, (int)x.MaterialId, (decimal)x.Quantity * Multiplier, (int)x.Material.Rate);
                });
            }
        }
Exemple #3
0
        void updateGrid()
        {
            listMaterialItems = MaterialItemService.getMaterialItemFilter(Input_From.SelectedDate, Input_To.SelectedDate, (int?)CB_Articles.SelectedValue, (int?)CB_Locations.SelectedValue, (int?)CB_Material.SelectedValue);

            listMaterialItems.ForEach(x => {
                if (x.Location == null)
                {
                    x.Location = new Location();
                }
            });

            dataGrid.ItemsSource = null;
            dataGrid.ItemsSource = listMaterialItems;
        }
 public ItemMaterialDetail(int Id)
 {
     InitializeComponent();
     list = MaterialItemService.getMaterialItemDetails(Id);
     updateGrid();
 }