//进入结算界面
        private void Balance()
        {
            FrmBalance frm = new FrmBalance(this.lblTotalMoney.Text);

            frm.ShowDialog();
            string[] temp = frm.Tag.ToString().Split('|');
            if (temp[0].Equals("F3"))//正常结账
            {
                this.lblReceivedMoney.Text = temp[1];
                this.lblReturnMoney.Text   = (Convert.ToDecimal(this.lblReceivedMoney.Text) - Convert.ToDecimal(this.lblTotalMoney.Text)).ToString();
                SaleInfo objSale = new SaleInfo()
                {
                    SerialNum      = this.lblSerialNum.Text,
                    SalePersonId   = Program.objCurrentLoginer.LoginId,
                    SalePersonName = Program.objCurrentLoginer.LoginName,
                    TotalMoney     = Convert.ToDecimal(this.lblTotalMoney.Text),
                    RealMoney      = Convert.ToDecimal(this.lblReceivedMoney.Text),//这里需要检查
                    ReturnMoney    = Convert.ToDecimal(this.lblReturnMoney.Text),
                    objProduct     = this.saleProductList
                };

                try
                {
                    if (new ProductService().UpdateSaleInfo(objSale))
                    {
                        //不作为或记录到本地
                    }
                }
                catch (Exception ex)
                {
                    try
                    {
                        new ErrorInfoService().WriteErrorInfoToDB(new Error
                        {
                            LoginId   = Program.objCurrentLoginer.LoginId,
                            Opearte   = new GetInfo().GetEnumDescription(OperateInfo.ErrorHappenedWhenLoginSaleInfo),
                            ErrorDesc = ex.Message
                        });
                    }
                    catch (Exception)
                    {
                        //数据库记录失败,记录到本地
                    }
                }

                ResetInfo();
            }
        }
예제 #2
0
        private void Balance()
        {
            //【1】打开UI界面:考虑取消或者修改的情况
            FrmBalance   frmBalance   = new FrmBalance(this.lblTotalMoney.Text);
            DialogResult dialogResult = frmBalance.ShowDialog();

            if (dialogResult == DialogResult.Cancel)
            {
                if (frmBalance.Tag.ToString() == "F4")//放弃购买:重新生成流水号,等待下一个客户
                {
                    RestForm();
                }
                else if (frmBalance.Tag.ToString() == "F5")//放弃部分商品
                {
                    this.txtProductId.Focus();
                }
            }
            else
            {
                //【2】正式结算
                SMMembers members = null;
                if (frmBalance.Tag.ToString().Contains("|"))//判断是否有会员卡
                {
                    string[] info = frmBalance.Tag.ToString().Split('|');
                    this.lblReceivedMoney.Text = info[0];
                    members = new SMMembers {
                        MemeberId = info[1], Points = (int)Convert.ToDouble(this.lblTotalMoney.Text.Trim()) / 10
                    };
                }
                else//不包含会员卡
                {
                    this.lblReceivedMoney.Text = frmBalance.Tag.ToString();
                }
                //显示找零
                this.lblReturnMoney.Text = (Convert.ToDecimal(this.lblReceivedMoney.Text.Trim()) - Convert.ToDecimal(this.lblTotalMoney.Text.Trim())).ToString();
                //【3】封装主表对象
                SalesListMain salesListMain = new SalesListMain
                {
                    SeriaINum     = this.lblSerialNum.Text,
                    TotalMoney    = Convert.ToDecimal(this.lblTotalMoney.Text.Trim()),
                    RealRecieve   = Convert.ToDecimal(this.lblReceivedMoney.Text.Trim()),
                    ReturnMoney   = Convert.ToDecimal(this.lblReturnMoney.Text.Trim()),
                    SalesPersonId = Program.currentSalesPerson.SalesPersonId,
                };
                //【4】封装明细表对象
                foreach (Product product in productList)
                {
                    salesListMain.ListDetail.Add(new SalesListDetail
                    {
                        SeriaINum     = this.lblSerialNum.Text,
                        ProductId     = product.ProductId,
                        ProductName   = product.ProductName,
                        Quantity      = product.Quantity,
                        UnitPrice     = product.UnitPrice,
                        Discount      = product.Discount,
                        SubTotalMoney = product.SubTotal,
                    });
                }

                //【5】调用后台
                try
                {
                    productService.SaveSaleInfo(salesListMain, members);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("保存数据发生异常" + ex.Message);
                }

                //【6】打印小票
                this.printDocument.Print();
                //【7】生成新的流水号
                RestForm();
            }
        }
예제 #3
0
        private void ApplyBalance()
        {
            FrmBalance   frmBalance = new FrmBalance(this.lblTotalMoney.Text);
            DialogResult result     = frmBalance.ShowDialog();

            if (result == DialogResult.OK)
            {
                string returnInfo = frmBalance.Tag.ToString();
                Member objMember  = null;
                //输入了正确的会员号
                if (returnInfo.Contains("|"))
                {
                    string[] infoSplit = returnInfo.Split('|');
                    this.lblReceivedMoney.Text = infoSplit[0];
                    objMember = new Member()
                    {
                        MemberId = Convert.ToInt32(infoSplit[1]),
                        Points   = (int)(Convert.ToDecimal(this.lblTotalMoney.Text) / 10)
                    };
                }
                else
                {
                    this.lblReceivedMoney.Text = returnInfo;
                }
                this.lblReturnMoney.Text = (Convert.ToDecimal(this.lblReceivedMoney.Text) - Convert.ToDecimal(this.lblTotalMoney.Text)).ToString();
                //封装销售主表
                SalesList objSalesList = new SalesList()
                {
                    SeriaNum      = this.lblSerialNum.Text,
                    TotalMoney    = Convert.ToDecimal(this.lblTotalMoney.Text),
                    RealReceive   = Convert.ToDecimal(this.lblReceivedMoney.Text),
                    ReturnMoney   = Convert.ToDecimal(this.lblReturnMoney.Text),
                    SalesPersonId = Program.currentSalesPerson.SalesPersonId
                };
                //封装销售明细
                foreach (SalesListDetail item in this.mainSaleList.SalesListDetail)
                {
                    objSalesList.SalesListDetail.Add(new SalesListDetail()
                    {
                        SerialNum       = objSalesList.SeriaNum,
                        ProductId       = item.ProductId,
                        ProductFullName = item.ProductFullName,
                        UnitPrice       = item.UnitPrice,
                        Discount        = item.Discount,
                        Quantity        = item.Quantity,
                        SubTotalMoney   = item.SubTotalMoney
                    });
                }
                try
                {
                    //调用后台方法保存数据
                    objProductService.SaveSaleInfo(objSalesList, objMember);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("结算过程出现异常,请检查:" + ex.Message);
                    return;
                }
                //打印小票(电脑蓝屏。。)
                //this.mainSaleList = objSalesList;
                //this.printDocument.Print();
                //界面刷新
                ResetForm();
            }
            else
            {
                if (frmBalance.Tag.ToString().Equals("F4"))//修改商品列表
                {
                    this.lblReceivedMoney.Text = "0.00";
                    this.lblReturnMoney.Text   = "0.00";
                    this.txtProductId.Focus();
                }
                else if (frmBalance.Tag.ToString().Equals("F5"))
                {
                    this.lblTotalMoney.Text    = "0.00";
                    this.lblReceivedMoney.Text = "0.00";
                    this.lblReturnMoney.Text   = "0.00";
                    ResetForm();
                }
            }
        }
예제 #4
0
        private void Balance()
        {
            FrmBalance objFrmBalance = new FrmBalance(this.lblTotalMoney.Text.Trim());

            if (objFrmBalance.ShowDialog() != DialogResult.OK)
            {
                if (objFrmBalance.Tag.ToString() == "F4")//用户放弃本次购买
                {
                    //重新生成流水号等待结算下一个客户
                    RestForm();
                }
                else if (objFrmBalance.Tag.ToString() == "F5")//用户放弃部分商品购买
                {
                    this.txtProductId.Focus();
                }
            }
            else //进入正式结算,获取用户的实付金额和会员卡
            {
                SMMembers objSMM = null;
                if (objFrmBalance.Tag.ToString().Contains('|'))//如果有会员卡号
                {
                    string[] info = objFrmBalance.Tag.ToString().Split('|');
                    this.lblReceivedMoney.Text = info[0];
                    objSMM = new SMMembers()//新建一个会员卡对象
                    {
                        MemberId = info[1],
                        Points   = (int)(Convert.ToDouble(this.lblTotalMoney.Text) / 10.0)
                    };
                }
                else
                {
                    this.lblReceivedMoney.Text = objFrmBalance.Tag.ToString();
                }
                //显示找零
                this.lblReturnMoney.Text = (Convert.ToDecimal(this.lblReceivedMoney.Text.Trim()) -
                                            Convert.ToDecimal(this.lblTotalMoney.Text)).ToString();
                SaleList objSaleList = new SaleList()
                {
                    SerialNum     = this.lblSerialNum.Text.Trim(),
                    TotalMoney    = Convert.ToDecimal(this.lblTotalMoney.Text.Trim()),
                    RealReceive   = Convert.ToDecimal(this.lblReceivedMoney.Text.Trim()),
                    ReturnMoney   = Convert.ToDecimal(this.lblReturnMoney.Text.Trim()),
                    SalesPersonId = Program.CurrentPerson.SalesPersonId
                };
                foreach (Product item in this.productlist)
                {
                    objSaleList.SaleListDetails.Add(new SaleListDetail()
                    {
                        SerialNum     = this.lblSerialNum.Text.Trim(),
                        ProductId     = item.ProductId,
                        ProductName   = item.ProductName,
                        Quantity      = item.Quantity,
                        Discount      = item.Discount,
                        SubTotalMoney = item.SubTotal,
                        UnitPrice     = item.UnitPrice
                    });
                }
                try
                {
                    objProductService.SaveSaleInfo(objSaleList, objSMM);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("保存销售数据到数据库时发生错误" + ex.Message, "错误信息");
                    return;
                }
                this.printDocument.Print(); //打印小票
                RestForm();                 //重置窗口
            }
        }
        private void Balance()
        {
            FrmBalance objFrmBalance = new FrmBalance(this.lblTotalMoney.Text.Trim());

            if (objFrmBalance.ShowDialog() != DialogResult.OK)
            {
                if (objFrmBalance.Tag.ToString() == "F4")
                {
                    // cancel the check out
                    ResetForm();
                }
                else if (objFrmBalance.Tag.ToString() == "F5")
                {
                    // not enough money ,buy some products
                    this.txtProductId.Focus();
                }
                else
                {
                    // check out
                    Members objMember = null;
                    if (objFrmBalance.Tag.ToString().Contains("|"))
                    {
                        string[] info = objFrmBalance.Tag.ToString().Split('|');
                        this.lblReceivedMoney.Text = info[0];

                        objMember = new Members()
                        {
                            MemberId = info[1],
                            Points   = (int)(Convert.ToDouble(this.lblTotalMoney.Text) / 10.0)
                        };
                    }
                    else
                    {
                        this.lblReceivedMoney.Text = objFrmBalance.Tag.ToString();
                    }

                    // display change
                    this.lblReturnMoney.Text = (Convert.ToDecimal(this.lblReceivedMoney.Text.Trim()) - Convert.ToDecimal(this.lblTotalMoney.Text)).ToString();


                    SalesListMain objSaleslist = new SalesListMain()
                    {
                        SerialNum     = this.lblSerialNum.Text.Trim(),
                        TotalMoney    = Convert.ToDecimal(this.lblTotalMoney.Text.Trim()),
                        RealReceive   = Convert.ToDecimal(this.lblReceivedMoney.Text.Trim()),
                        ReturnMoney   = Convert.ToDecimal(this.lblReturnMoney.Text.Trim()),
                        SalesPersonId = Program.objCurrentPerson.SalesPersonId
                    };


                    foreach (Products item in this.productsList)
                    {
                        objSaleslist.ListDetail.Add(new SalesListDetail()
                        {
                            SerialNum     = this.lblSerialNum.Text.Trim(),
                            ProductId     = item.ProductId,
                            ProductName   = item.ProductName,
                            Quantity      = item.Quantity,
                            UnitPrice     = item.UnitPrice,
                            Discount      = item.Discount,
                            SubTotalMoney = item.SubTotal
                        });
                    }


                    // save to db
                    try
                    {
                        objProService.SaveSaleInfo(objSaleslist, objMember);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Save data Error" + ex.Message);
                        return;
                    }

                    ResetForm();
                }
            }
        }