private void btnPrint_Click(object sender, EventArgs e) { //打印回执 DbConnection conn = null; DbTransaction trans = null; try { using (AMSEntities amsContext = new AMSEntities()) { conn = amsContext.Connection; if (conn.State != ConnectionState.Open) { conn.Open(); } using (trans = conn.BeginTransaction(IsolationLevel.ReadCommitted)) { //事务数据操作或其它一致性操作 tbBillSerialNo serialNo = new tbBillSerialNo(); serialNo.vcFill = "0"; amsContext.AddTotbBillSerialNo(serialNo); Helper.Save(amsContext); decimal dReturnFee = decimal.Round(ig.nBalance * 2 / 10, 2); decimal dFee = ig.nBalance - dReturnFee; tbBillList billList = new tbBillList(); billList.iBillNo = serialNo.iSerialNo; billList.iCount = 1; billList.iNO = 1; billList.nCharge = dFee; // ig.nBalance;// -dReturnFee; billList.nPrice = dFee; // ig.nBalance;// -dReturnFee; billList.nRate = 1; billList.vcGoodsName = "退还金额"; //billList.vcUnit = ""; amsContext.AddTotbBillList(billList); tbBillList billList2 = new tbBillList(); billList2.iBillNo = serialNo.iSerialNo; billList2.iCount = 1; billList2.iNO = 2; billList2.nCharge = dReturnFee; billList2.nPrice = dReturnFee; billList2.nRate = 1; billList2.vcGoodsName = "退卡费"; //billList.vcUnit = ""; amsContext.AddTotbBillList(billList2); billInvoice = new tbBillInvoice(); billInvoice.dCharge = ig.nBalance; //0;// ig.nBalance + iFillFee + iExtraFee; billInvoice.dIgGet = 0; billInvoice.dIgValue = 0; //ig.iIgValue; billInvoice.dLastCharge = ig.nBalance; billInvoice.dLastIg = ig.iIgValue; billInvoice.dMealFee = 0; billInvoice.dServiceFee = 0; billInvoice.dSumFee = ig.nBalance; // dFee;// ig.nBalance - dReturnFee;//0;// iFillFee + iExtraFee; billInvoice.dtCreateDate = DateTime.Now; billInvoice.dTotalFee = ig.nBalance; //dFee;// ig.nBalance - dReturnFee; ;//0;// iFillFee; billInvoice.dtPrintDate = DateTime.Now; billInvoice.iBillNo = serialNo.iSerialNo; billInvoice.vcAssCardID = assCard.vcAssCardID; billInvoice.vcAssName = ass.vcAssName;//txtAssName.Text; billInvoice.vcBillType = "BI006"; billInvoice.vcEffFlag = "0"; billInvoice.vcLinkSerial = null; billInvoice.vcOperName = GlobalParams.oper.vcOperName; billInvoice.vcOperID = GlobalParams.oper.vcOperID; billInvoice.vcPrintFlag = "1"; //billInvoice.vcReserve = ""; amsContext.AddTotbBillInvoice(billInvoice); Helper.Save(amsContext); //打印帐单----------------------------------- //打印帐单----------------------------------- List <tbBillInvoice> invoice = new List <tbBillInvoice>(); invoice.Add(billInvoice); List <tbBillList> list = new List <tbBillList>(); list.Add(billList); list.Add(billList2); Helper.MyPrint(invoice, list); trans.Commit(); } } btnPrint.Enabled = false; btnCardReturn.Enabled = false; txtPwd.Enabled = true; txtPwd.Focus(); Helper.ShowInfo(this, "打印回执成功,请输入会员卡密码,进行退卡操作"); } catch (Exception ex) { billInvoice = null; ErrorLog.Write(this, ex); } }
private void btnPrint_Click(object sender, EventArgs e) { //打印回执 DbConnection conn = null; DbTransaction trans = null; try { if (ass == null || assCard == null || ig == null) { throw new Exception("请首先查询会员,并选择某个会员卡进行会员卡挂失操作"); } if (ass.vcAssState != ConstApp.AST_1) { throw new Exception("此会员未发卡无法挂失"); } if (assCard.cCardState != ConstApp.CST_1) { throw new Exception("此会员卡不在正常在用状态,无法挂失"); } using (AMSEntities amsContext = new AMSEntities()) { conn = amsContext.Connection; if (conn.State != ConnectionState.Open) { conn.Open(); } using (trans = conn.BeginTransaction(IsolationLevel.ReadCommitted)) { //事务数据操作或其它一致性操作 tbBillSerialNo serialNo = new tbBillSerialNo(); serialNo.vcFill = "0"; amsContext.AddTotbBillSerialNo(serialNo); Helper.Save(amsContext); tbBillList billList = new tbBillList(); billList.iBillNo = serialNo.iSerialNo; billList.iCount = 1; billList.iNO = 1; billList.nCharge = 0; billList.nPrice = 0; billList.nRate = 1; billList.vcGoodsName = "会员卡挂失"; //billList.vcUnit = ""; amsContext.AddTotbBillList(billList); billInvoice = new tbBillInvoice(); billInvoice.dCharge = 0;// ig.nBalance + iFillFee + iExtraFee; billInvoice.dIgGet = 0; billInvoice.dIgValue = ig.iIgValue; billInvoice.dLastCharge = ig.nBalance; billInvoice.dLastIg = ig.iIgValue; billInvoice.dMealFee = 0; billInvoice.dServiceFee = 0; billInvoice.dSumFee = 0; // iFillFee + iExtraFee; billInvoice.dtCreateDate = DateTime.Now; billInvoice.dTotalFee = 0; // iFillFee; billInvoice.dtPrintDate = DateTime.Now; billInvoice.iBillNo = serialNo.iSerialNo; billInvoice.vcAssCardID = assCard.vcAssCardID; billInvoice.vcAssName = txtAssName.Text; billInvoice.vcBillType = "BI004"; billInvoice.vcEffFlag = "0"; billInvoice.vcLinkSerial = null; billInvoice.vcOperName = GlobalParams.oper.vcOperName; billInvoice.vcOperID = GlobalParams.oper.vcOperID; billInvoice.vcPrintFlag = "1"; //billInvoice.vcReserve = ""; amsContext.AddTotbBillInvoice(billInvoice); Helper.Save(amsContext); //打印帐单----------------------------------- List <tbBillInvoice> invoice = new List <tbBillInvoice>(); invoice.Add(billInvoice); List <tbBillList> list = new List <tbBillList>(); list.Add(billList); Helper.MyPrint(invoice, list); trans.Commit(); } } Helper.ShowInfo(this, "打印回执成功,请输入会员卡密码,进行挂失操作"); } catch (Exception ex) { billInvoice = null; ErrorLog.Write(this, ex); } }
private void btnPrint_Click(object sender, EventArgs e) { DbConnection conn = null; DbTransaction trans = null; try { if (ass == null || assCard == null || ig == null) { throw new Exception("请首先读取会员卡信息!"); } int iFillFee = Convert.ToInt32(txtFillFee.Value); if (iFillFee < 1000) { throw new Exception("充值金额必须是大于1000元的整数"); } var fillProm = GlobalParams.FillProm.FirstOrDefault(f => f.iCelling > iFillFee && f.iFloor <= iFillFee); if (fillProm == null) { throw new Exception("获取优惠比率出错,请检查优惠比率配置是否正确!"); } int iExtraFee = iFillFee * fillProm.iRate / 100; txtExtraFee.Text = iExtraFee.ToString(); txtSum.Text = Convert.ToString(iFillFee + iExtraFee); if (assCard.cCardState != ConstApp.CST_1) { throw new Exception("此会员卡不在正常在用状态,无法充值"); } using (AMSEntities amsContext = new AMSEntities()) { conn = amsContext.Connection; if (conn.State != ConnectionState.Open) { conn.Open(); } using (trans = conn.BeginTransaction(IsolationLevel.ReadCommitted)) { //事务数据操作或其它一致性操作 tbBillSerialNo serialNo = new tbBillSerialNo(); serialNo.vcFill = "0"; amsContext.AddTotbBillSerialNo(serialNo); Helper.Save(amsContext); tbBillList billList1 = new tbBillList(); billList1.iBillNo = serialNo.iSerialNo;//lSerialNo; billList1.iCount = 1; billList1.iNO = 1; billList1.nCharge = Convert.ToDecimal(iFillFee); billList1.nPrice = Convert.ToDecimal(iFillFee); billList1.nRate = 1; billList1.vcGoodsName = "会员充值"; billList1.vcUnit = ""; amsContext.AddTotbBillList(billList1); tbBillList billList2 = new tbBillList(); billList2.iBillNo = serialNo.iSerialNo; billList2.iCount = 1; billList2.iNO = 2; billList2.nCharge = Convert.ToDecimal(iExtraFee); billList2.nPrice = Convert.ToDecimal(iExtraFee); billList2.nRate = 1; billList2.vcGoodsName = "赠款"; billList2.vcUnit = ""; amsContext.AddTotbBillList(billList2); billInvoice = new tbBillInvoice(); billInvoice.dCharge = ig.nBalance + iFillFee + iExtraFee; billInvoice.dIgGet = 0; billInvoice.dIgValue = ig.iIgValue; billInvoice.dLastCharge = ig.nBalance; billInvoice.dLastIg = ig.iIgValue; billInvoice.dMealFee = 0; billInvoice.dServiceFee = 0; billInvoice.dSumFee = iFillFee + iExtraFee; billInvoice.dtCreateDate = DateTime.Now; billInvoice.dTotalFee = iFillFee; billInvoice.dtPrintDate = DateTime.Now; billInvoice.iBillNo = serialNo.iSerialNo; billInvoice.vcAssCardID = assCard.vcAssCardID; billInvoice.vcAssName = txtAssName.Text; billInvoice.vcBillType = "BI002"; billInvoice.vcEffFlag = "0"; billInvoice.vcOperName = GlobalParams.oper.vcOperName; billInvoice.vcOperID = GlobalParams.oper.vcOperID; billInvoice.vcPrintFlag = "1"; amsContext.AddTotbBillInvoice(billInvoice); Helper.Save(amsContext); //打印 会员卡充值帐单------------------- //打印帐单----------------------------------- List <tbBillInvoice> invoice = new List <tbBillInvoice>(); invoice.Add(billInvoice); List <tbBillList> list = new List <tbBillList>(); list.Add(billList1); list.Add(billList2); Helper.MyPrint(invoice, list); trans.Commit(); } } Helper.ShowInfo(this, "打印回执成功"); } catch (Exception ex) { billInvoice = null; ErrorLog.Write(this, ex); } }
private void btnPrint_Click(object sender, EventArgs e) { //需要将生成的发票流水写到txtBillNo文本框中 DbConnection conn = null; DbTransaction trans = null; try { if (dgvIgEx.Rows.Count <= 0) { throw new Exception("没有任何兑换记录"); } using (AMSEntities amsContext = new AMSEntities()) { string strAssCardID = txtCardID.Text.Trim(); int strAssID = int.Parse(txtAssID.Text.Trim()); decimal deTolIg = decimal.Parse(txtIgSum.Text.Trim()); tbIntegral intg1 = amsContext.tbIntegral.FirstOrDefault(ig => ig.iAssID == strAssID && ig.vcAssCardID == strAssCardID); if (intg1 == null) { throw new Exception("会员余额积分异常!"); } if (intg1.iIgValue < deTolIg) { throw new Exception("当前积分余额不足,请重新刷卡后再试!"); } conn = amsContext.Connection; if (conn.State != ConnectionState.Open) { conn.Open(); } using (trans = conn.BeginTransaction(IsolationLevel.ReadCommitted)) { //事务数据操作或其它一致性操作 tbBillSerialNo serialNo = new tbBillSerialNo(); serialNo.vcFill = "0"; amsContext.AddTotbBillSerialNo(serialNo); Helper.Save(amsContext); List <tbBillList> list = new List <tbBillList>(); DataTable dtIgList = (DataTable)dgvIgEx.DataSource; for (int i = 0; i < dtIgList.Rows.Count; i++) { tbBillList billList = new tbBillList(); billList.iBillNo = serialNo.iSerialNo;//lSerialNo; billList.iNO = i + 1; billList.vcGoodsName = dtIgList.Rows[i]["积分兑换项目"].ToString(); billList.iCount = 1; billList.vcUnit = ""; billList.nPrice = decimal.Parse(dtIgList.Rows[i]["兑换分值"].ToString()); billList.nRate = 1; billList.nCharge = decimal.Parse(dtIgList.Rows[i]["兑换分值"].ToString()); amsContext.AddTotbBillList(billList); list.Add(billList); } DateTime dtoperdate = DateTime.Now; tbBillInvoice billInvoice = new tbBillInvoice(); billInvoice.iBillNo = serialNo.iSerialNo; billInvoice.vcAssName = txtAssName.Text.Trim(); billInvoice.vcAssCardID = strAssCardID; billInvoice.dtCreateDate = dtoperdate; billInvoice.dtPrintDate = dtoperdate; billInvoice.dLastCharge = intg1.nBalance; billInvoice.dLastIg = intg1.iIgValue; billInvoice.vcOperID = GlobalParams.oper.vcOperID; billInvoice.vcOperName = GlobalParams.oper.vcOperName; billInvoice.dSumFee = deTolIg; billInvoice.dServiceFee = 0; billInvoice.dMealFee = 0; billInvoice.dTotalFee = deTolIg; billInvoice.dCharge = intg1.nBalance; billInvoice.dIgValue = (decimal)intg1.iIgValue - deTolIg; billInvoice.dIgGet = -deTolIg; billInvoice.vcPrintFlag = "1"; billInvoice.vcBillType = "BI003"; billInvoice.vcEffFlag = "0"; amsContext.AddTotbBillInvoice(billInvoice); Helper.Save(amsContext); List <tbBillInvoice> invoice = new List <tbBillInvoice>(); invoice.Add(billInvoice); Helper.MyPrint(invoice, list); trans.Commit(); txtBillNo.Text = serialNo.iSerialNo.ToString(); } } cmbIgEXGoods.Enabled = false; txtComments.Enabled = false; btnAdd.Enabled = false; btnDel.Enabled = false; btnPrint.Enabled = false; btnRead.Enabled = false; btnExOk.Enabled = true; Helper.ShowInfo(this, "打印回执成功"); } catch (Exception ex) { ErrorLog.Write(this, ex, "打印异常"); } }