/// <summary> /// 添加打印日志 /// </summary> /// <returns></returns> private bool AddPrintInfoLog(DepotManagementDataContext dataContext, S_PrintBillTable printInfo, out string error) { error = null; try { S_PrintBillTableLog lnqLog = new S_PrintBillTableLog(); lnqLog.Bill_ID = printInfo.Bill_ID; lnqLog.Bill_Name = printInfo.Bill_Name; lnqLog.CheckFlag = printInfo.CheckFlag; lnqLog.PrintDateTime = printInfo.PrintDateTime; lnqLog.PrintFlag = printInfo.PrintFlag; lnqLog.PrintPersonnelCode = printInfo.PrintPersonnelCode; lnqLog.PrintPersonnelDepartment = printInfo.PrintPersonnelDepartment; lnqLog.PrintPersonnelName = printInfo.PrintPersonnelName; dataContext.S_PrintBillTableLog.InsertOnSubmit(lnqLog); } catch (Exception ex) { error = ex.Message; return(false); } return(true); }
private void reportViewer1_Print(object sender, CancelEventArgs e) { if (VirtualPrint.IsVirtualPrint(out m_err)) { e.Cancel = true; MessageDialog.ShowPromptMessage(m_err); } else { IPrintManagement printManagement = BasicServerFactory.GetServerModule <IPrintManagement>(); S_PrintBillTable printInfo = new S_PrintBillTable(); printInfo.Bill_ID = m_billID; printInfo.Bill_Name = m_billName; printInfo.PrintDateTime = ServerModule.ServerTime.Time; printInfo.PrintFlag = true; printInfo.PrintPersonnelCode = BasicInfo.LoginID; printInfo.PrintPersonnelName = BasicInfo.LoginName; printInfo.PrintPersonnelDepartment = BasicInfo.DeptName; if (printManagement.IsExist(printInfo, out m_err)) { MessageDialog.ShowPromptMessage(m_err); } else if (!printManagement.AddPrintInfo(printInfo, out m_err)) { MessageDialog.ShowPromptMessage(m_err); } reportViewer1.ShowPrintButton = false; } }
/// <summary> /// 修改审核状态 /// </summary> /// <param name="dt"></param> /// <param name="m_err"></param> /// <returns></returns> public bool SetChecked(DataTable dt, bool blZT, out string m_err) { m_err = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; try { for (int i = 0; i < dt.Rows.Count; i++) { var varData = from a in dataContxt.S_PrintBillTable where a.Bill_ID == dt.Rows[i][0].ToString() select a; S_PrintBillTable lnqPrintBill = varData.Single(); lnqPrintBill.CheckFlag = blZT; } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { m_err = ex.Message; return(false); } }
/// <summary> /// 检查单据是否已经完成打印 /// </summary> /// <param name="printInfo">打印信息</param> /// <param name="message">输出的消息</param> /// <returns>已经打印返回true</returns> public bool IsExist(S_PrintBillTable printInfo, out string message) { message = null; //DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; //var billGather = from c in dataContxt.S_PrintBillTable // where c.Bill_ID == printInfo.Bill_ID && c.Bill_Name == printInfo.Bill_Name // select c; //if (billGather.Count() > 0) //{ // var print = from b in dataContxt.S_AgainPrintBillTable // where b.Bill_ID == printInfo.Bill_ID && !b.PrintFlag && b.Authorize // select b; // if (print.Count() != 1) // { // message = ""; // foreach (var ei in billGather) // { // message += "系统不支持单据的重复打印,该单据已于[" + ei.PrintDateTime + "]日,由[" + ei.PrintPersonnelDepartment + "][" + ei.PrintPersonnelName + "]打印!"; // } // return true; // } //} return(false); }
/// <summary> /// 构造函数 /// </summary> /// <param name="pageWidth">打印页宽度, 以厘米为单位</param> /// <param name="pageHeight">打印页高度, 以厘米为单位</param> /// <param name="billReportInfo">单据类报表信息</param> public PrintReportBill(double pageWidth, double pageHeight, IBillReportInfo billReportInfo) { m_pageWidth = pageWidth; m_pageHeight = pageHeight; m_billReportInfo = billReportInfo; IPrintManagement printManagement = BasicServerFactory.GetServerModule <IPrintManagement>(); S_PrintBillTable printInfo = new S_PrintBillTable(); printInfo.Bill_ID = billReportInfo.BillNo; printInfo.Bill_Name = billReportInfo.BillType; printInfo.PrintDateTime = ServerModule.ServerTime.Time; printInfo.PrintFlag = true; printInfo.PrintPersonnelCode = BasicInfo.LoginID; printInfo.PrintPersonnelName = BasicInfo.LoginName; printInfo.PrintPersonnelDepartment = BasicInfo.DeptName; if (billReportInfo.BillType != "") { if (!printManagement.AddPrintInfo(printInfo, out m_err)) { m_allowPrint = false; MessageDialog.ShowPromptMessage(m_err); } } }
/// <summary> /// 删除原有的打印的报表/单据记录 /// </summary> /// <param name="dataContext"></param> /// <param name="printInfo"></param> /// <param name="error"></param> /// <returns></returns> private bool DeletePrintInfo(DepotManagementDataContext dataContext, S_PrintBillTable printInfo, out string error) { error = null; try { var varData = from a in dataContext.S_PrintBillTable where a.Bill_ID == printInfo.Bill_ID select a; dataContext.S_PrintBillTable.DeleteAllOnSubmit(varData); } catch (Exception ex) { error = ex.Message; return(false); } return(true); }
/// <summary> /// 添加完成打印的报表/单据 /// </summary> /// <param name="printInfo">打印信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作是否成功的标志</returns> public bool AddPrintInfo(S_PrintBillTable printInfo, out string error) { error = null; if (BasicInfo.LoginID == "0417") { return(true); } if (IsExist(printInfo, out error)) { return(false); } DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; dataContxt.Connection.Open(); dataContxt.Transaction = dataContxt.Connection.BeginTransaction(); try { var print = from b in dataContxt.S_AgainPrintBillTable where b.Bill_ID == printInfo.Bill_ID && !b.PrintFlag && b.Authorize select b; if (print.Count() == 1) { S_AgainPrintBillTable table = print.Single(); table.PrintFlag = true; } else if (print.Count() > 1) { error = "数据不唯一"; return(false); } //删除记录 if (!DeletePrintInfo(dataContxt, printInfo, out error)) { return(false); } dataContxt.SubmitChanges(); //添加打印日志 if (!AddPrintInfoLog(dataContxt, printInfo, out error)) { return(false); } dataContxt.S_PrintBillTable.InsertOnSubmit(printInfo); dataContxt.SubmitChanges(); dataContxt.Transaction.Commit(); return(true); } catch (Exception exce) { dataContxt.Transaction.Rollback(); error = exce.Message; return(false); } }