예제 #1
0
 private void itemaccesories_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
 {
     PrintingPress.Accessory _Accessory = (PrintingPress.Accessory)itemaccesories.SelectedItem;
     if (_Accessory != null)
     {
         ((PrintingPress.Accessory)itemaccesories.SelectedItem).Calc_Cost = ((PrintingPress.Accessory)itemaccesories.SelectedItem).Cost * ((PrintingPress.Accessory)itemaccesories.SelectedItem).Consumption;
         ((PrintingPress.Accessory)itemaccesories.SelectedItem).RaisePropertyChanged("Calc_Cost");
     }
 }
예제 #2
0
        private void project_Changed()
        {
            List <project_template_detail> _projectTemplate = new List <project_template_detail>();
            int selectid = Convert.ToInt32(id_project);

            _projectTemplate = entity.db.project_template_detail.Where(x => x.id_project_template == selectid).ToList();
            project_template_detail accesories_template       = _projectTemplate.Where(x => x.logic == "Accessory").FirstOrDefault();
            project_template_detail accesories_x_qty_template = _projectTemplate.Where(x => x.logic == "Accessory Per Quantity").FirstOrDefault();
            project_template_detail ink_template     = _projectTemplate.Where(x => x.logic == "ink").FirstOrDefault();
            project_template_detail printer_template = _projectTemplate.Where(x => x.logic == "printer").FirstOrDefault();
            project_template_detail toner_template   = _projectTemplate.Where(x => x.logic == "Toner").FirstOrDefault();
            project_template_detail paper_template   = _projectTemplate.Where(x => x.logic == "paper").FirstOrDefault();
            project_template_detail cut_template     = _projectTemplate.Where(x => x.logic == "Cut").FirstOrDefault();

            //project_template_detail accesory_abc = _projectTemplate.Where(x => x.logic == "accesory_abc").FirstOrDefault();

            if (ink_template != null)
            {
                int _inkTag = Convert.ToInt16(ink_template.id_tag);

                cmbink.SelectedValuePath = "id_item";
                cmbink.DisplayMemberPath = "name";
                cmbink.ItemsSource       = entity.db.items
                                           .Where(x => entity.db.item_tag_detail.Where(y => y.id_tag == _inkTag)
                                                  .Select(z => z.id_item)
                                                  .Contains(x.id_item)).ToList();
                cmbvalue.ItemsSource = ink_Percentage;
            }

            if (printer_template != null)
            {
                _printerTag = Convert.ToInt16(printer_template.id_tag);

                using (db db = new db())
                {
                    List <item> printerlist = entity.db.items.Where(x => entity.db.item_tag_detail
                                                                    .Where(y => y.id_tag == _printerTag)
                                                                    .Select(z => z.id_item)
                                                                    .Contains(x.id_item)).ToList();

                    foreach (item _item in printerlist)
                    {
                        PrintingPress.Printer _printer = new PrintingPress.Printer();
                        _printer.Id          = _item.id_item;
                        _printer.Name        = _item.name;
                        _printer.Min_Long    = (decimal)_item.item_asset.FirstOrDefault().min_width;
                        _printer.Min_Short   = (decimal)_item.item_asset.FirstOrDefault().min_length;
                        _printer.Max_Long    = (decimal)_item.item_asset.FirstOrDefault().max_width;
                        _printer.Max_Short   = (decimal)_item.item_asset.FirstOrDefault().max_length;
                        _printer.Speed       = (int)_item.item_asset.FirstOrDefault().speed;
                        _printer.Color_Limit = (int)_item.item_property.FirstOrDefault().value;
                        _printer.Cost        = (decimal)_item.unit_cost;
                        _printer.Cost_DieSet = (decimal)_item.item_asset.FirstOrDefault().dieset_price;
                        //Adding to List
                        _printerList.Add(_printer);
                        //stpprinter.ItemsSource = _printerList;
                    }
                }
            }

            if (accesories_template != null)
            {
                int         _accessoryTag = Convert.ToInt16(accesories_template.id_tag);
                List <item> _itemList     = entity.db.items.Where(x => entity.db.item_tag_detail
                                                                  .Where(y => y.id_tag == _accessoryTag)
                                                                  .Select(z => z.id_item).Contains(x.id_item)).ToList();

                foreach (item item in _itemList)
                {
                    int id_item = Convert.ToInt32(item.id_item);
                    if (id_item > 0)
                    {
                        PrintingPress.Accessory accessory = new PrintingPress.Accessory();
                        accessory.Id          = (int)item.id_item;
                        accessory.Cost        = (decimal)item.unit_cost;
                        accessory.Name        = item.name;
                        accessory.Consumption = 1;
                        accessory.Calc_Cost   = accessory.Cost * accessory.Consumption;
                        _accessoryList.Add(accessory);
                    }
                }
                itemaccesories.ItemsSource = _accessoryList.ToList();
            }

            if (toner_template != null)
            {
                int  _tonerTag = Convert.ToInt16(toner_template.id_tag);
                item _toner    = entity.db.items
                                 .Where(x => entity.db.item_tag_detail
                                        .Where(y => y.id_tag == _tonerTag)
                                        .Select(z => z.id_item).Contains(x.id_item)).FirstOrDefault();
            }

            if (cut_template != null)
            {
                int  _cutTag = Convert.ToInt16(cut_template.id_tag);
                item _cut    = entity.db.items
                               .Where(x => entity.db.item_tag_detail
                                      .Where(y => y.id_tag == _cutTag)
                                      .Select(z => z.id_item).Contains(x.id_item)).FirstOrDefault();
            }

            if (paper_template != null)
            {
                int _paperTag = Convert.ToInt16(paper_template.id_tag);
                using (db db = new db())
                {
                    List <item> paperlist = entity.db.items
                                            .Where(x => entity.db.item_tag_detail.Where(y => y.id_tag == _paperTag)
                                                   .Select(z => z.id_item)
                                                   .Contains(x.id_item)).ToList();

                    foreach (item _item in paperlist)
                    {
                        PrintingPress.Paper _paper = new PrintingPress.Paper();
                        _paper.Id = _item.id_item;

                        if (_item.item_dimension.Where(x => x.id_app_dimension == id_Weight).FirstOrDefault() != null)
                        {
                            _paper.Weight = (int)_item.item_dimension.Where(x => x.id_app_dimension == id_Weight).FirstOrDefault().value;
                        }
                        else
                        {
                            _paper.Weight = 0;
                        }

                        _paper.Cost = (decimal)_item.unit_cost;

                        if (_item.item_dimension.Where(x => x.id_app_dimension == id_Long).FirstOrDefault() != null)
                        {
                            _paper.Long = (decimal)_item.item_dimension.Where(x => x.id_app_dimension == id_Long).FirstOrDefault().value;
                        }
                        else
                        {
                            _paper.Long = 0;
                        }

                        if (_item.item_dimension.Where(x => x.id_app_dimension == id_Short).FirstOrDefault() != null)
                        {
                            _paper.Short = (decimal)_item.item_dimension.Where(x => x.id_app_dimension == id_Short).FirstOrDefault().value;
                        }
                        else
                        {
                            _paper.Short = 0;
                        }

                        _paper.Name = _paper.Long.ToString() + " x " + _paper.Short.ToString();
                        //Adding Paper to PaperList
                        _paperList.Add(_paper);
                    }
                }
            }
        }