Пример #1
0
        private void btn_reprint_Click(object sender, EventArgs e)
        {
            var c_row = dataGridView1.CurrentRow;

            if (c_row != null && c_row.Tag != null && c_row.Tag.ToString() != "")
            {
                var sheet_no = c_row.Tag.ToString();
                //准备打印表格
                DataTable dt = new DataTable();
                dt.Columns.Add("行号");
                dt.Columns.Add("销售单号");
                dt.Columns.Add("客户");
                dt.Columns.Add("操作员");
                dt.Columns.Add("日期");
                dt.Columns.Add("货号");
                dt.Columns.Add("商品名称");
                dt.Columns.Add("规格");
                dt.Columns.Add("单位");
                dt.Columns.Add("数量");
                dt.Columns.Add("单价");
                dt.Columns.Add("金额");
                dt.Columns.Add("合计数量");
                dt.Columns.Add("合计金额");
                dt.Columns.Add("付款方式");
                dt.Columns.Add("实付金额");
                dt.Columns.Add("抹零金额");
                dt.Columns.Add("整单折扣");

                IBLL.ISaleData bll   = new BLL.SaleData();
                DataTable      lines = new DataTable();
                decimal        ml    = 0;
                var            ord   = bll.GetSaleSheetMasterDetail(sheet_no, out lines, out ml);
                decimal        amt   = 0; //单据总金额
                decimal        qty   = 0; //单据总数量
                int            index = 0;
                if (ord != null && lines.Rows.Count > 0)
                {
                    string pay_way_str = "挂账/预付";
                    if (ord.pay_way == "A")
                    {
                        pay_way_str = "现结-现金";
                    }
                    else if (ord.pay_way == "W")
                    {
                        pay_way_str = "现结-微信";
                    }
                    else if (ord.pay_way == "Z")
                    {
                        pay_way_str = "现结-支付宝";
                    }

                    foreach (DataRow dr in lines.Rows)
                    {
                        ++index;
                        //待打印表单处理
                        DataRow row = dt.NewRow();
                        row["行号"]   = index.ToString();
                        row["销售单号"] = ord.sheet_no;
                        row["客户"]   = ord.cust_no;
                        row["操作员"]  = ord.oper_id;
                        row["日期"]   = ord.oper_date.ToString("yyyy-MM-dd");
                        row["货号"]   = dr["item_subno"].ToString();
                        row["商品名称"] = dr["item_name"].ToString();
                        row["规格"]   = dr["item_size"].ToString();
                        row["单位"]   = dr["unit_no"].ToString();
                        row["数量"]   = Conv.ToDecimal(dr["sale_qnty"]).ToString("F2");
                        row["单价"]   = Conv.ToDecimal(dr["real_price"]).ToString("F2");
                        row["金额"]   = Conv.ToDecimal(dr["sale_money"]).ToString("F2");
                        row["付款方式"] = pay_way_str;
                        row["实付金额"] = ord.real_amount.ToString("F2");
                        row["抹零金额"] = ml.ToString("F2");
                        if (ord.discount != 0)
                        {
                            row["整单折扣"] = (ord.discount * 100) + "折";
                        }
                        else
                        {
                            row["整单折扣"] = "无折扣";
                        }
                        dt.Rows.Add(row);
                        amt += Conv.ToDecimal(dr["sale_money"]);
                        qty += Conv.ToDecimal(dr["sale_qnty"]);
                    }
                    foreach (DataRow row in dt.Rows)
                    {
                        row["合计数量"] = qty.ToString("F2");
                        row["合计金额"] = amt.ToString("F2");
                    }
                }
                //打印
                try
                {
                    IBLL.ISysBLL sbll = new BLL.SysBLL();
                    sbll.WritePrintLog(ord.sheet_no);
                    printXSCK printXsck = new printXSCK(dt);
                    printXsck.print();
                }
                catch (Exception ex)
                {
                    Log.writeLog("btn_reprint_Click()", ex.ToString(), sheet_no);
                }
            }
        }