Exemplo n.º 1
0
 private void textBoxRealReceived_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         double total = salesList.TotalMoney;
         double paied = 0;
         if (!double.TryParse(this.textBoxRealReceived.Text.Trim(), out paied))
         {
             SetNewTip("提示:请在实收款栏输入数字!", this.toolStripStatusLabelTip.Text);
             return;
         }
         paied = Convert.ToDouble(this.textBoxRealReceived.Text);
         double shouldreturn = paied - total;
         if (paied >= total)
         {
             this.textBoxRealReceived.Text = NumericUtility.ToMoneyFormat(paied);
             this.textBoxReturnChange.Text = NumericUtility.ToMoneyFormat(shouldreturn);
             if (this.textBoxVIPCardNo.Text.Trim().Length > 0)
             {
                 salesList.VipCardNo = Convert.ToInt32(this.textBoxVIPCardNo.Text.Trim());
             }
             salesList.RealReceive = paied;
             salesList.ReturnMoney = shouldreturn;
             bComplete             = true;
         }
     }
     else if ((e.KeyCode == Keys.F4) || (e.KeyCode == Keys.F5))
     {
         FormBalance_KeyDown(sender, e);
     }
 }
Exemplo n.º 2
0
 private void ResetForm()
 {
     // 清空原来的
     this.bs.Clear();
     // 重新生成一个流水号
     this.textBoxSerialNumber.Text = GetNewSerialNumber();
     // 清空商品条码、数量、单价、折扣
     this.textBoxProductId.Text = string.Empty;
     this.textBoxCount.Text     = "0";
     this.textBoxPrice.Text     = NumericUtility.ToMoneyFormat(0);
     this.textBoxDiscount.Text  = "0";
 }
Exemplo n.º 3
0
        /// <summary>
        /// 在主窗口里按键
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormMain_KeyDown(object sender, KeyEventArgs e)
        {
            // 按下F1
            if (e.KeyCode == Keys.F1)
            {
                // 封装销售对象
                SalesList saleList = new SalesList()
                {
                    SerialNumber  = this.textBoxSerialNumber.Text,
                    TotalMoney    = Convert.ToDouble(this.textBoxShouldPay.Text),
                    SalesPersonId = Program.LoginSalePerson.SalesPersonId
                };
                // 打开结算对象窗口
                FormBalance dlg = new FormBalance(saleList);
                if (DialogResult.OK != dlg.ShowDialog())
                {
                    if (((KeyEventArgs)dlg.Tag).KeyCode == Keys.F4)
                    {
                        ResetForm();
                        // 更新主窗口的实收、找零
                        this.textBoxRealReceived.Text = NumericUtility.ToMoneyFormat(saleList.RealReceive);
                        this.textBoxReturnChange.Text =
                            NumericUtility.ToMoneyFormat(saleList.ReturnMoney);
                    }
                    return;
                }

                saleList = dlg.salesList;
                try
                {
                    // 保存销售信息、明细
                    objSalesManager.SaveSaleInfo(saleList, salesListDetailList);
                }
                // 访问数据库出错
                catch (Exception ex)
                {
                    MessageBoxEx.Show("保存商品明细时出错!",
                                      Program.MessageBoxTitle[Program.MessageBoxTitleType.Error],
                                      ex.Message,
                                      MessageBoxButtons.OK,
                                      MessageBoxIcon.Error);
                }
                // 有会员卡,则更新积分
                if (dlg.salesList.VipCardNo != 0)
                {
                    try
                    {
                        objSalesManager.UpdateVipPoint(dlg.salesList.VipCardNo,
                                                       (int)(Math.Floor(Convert.ToDouble(this.textBoxShouldPay.Text) / 10)));
                    }
                    // 更新积分时,数据库出错
                    catch (Exception ex)
                    {
                        MessageBoxEx.Show("更新会员积分时出错!",
                                          Program.MessageBoxTitle[Program.MessageBoxTitleType.Error],
                                          ex.Message,
                                          MessageBoxButtons.OK,
                                          MessageBoxIcon.Error);
                    }
                }

                // 打印小票
                // TODO
                //printDocumentMain.Print();

                ResetForm();
                // 更新主窗口的实收、找零
                this.textBoxRealReceived.Text = NumericUtility.ToMoneyFormat(saleList.RealReceive);
                this.textBoxReturnChange.Text =
                    NumericUtility.ToMoneyFormat(saleList.ReturnMoney);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 更新总价
 /// </summary>
 private void AdjustTotal()
 {
     // 更新总价
     this.textBoxShouldPay.Text = NumericUtility.ToMoneyFormat((from p in this.salesListDetailList select p.SubTotalMoney).Sum());
 }
Exemplo n.º 5
0
 public FormBalance(SalesList objSalesList) : this()
 {
     salesList = objSalesList;
     this.textBoxTotal.Text = NumericUtility.ToMoneyFormat(salesList.TotalMoney);
 }
Exemplo n.º 6
0
        public static void Print(System.Drawing.Printing.PrintPageEventArgs e, SalesList salesList, List <SalesListDetail> detailList, SalesPerson sp)
        {
            //生成票据
            float left        = 2;                                                                               //打印区域的左边界
            float top         = 10;                                                                              //打印区域的上边界
            Font  titleFont   = new Font("楷体_gb2312", 12);                                                       //标题字体
            Font  contentFont = new Font("仿宋", 8);                                                               //正文字体

            e.Graphics.DrawString("  实惠到家超市", titleFont, Brushes.Blue, left + 10, top - 5, new StringFormat());  //打印标题
            e.Graphics.DrawString("    购物凭证", titleFont, Brushes.Blue, left + 10, top + 15, new StringFormat()); //打印标题
            //画一条分界线
            Pen pen = new Pen(Color.Green, 1);

            e.Graphics.DrawLine(pen, new Point((int)left - 2, (int)top + 35), new Point((int)left + 180, (int)top + 36));
            //打印内容
            double totalMoney = 0;                                                                                                                                          //商品总计金额

            e.Graphics.DrawString("商品名称          单价     数量      金额", contentFont, Brushes.Blue, left, top + titleFont.GetHeight(e.Graphics) + 12 + 12, new StringFormat()); //打印内容表头标题
            for (int i = 1; i <= detailList.Count; i++)
            {
                //调整间距
                string sp1 = string.Empty;
                if (detailList[i - 1].ProductName.Length == 4)
                {
                    sp1 = "    ";
                }
                else if (detailList[i - 1].ProductName.Length == 3)
                {
                    sp1 = "      ";
                }
                else if (detailList[i - 1].ProductName.Length == 5)
                {
                    sp1 = "  ";
                }
                string sp2 = string.Empty;
                if (detailList[i - 1].UnitPrice.ToString().Length == 3)
                {
                    sp1 = "     ";
                }
                else if (detailList[i - 1].UnitPrice.ToString().Length == 4)
                {
                    sp1 = "    ";
                }
                else if (detailList[i - 1].UnitPrice.ToString().Length == 5)
                {
                    sp1 = "   ";
                }
                string sp3 = string.Empty;
                if (detailList[i - 1].Quantity.ToString().Length == 1)
                {
                    sp1 = "     ";
                }
                else if (detailList[i - 1].Quantity.ToString().Length == 2)
                {
                    sp1 = "    ";
                }
                else if (detailList[i - 1].Quantity.ToString().Length == 3)
                {
                    sp1 = "   ";
                }
                e.Graphics.DrawString(detailList[i - 1].ProductName + sp1 + NumericUtility.ToMoneyFormat(detailList[i - 1].UnitPrice) + sp2 + detailList[i - 1].Quantity.ToString() + sp3 + NumericUtility.ToMoneyFormat(detailList[i - 1].SubTotalMoney), contentFont, Brushes.Blue, left, top + titleFont.GetHeight(e.Graphics) + contentFont.GetHeight(e.Graphics) * i + 12 + 12, new StringFormat());//打印明细内容
            }
            //画一条分界线
            e.Graphics.DrawLine(pen, new Point((int)left - 2, (int)top + 125), new Point((int)left + 180, (int)top + 36));

            //打印备注
            e.Graphics.DrawString("总计: ", contentFont, Brushes.Blue, left + 10, top + 15, new StringFormat());
            e.Graphics.DrawString("实收: ", contentFont, Brushes.Blue, left + 10, top + 15, new StringFormat());
            e.Graphics.DrawString("找零: ", contentFont, Brushes.Blue, left + 10, top + 15, new StringFormat());
            e.Graphics.DrawString("流水号: ", contentFont, Brushes.Blue, left + 10, top + 15, new StringFormat());
            e.Graphics.DrawString("收银员", contentFont, Brushes.Blue, left + 10, top + 15, new StringFormat());
            e.Graphics.DrawString("在30日内凭小票可开具购物发票", contentFont, Brushes.Blue, left + 10, top + 15, new StringFormat());
            e.Graphics.DrawString("          欢迎再次光临", contentFont, Brushes.Blue, left + 10, top + 15, new StringFormat());
        }