Esempio n. 1
0
        static public void ShowMatListByWH(BaseEntities db, WaybillList wb, DiscCards disc_card = null)
        {
            var f = new frmWhCatalog(1, disc_card);

            //   f.uc.xtraTabPage3.PageVisible = false;
            f.uc.xtraTabPage4.PageVisible             = false;
            f.uc.xtraTabPage5.PageVisible             = false;
            f.uc.xtraTabPage9.PageVisible             = false;
            f.uc.xtraTabPage11.PageVisible            = false;
            f.uc.MatListTabPage.PageVisible           = true;
            f.uc.xtraTabControl1.SelectedTabPageIndex = 4;
            f.uc.wb        = wb;
            f.uc.isMatList = true;

            if (f.ShowDialog() == DialogResult.OK)
            {
                var num = wb.WaybillDet.Count();
                foreach (var item in f.uc.custom_mat_list)
                {
                    var wbd = new WaybillDet
                    {
                        WbillId      = wb.WbillId,
                        Num          = ++num,
                        OnDate       = wb.OnDate,
                        MatId        = item.MatId,
                        WId          = item.WId,
                        Amount       = item.Amount,
                        Price        = item.Price - (item.Price * item.Discount / 100),
                        PtypeId      = item.PTypeId,
                        Discount     = item.Discount,
                        Nds          = wb.Nds,
                        CurrId       = wb.CurrId,
                        OnValue      = wb.OnValue,
                        BasePrice    = item.Price + Math.Round(item.Price.Value * wb.Nds.Value / 100, 2),
                        PosKind      = 0,
                        PosParent    = 0,
                        DiscountKind = disc_card != null ? 2 : 0,
                    };
                    db.WaybillDet.Add(wbd);
                    db.SaveChanges();

                    if (wb.WType == 16)
                    {
                        db.WMatTurn.Add(new WMatTurn()
                        {
                            SourceId = wbd.PosId,
                            PosId    = wbd.PosId,
                            WId      = wbd.WId.Value,
                            MatId    = wbd.MatId,
                            OnDate   = wbd.OnDate.Value,
                            TurnType = 3,
                            Amount   = wbd.Amount
                        });
                    }
                }
                db.SaveChanges();
            }
        }
Esempio n. 2
0
        private void DelMaterialBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (wbd_row != null)
            {
                if (wbd_row.PosType == 0)
                {
                    _db.DeleteWhere <WaybillDet>(w => w.PosId == wbd_row.PosId);
                }

                if (wbd_row.PosType == 1)
                {
                    _db.DeleteWhere <WayBillSvc>(w => w.PosId == wbd_row.PosId * -1);
                }

                if (wbd_row.PosType == 2)
                {
                    _db.DeleteWhere <WayBillTmc>(w => w.PosId == wbd_row.PosId);
                }

                if (wbd_row.PosType == 3)
                {
                    disc_card = null;

                    foreach (var item in _db.WaybillDet.Where(w => w.WbillId == wb.WbillId))
                    {
                        if (item.DiscountKind == 2)
                        {
                            var DiscountPrice = item.BasePrice;
                            item.Price        = DiscountPrice * 100 / (100 + item.Nds.Value);
                            item.Discount     = 0;
                            item.DiscountKind = 0;
                            if (item.WayBillDetAddProps != null)
                            {
                                item.WayBillDetAddProps.CardId = null;
                            }
                            else
                            {
                                _db.WayBillDetAddProps.Add(new WayBillDetAddProps
                                {
                                    CardId = null,
                                    PosId  = item.PosId
                                });
                            }
                        }
                    }
                }

                _db.SaveChanges();

                //     WaybillDetOutGridView.DeleteSelectedRows();
                RefreshDet();
                GetOk();
            }
        }
Esempio n. 3
0
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            using (var frm = new frmSetDiscountCard(_db, wb))
            {
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    disc_card = frm.cart;
                    KagentComboBox.EditValue = wb.KaId;

                    RefreshDet();
                }
            }
        }
Esempio n. 4
0
        public frmWayBillDetOut(BaseEntities db, int?PosId, WaybillList wb, DiscCards cart)
        {
            InitializeComponent();

            _db    = db;
            _PosId = PosId;
            _wb    = wb;
            _cart  = cart;

            WHComboBox.Properties.DataSource     = DBHelper.WhList;
            MatComboBox.Properties.DataSource    = db.MaterialsList.ToList();
            PriceTypesEdit.Properties.DataSource = DB.SkladBase().PriceTypes.ToList();
            ProducerTextEdit.Properties.Items.AddRange(_db.WayBillDetAddProps.Where(w => w.Producer != null).Select(s => s.Producer).Distinct().ToList());

            panel3.Visible = barCheckItem1.Checked;
            if (!barCheckItem1.Checked)
            {
                Height -= panel3.Height;
            }

            panel4.Visible = barCheckItem2.Checked;
            if (!barCheckItem2.Checked)
            {
                Height -= panel4.Height;
            }

            panel5.Visible = barCheckItem3.Checked;
            if (!barCheckItem3.Checked)
            {
                Height -= panel5.Height;
            }

            if (DBHelper.CurrentUser.ShowPrice == 0)
            {
                if (barCheckItem2.Checked)
                {
                    barCheckItem2.PerformClick();
                }
                barCheckItem2.Visibility = BarItemVisibility.Never;
            }

            BasePriceEdit.Enabled  = new UserSettingsRepository(DBHelper.CurrentUser.UserId, _db).AccessEditPrice;
            PriceTypesEdit.Enabled = BasePriceEdit.Enabled;
            panelControl4.Enabled  = BasePriceEdit.Enabled;
        }
Esempio n. 5
0
        private void frmDiscountCardEdit_Load(object sender, EventArgs e)
        {
            if (_id == null)
            {
                dc = _db.DiscCards.Add(new DiscCards
                {
                    GrpId      = 1,
                    ExpireDate = DateTime.Now.AddYears(1),
                    OnValue    = 0,
                    Num        = "",
                    DiscType   = 1
                });
            }
            else
            {
                dc = _db.DiscCards.Find(_id);
            }

            DiscCardsBS.DataSource = dc;

            GrpIdEdit.Properties.TreeList.DataSource = DB.SkladBase().DiscCardGrp.Select(s => new { s.GrpId, s.PId, s.Name }).ToList();
            KagentComboBox.Properties.DataSource     = DBHelper.Kagents;
        }
Esempio n. 6
0
 public frmWhCatalog(int gtype, DiscCards cart = null)
 {
     _gtype = gtype;
     InitializeComponent();
     _cart = cart;
 }