/// <summary> /// 添加需重新打印的单据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { if (txtBill_ID.Text == string.Empty) { MessageDialog.ShowPromptMessage("请填写单据号!"); return; } if (txtPrintRemark.Text == string.Empty) { MessageDialog.ShowPromptMessage("请填写重打原因!"); return; } DataTable dt = m_serverPrintManagement.GetPrintBillTableByDJH(txtBill_ID.Text); if (dt.Rows.Count > 0) { S_AgainPrintBillTable againprint = new S_AgainPrintBillTable(); againprint.Bill_ID = txtBill_ID.Text; againprint.PrintPersonnelCode = BasicInfo.LoginID; againprint.PrintPersonnelName = BasicInfo.LoginName; againprint.PrintPersonnelDepartment = BasicInfo.DeptName; againprint.PrintDateTime = ServerTime.Time; againprint.Remark = txtPrintRemark.Text; bool b = m_serverPrintManagement.Add_S_AgainPrintBillTable(againprint, out m_strErr); if (b) { MessageBox.Show("提交成功!等待主管审核"); Flow_BillFlowMessage msg = m_billFlowMsg.GetMessage(BasicInfo.LoginID, labelTitle.Text, txtBill_ID.Text); if (msg != null) { m_billFlowMsg.DestroyMessage(BasicInfo.LoginID, msg.序号); } SendNewFlowMessage(txtBill_ID.Text); } else { MessageDialog.ShowErrorMessage(m_strErr); } } else { MessageDialog.ShowErrorMessage("单据号不正确 或 此单据号还没有打印过!"); } }
/// <summary> /// 批准后修改打印状态 /// </summary> /// <param name="DJH">单据号</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns></returns> public bool UpdateAuthorize(string ID, out string error) { try { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var billGather = from b in dataContxt.S_AgainPrintBillTable where b.ID == int.Parse(ID) select b; if (billGather.Count() != 1) { return(false); } else { S_AgainPrintBillTable Again = billGather.Single(); if (Again.CheckFlag) { if (Again.Authorize) { error = Again.AuthorizeMan + " 在 " + Again.AuthorizeTime + " 已经批准!"; return(false); } else { Again.Authorize = true; Again.AuthorizeMan = BasicInfo.LoginName; Again.AuthorizeTime = ServerTime.Time; Again.PrintFlag = false; dataContxt.SubmitChanges(); return(true); } } else { error = "请等待审核后再进行此操作!"; return(false); } } } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 审核后修改打印状态 /// </summary> /// <param name="ID">数据行ID</param> /// <param name="error">如果返回值为假,则输出错误信息</param> /// <returns>操作是否成功的标志</returns> public bool UpdateAgainPrintBillTable(string ID, out string error) { try { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from b in dataContxt.S_AgainPrintBillTable where b.ID == int.Parse(ID) select b; if (result.Count() != 1) { return(false); } else { S_AgainPrintBillTable billGather = result.Single(); if (billGather.CheckFlag) { error = billGather.CheckMan + "在 " + billGather.CheckTime + " 已经审核!"; return(false); } else { billGather.CheckFlag = true; billGather.CheckMan = BasicInfo.LoginName; billGather.CheckTime = ServerTime.Time; dataContxt.SubmitChanges(); return(true); } } } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 添加重新打印的单据 /// </summary> /// <param name="billID">单据号</param> /// <param name="billName">单据名</param> /// <param name="printPersonnelCode">打印人编码</param> /// <param name="printPersonnelName">打印人姓名</param> /// <param name="printPersonnelDepartment">打印部门</param> /// <param name="printDateTime">打印时间</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns></returns> public bool Add_S_AgainPrintBillTable(S_AgainPrintBillTable againprint, out string error) { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from r in dataContxt.S_AgainPrintBillTable where r.Bill_ID == againprint.Bill_ID && !r.PrintFlag select r; if (result.Count() > 0) { error = string.Format("【{0}】单据已经存在一个未完成的申请。", againprint.Bill_ID); return(false); } S_AgainPrintBillTable tablePrintBill = new S_AgainPrintBillTable(); tablePrintBill.Bill_ID = againprint.Bill_ID; tablePrintBill.PrintPersonnelCode = againprint.PrintPersonnelCode; tablePrintBill.PrintPersonnelName = againprint.PrintPersonnelName; tablePrintBill.PrintPersonnelDepartment = againprint.PrintPersonnelDepartment; tablePrintBill.PrintDateTime = againprint.PrintDateTime; tablePrintBill.Remark = againprint.Remark; tablePrintBill.CheckFlag = false; tablePrintBill.Authorize = false; tablePrintBill.PrintFlag = false; try { dataContxt.S_AgainPrintBillTable.InsertOnSubmit(tablePrintBill); dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <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); } }