/// <summary> /// 结算 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BarButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (gridView1.RowCount == 0) { MessageBox.Show("没选择项目!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ///检查是否有价格为0 的项目 for (int i = 0; i < gridView1.RowCount; i++) { if (Convert.ToDecimal(gridView1.GetRowCellValue(i, "PRICE")) <= 0) { MessageBox.Show("尚有未输入价格的项目!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); gridView1.SelectRow(i); return; } } string s_cuname; if (string.IsNullOrEmpty(textEdit1.Text)) { textEdit1.ErrorImageOptions.Alignment = ErrorIconAlignment.MiddleRight; textEdit1.ErrorText = "请输入交款单位!"; return; } else { s_cuname = textEdit1.EditValue.ToString(); } List <string> itemId_List = new List <string>(); List <string> itemType_List = new List <string>(); List <decimal> prict_List = new List <decimal>(); List <decimal> nums_List = new List <decimal>(); for (int i = 0; i < gridView1.RowCount; i++) { itemId_List.Add(gridView1.GetRowCellValue(i, "SA004").ToString()); itemType_List.Add(gridView1.GetRowCellValue(i, "SA002").ToString()); prict_List.Add(decimal.Parse(gridView1.GetRowCellValue(i, "PRICE").ToString())); nums_List.Add(decimal.Parse(gridView1.GetRowCellValue(i, "NUMS").ToString())); } string settleId = Tools.GetEntityPK("FA01"); int re = FireAction.TempSalesSettle( s_cuname, settleId, itemId_List.ToArray(), itemType_List.ToArray(), prict_List.ToArray(), nums_List.ToArray(), Envior.cur_userId); if (re > 0) { if (MessageBox.Show("办理成功!现在打印【发票】吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { if (!Envior.canInvoice) { MessageBox.Show("当前用户没有打印发票权限!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } if (!Envior.TAX_READY) { MessageBox.Show("金税卡没有打开!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { Frm_taxClientInfo frm_client = new Frm_taxClientInfo(); frm_client.swapdata["parent"] = Envior.mform; frm_client.swapdata["title"] = textEdit1.Text; if (frm_client.ShowDialog(Envior.mform) == DialogResult.OK) { InvoiceInfo invClient = Envior.mform.swapdata["clientinfo"] as InvoiceInfo; //打印发票 //PrtServAction.Print_Fireinvoice(settleId, invClient, Envior.mform.Handle.ToInt32()); PrtServAction.Print_Invoice(settleId, invClient); } frm_client.Dispose(); } } //打印付货单 int jp_row = gridView1.LocateByValue("SA002", "12"); // //如果有祭品 则打印付货单 if (jp_row >= 0) { //打印火化证明 if (MessageBox.Show("现在打印【付货单】吗?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { PrtServAction.Print_FHD(settleId, this.Handle.ToInt32()); } } textEdit1.Text = ""; sa01_ds.Sa01.Rows.Clear(); } }
/// <summary> /// 结算 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem18_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!SaveCheck()) { return; } string s_tip = string.Empty; if (dec_fin > 0 && dec_tax > 0) { s_tip = "本次结算共需要一张财政发票和一张税务发票,是否继续?"; } else if (dec_fin > 0) { s_tip = "本次结算共需要一张财政发票,是否继续?"; } else if (dec_tax > 0) { s_tip = "本次结算共需要一张税务发票,是否继续?"; } else { return; } if (XtraMessageBox.Show(s_tip, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } string s_cuname = be_cuname.EditValue.ToString(); //交款人(或单位) StringBuilder sb_memo = new StringBuilder(50); List <string> itemId_List = new List <string>(); List <string> itemType_List = new List <string>(); List <decimal> prict_List = new List <decimal>(); List <decimal> nums_List = new List <decimal>(); for (int i = 0; i < gridView1.RowCount; i++) { itemId_List.Add(gridView1.GetRowCellValue(i, "SA004").ToString()); itemType_List.Add(gridView1.GetRowCellValue(i, "SA002").ToString()); prict_List.Add(decimal.Parse(gridView1.GetRowCellValue(i, "PRICE").ToString())); nums_List.Add(decimal.Parse(gridView1.GetRowCellValue(i, "NUMS").ToString())); ///添加备注....... if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("花圈一天") >= 0) { sb_memo.Append(gridView1.GetRowCellValue(i, "SA003").ToString() + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("花圈二天") >= 0) { sb_memo.Append(gridView1.GetRowCellValue(i, "SA003").ToString() + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("花圈三天") >= 0) { sb_memo.Append(gridView1.GetRowCellValue(i, "SA003").ToString() + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("花圈四天") >= 0) { sb_memo.Append(gridView1.GetRowCellValue(i, "SA003").ToString() + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("一次性绢花A") >= 0) { sb_memo.Append(gridView1.GetRowCellValue(i, "SA003").ToString() + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("一次性绢花B") >= 0) { sb_memo.Append(gridView1.GetRowCellValue(i, "SA003").ToString() + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("鲜花盆A") >= 0) { sb_memo.Append(gridView1.GetRowCellValue(i, "SA003").ToString() + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("鲜花盆") >= 0) { sb_memo.Append(gridView1.GetRowCellValue(i, "SA003").ToString() + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("遗像A") >= 0) { sb_memo.Append(gridView1.GetRowCellValue(i, "SA003").ToString() + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("礼兵礼仪抬尸") >= 0) { sb_memo.Append("礼兵礼仪抬尸" + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("现场乐曲") >= 0) { sb_memo.Append("现场乐曲" + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("现场歌手演唱") >= 0) { sb_memo.Append("现场歌手演唱" + " "); } else if (gridView1.GetRowCellValue(i, "SA003").ToString().IndexOf("鲜花告别") >= 0) { sb_memo.Append("鲜花告别" + " "); } } string s_fa001 = Tools.GetEntityPK("FA01"); int re = FireAction.TempSalesSettle( s_cuname, s_fa001, itemId_List.ToArray(), itemType_List.ToArray(), prict_List.ToArray(), nums_List.ToArray(), Envior.cur_userId, sb_memo.ToString()); //如果保存失败,则退出处理 if (re < 0) { return; } //清理数据 business_ds.Sa01.Rows.Clear(); be_cuname.Text = ""; te_fin_sum.Text = ""; te_tax_sum.Text = ""; XtraMessageBox.Show("结算成功!现在开始开具发票!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ////开财政票! if (dec_fin > 0) { if (FinInvoice.GetCurrentPh() > 0) { if (XtraMessageBox.Show("下一张财政发票号码:" + Envior.FIN_NEXT_BILL_NO + ",是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { FinInvoice.Invoice(s_fa001); } } } //// 开税票 if (dec_tax > 0) { //获取税务客户信息 Frm_TaxClientInfo frm_taxClient = null; if (tu01 == null) { frm_taxClient = new Frm_TaxClientInfo(s_cuname); } else { frm_taxClient = new Frm_TaxClientInfo(tu01); } if (frm_taxClient.ShowDialog() != DialogResult.OK) { tu01 = null; return; } TaxClientInfo clientInfo = frm_taxClient.swapdata["taxclientinfo"] as TaxClientInfo; if (TaxInvoice.GetNextInvoiceNo() < 0) { tu01 = null; return; //获取票据号失败,则退出!!! } if (XtraMessageBox.Show("下一张税票代码:" + Envior.NEXT_BILL_CODE + "\r\n" + "票号:" + Envior.NEXT_BILL_NUM + ",是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { TaxInvoice.Invoice(s_fa001, clientInfo); } //////////// 保存客户信息 /////////////// Tu01_dao tu01_dao = new Tu01_dao(); if (tu01 != null) { tu01.tu003 = clientInfo.InfoClientName; tu01.tu005 = clientInfo.InfoClientTaxCode; tu01.tu006 = clientInfo.infoclientaddressphone; tu01.tu007 = clientInfo.infoclientbankaccount; tu01_dao.Update(tu01); } else if (clientInfo.InfoClientName.Length >= 5) { tu01 = new Tu01(); tu01.tu001 = Tools.GetEntityPK("TU01"); tu01.tu003 = clientInfo.InfoClientName; tu01.tu005 = clientInfo.InfoClientTaxCode; tu01.tu006 = clientInfo.infoclientaddressphone; tu01.tu007 = clientInfo.infoclientbankaccount; tu01_dao.Insert(tu01); } tu01 = null; } }