private void ShowDqfp() { try { EmptyFP dqfp = handler.GetFPH(InstanceForm.BCurrentUser.EmployeeId); lblFPH.Text = dqfp.Qz + dqfp.Fph; } catch (Exception err) { lblFPH.Text = "<无可用票据>"; btnPrint.Visible = false; } }
private void btnPrint_Click(object sender, EventArgs e) { if (dgvFpjl.DataSource == null) { MessageBox.Show("请先查询要补打的记录", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string _dnlsh = this.dgvFpjl.CurrentRow.Cells["COL_DNLSH"].Value.ToString(); if (!string.IsNullOrEmpty(_dnlsh)) { string sqlString = string.Format(@"select bqxghbz from mz_ghxx where dnlxh = '{0}'", _dnlsh); DataTable _dataTable = InstanceForm.BDatabase.GetDataTable(sqlString); if (_dataTable.Rows.Count > 0) { string _bqxghbz = _dataTable.Rows[0]["bqxghbz"].ToString(); int _out = 0; if (Int32.TryParse(_bqxghbz, out _out)) { if (_out == 1) { MessageBox.Show(string.Format("当前选中的电脑流水号为:[{0}]的挂号记录已退费", _dnlsh), "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } } DataTable tb = (DataTable)dgvFpjl.DataSource; DataRow[] drsFpjl = tb.Select("SELECTED=1 and JLZT=0"); if (drsFpjl.Length == 0) { MessageBox.Show("没有选择需要补打的记录", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string dysj = DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase).ToString("yyyy-MM-dd HH:mm:ss"); groupBox1.Enabled = false; this.Cursor = TrasenClasses.GeneralClasses.PubStaticFun.WaitCursor(); int sjly = 0; if (rdLS.Checked) { sjly = 1; } try { for (int i = 0; i < drsFpjl.Length; i++) { Guid fpid = new Guid(drsFpjl[i]["FPID"].ToString().Trim()); int lx = Convert.ToInt32(drsFpjl[i]["LX"]); //后台查询发票记录,以防止同时操作 DataRow drFpxx = handler.SelectFpxx(lx, "", fpid, sjly); //Fun.DebugView(drFpxx.Table); if (Convertor.IsNull(drFpxx["发票号"], "0") != "0" && Convertor.IsNull(drFpxx["发票号"], "") != "") { throw new Exception("该记录已经打印过发票,不能补打"); } //if (InstanceForm.BCurrentUser.Name.ToString() != drFpxx["收费员"].ToString()) // throw new Exception("非本人票,不能补打"); TimeSpan ts = Convert.ToDateTime(dysj) - Convert.ToDateTime(drFpxx["收费日期"]); double dHours = Math.Round(ts.TotalHours); //if (dHours <= Convert.ToDouble(cfg1172.Config)) // throw new Exception("发票打印时间太久,不能补打"); try { //获得可用发票 EmptyFP emptyfp = handler.GetFPH(InstanceForm.BCurrentUser.EmployeeId); try { //打印 handler.Print(drFpxx, emptyfp, dysj); } catch (Exception error) { MessageBox.Show("打印过程中发生错误:" + Environment.NewLine + error.Message + Environment.NewLine + error.StackTrace, "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception err) { if (MessageBox.Show("获取可用发票发生错误:" + err.Message + Environment.NewLine + err.StackTrace + Environment.NewLine + "是否继续打印?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } } btnCX_Click(null, null); } catch (Exception error) { MessageBox.Show(error.Message + Environment.NewLine + error.StackTrace, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { groupBox1.Enabled = true; ShowDqfp(); this.Cursor = Cursors.Default; } }