Пример #1
0
        private void tbSelectItem_KeyDown(object sender, KeyEventArgs e)
        {
            //选好单品,并且回车
            if (e.KeyCode == Keys.Enter && tbSelectItem.Text != "")
            {
                SupplyChainPos       scp  = SupplyChainPos.FindById(PosId);
                SupplyChainPosDetail scpd = SupplyChainPosDetail.New;
                BaseInfoMaterial     bim  = BaseInfoMaterial.FindById(MaterialId);
                scpd.IsPaid           = false;
                scpd.MaterialId       = bim.Id;
                scpd.MaterialName     = bim.Name;
                scpd.MaterialCategory = bim.Category;
                scpd.UnitName         = bim.SaleUnitName;
                if (scp.MemberId != 0)
                {
                    scpd.UnitPrice = bim.MemberPrice;
                }
                else
                {
                    scpd.UnitPrice = bim.RetailPrice;
                }
                scpd.Quantity      = 1;
                scpd.Discount      = 0;
                scpd.Amount        = scpd.UnitPrice * scpd.Quantity;
                scpd.IsReturns     = false;
                scpd.IsGift        = false;
                scpd.OrderDateTime = DateTime.Now;
                scpd.Save();
                scp.SupplyChainPosDetails.Add(scpd);
                scp.Quantity       += 1;
                scp.UnPaidQuantity += 1;
                scp.UnPayAmount    += scpd.Amount;
                scp.PosAmount      += scpd.Amount;
                scp.Cashier         = UserStatics.ChineseName;
                scp.Save();
                bim.ConvQuantity -= 1;
                bim.InvQuantity   = bim.ConvQuantity / bim.UnitConvValue;
                bim.Save();

                FrmAddEditBindComboBoxText.BindObjectToControls(scp, panelBottom);

                TableForPosDetail = BllSupplyChainPos.GetPosDetail(PosId);
                ReloadDgvPosDetail();
                foreach (DataGridViewRow row in dgvPosDetail.Rows)
                {
                    row.Selected = true;
                }
                tbSelectItem.Text = "";
                ctUnderPay.Text   = scp.UnPayAmount.ToString();
            }
            if (e.KeyCode == Keys.Down)
            {
                bsSelectItem.MoveNext();
            }
            if (e.KeyCode == Keys.Up)
            {
                bsSelectItem.MovePrevious();
            }
        }
Пример #2
0
        private void PayAllDue()
        {
            SupplyChainPos       scp = SupplyChainPos.FindById(PosId);
            SupplyChainPosDetail scpd;

            //1.遍历表格,取出未付和非赠品,设置为已付
            //2.将pos主表相关项填好,并设为已结
            //3.区分保存储值卡、实付等数据,方便以后统计。
            foreach (DataGridViewRow row in dgvPosDetail.Rows)
            {
                if (row.Selected || (bool)row.Cells["是否已付"].Value == false ||
                    (bool)row.Cells["是否退货"].Value == false ||
                    (bool)row.Cells["是否赠品"].Value == false)
                {
                    scpd        = SupplyChainPosDetail.FindById(long.Parse(row.Cells["Id"].Value.ToString()));
                    scpd.IsPaid = true;
                    scpd.Save();
                    scp.UnPaidQuantity -= 1;
                    scp.UnPayAmount    -= scpd.Amount;
                    if (scp.UnPaidQuantity == 0 && scp.UnPayAmount == 0)
                    {
                        scp.IsAllPaid = true;
                    }
                    scp.Save();
                }
            }

            if (decimal.Parse(ctRemainingSum.Text) >= decimal.Parse(ctUnderPay.Text))
            {
                scp.PayByStoredValueCard = decimal.Parse(ctUnderPay.Text);
                scp.Save();
            }
            else if (decimal.Parse(ctRemainingSum.Text) + ctRealPay.Value == decimal.Parse(ctUnderPay.Text))
            {
                scp.PayByStoredValueCard = decimal.Parse(ctUnderPay.Text) - ctRealPay.Value;
                scp.PayInAmount          = ctRealPay.Value;
                scp.Save();
            }
        }
Пример #3
0
        private void FrmSupplyChainPos_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (PosId != 0)
            {
                SupplyChainPos fscp = SupplyChainPos.FindById(PosId);

                //1.如果当前单据没有子项,则删单
                //2.如果当前单据有子项,
                //2a.如果是挂单,则什么也不做
                //2b.如果不是挂单,则提示是否要保留,
                //2ba.如果保留则自动进入挂单
                //2bb.否则删除子项和当前单据
                if (fscp.Quantity == 0)
                {
                    fscp.Delete();
                }
                else if (fscp.Quantity != 0)
                {
                    if (fscp.IsHolded == false)
                    {
                        DialogResult dr = MessageBox.Show("当前单据未挂单,是否要保留", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                        if (dr == DialogResult.OK)
                        {
                            fscp.IsHolded = true;
                            fscp.Save();
                        }
                        else
                        {
                            SupplyChainPosDetail.DeleteAll(CK.K["SupplyChainPosId"] == PosId);
                            fscp.SupplyChainPosDetails.Clear();
                            fscp.Delete();
                        }
                    }
                }
            }
        }