Esempio n. 1
0
        private void AddIndividualPrice(int PTypeId)
        {
            if (!_db.MatPrices.Any(a => a.PTypeId == PTypeId && a.MatId == _mat_id))
            {
                var price = _db.PriceTypes.FirstOrDefault(w => w.PTypeId == PTypeId);

                _mat_prices = _db.MatPrices.Add(new MatPrices
                {
                    PTypeId   = PTypeId,
                    MatId     = _mat_id.Value,
                    OnValue   = 0,
                    Dis       = 0,
                    WithNds   = 0,
                    ExtraType = price.ExtraType.Value,
                    PPTypeId  = price.PPTypeId,
                    Currency  = null
                });

                _db.SaveChanges();
            }
        }
Esempio n. 2
0
        private void DisCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            PricePanel.Enabled = DisCheckBox.Checked;

            if (!DisCheckBox.ContainsFocus)
            {
                return;
            }

            if (DisCheckBox.Checked)
            {
                _mat_prices.Dis = 0;
                if (_db.Entry <MatPrices>(_mat_prices).State == System.Data.Entity.EntityState.Detached)
                {
                    _mat_prices = _db.MatPrices.Add(_mat_prices);
                }
            }
            else
            {
                _mat_prices.Dis = 1;
            }

            _db.SaveChanges();
        }
Esempio n. 3
0
        private void DirTreeList_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            var focused_tree_node = DirTreeList.GetDataRecordByNode(e.Node) as CatalogTreeList;

            if (focused_tree_node.Id == 1)
            {
                GetListMatPrices();
            }

            xtraTabControl1.SelectedTabPageIndex = focused_tree_node.TabIdx;


            if (focused_tree_node.ParentId == 1)
            {
                _db.SaveChanges();
                int data_set_id = (int)focused_tree_node.DataSetId;

                var pt = _db.GetMatPriceTypes(_mat_id).FirstOrDefault(w => w.PTypeId == data_set_id);
                DisCheckBox.EditValue = pt.Dis;

                _mat_prices = _db.MatPrices.FirstOrDefault(a => a.PTypeId == data_set_id && a.MatId == _mat_id);
                if (_mat_prices == null)
                {
                    _mat_prices = new MatPrices
                    {
                        //   Id = _mat_prices.Id,
                        PTypeId   = data_set_id,
                        MatId     = _mat_id.Value,
                        OnValue   = 0,
                        Dis       = 0,
                        WithNds   = 0,
                        ExtraType = pt.ExtraType.Value,
                        PPTypeId  = pt.PPTypeId,
                        Currency  = null
                    };
                }

                MatPriceTypesBS.DataSource      = _mat_prices;
                DelIdividualMatPriceBtn.Enabled = _mat_prices.Id > 0;



                lookUpEdit2.Properties.DataSource = _db.PriceTypes.Where(w => w.PTypeId != pt.PTypeId).Select(s => new { s.PTypeId, s.Name }).ToList();
                lookUpEdit3.Properties.DataSource = lookUpEdit2.Properties.DataSource;

                if (pt.ExtraType == 1) // в ручну встановити ціну
                {
                    CustomPriceCheckEdit.Checked = true;
                    CustomPriceEdit.EditValue    = pt.OnValue;
                }

                if (pt.ExtraType == 0 || pt.ExtraType == 2 || pt.ExtraType == 3) // автоматично розрахувати ціну
                {
                    AutoCalcPriceCheckEdit.Checked = true;

                    if (pt.ExtraType == 0 && pt.PPTypeId != null) // скидка
                    {
                        checkEdit4.Checked = true;
                    }
                    else // націнка
                    {
                        checkEdit3.Checked = true;
                    }
                }

                if (pt.IsIndividually == 1)
                {
                    CommentLabel.Text = "* Націнтка встановлена для цього товара індивідуально";
                }
                else
                {
                    CommentLabel.Text = "* Націнка взята з довідника цінових катогорій";
                }
                if (pt.Dis == 1)
                {
                    CommentLabel.Text = "* Для даного товара заборонено автоматичне формування відпускної ціни в цій ціновій категорії";
                }
            }
        }