using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DBUtility { public class ClsGy_Base_Ctl { public string MvarItemKey; public string MvarReportTitle; public Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper(); //新增 public virtual bool AddNew() { return true; } //修改 public virtual bool ModifyByID(Int64 sItemID) { return true; } #region 固定代码 //是否存在子项目 public bool HavChildCodes(Int64 sItemID) { DataSet DS; try { DS = oCn.RunProcReturn("Select HItemID from " + MvarItemKey + " Where HParentID='" + sItemID + "'", MvarItemKey , ref Pub_Class.ClsPub.sExeReturnInfo); if (DS.Tables[0].Rows.Count == 0) return false; else { return true; } } catch (Exception e) { throw (e); } } //根据代码判断信息 public virtual bool HavParentCode(string sCode, Int64 sItemID) { return true; } //重复代码 public bool HavSameNumber(Int64 sItemID, string sNumber) { DataSet DS; try { DS = oCn.RunProcReturn("Select HItemID from " + MvarItemKey + " Where HItemID<>" + sItemID + " and HNumber='" + sNumber + "'", MvarItemKey, ref Pub_Class.ClsPub.sExeReturnInfo); if (DS.Tables[0].Rows.Count == 0) return false; else { return true; } } catch (Exception e) { throw (e); } } //审核 public bool AuditByID(Int64 sItemID, ref string sReturn) { try { string HCheckEmp = ClsPub.CurUserName; oCn.RunProc("Update " + MvarItemKey + " set HCheckEmp = '" + HCheckEmp + "',HCheckDate=getdate() where HItemID='" + sItemID + "'", ref Pub_Class.ClsPub.sExeReturnInfo); sReturn = ""; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } //反审核 public bool DeAuditByID(Int64 sItemID, ref string sReturn) { try { oCn.RunProc("Update " + MvarItemKey + " set HCheckEmp = '', HCheckDate=null where HItemID='" + sItemID + "'", ref Pub_Class.ClsPub.sExeReturnInfo); sReturn = ""; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } //禁用 public bool StopByID(Int64 sItemID) { try { oCn.RunProc("Update " + MvarItemKey + " set HStopflag=1 where HItemID='" + sItemID + "'", ref Pub_Class.ClsPub.sExeReturnInfo); return true; } catch (Exception e) { throw (e); } } //反禁用 public bool UnStopByID(Int64 sItemID) { try { oCn.RunProc("Update " + MvarItemKey + " set HStopflag=0 where HItemID='" + sItemID + "'", ref Pub_Class.ClsPub.sExeReturnInfo); return true; } catch (Exception e) { throw (e); } } //关闭 public bool CloseByID(Int64 sItemID, ref string sReturn) { try { string HCloseEmp = ClsPub.CurUserName; oCn.RunProc("Update " + MvarItemKey + " set HCloseEmp = '" + HCloseEmp + "',HCloseDate=getdate() where HItemID='" + sItemID + "'", ref Pub_Class.ClsPub.sExeReturnInfo); sReturn = ""; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } //反关闭 public bool DeCloseByID(Int64 sItemID, ref string sReturn) { try { oCn.RunProc("Update " + MvarItemKey + " set HCloseEmp = '', HCloseDate=null where HItemID='" + sItemID + "'", ref Pub_Class.ClsPub.sExeReturnInfo); sReturn = ""; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } //审核2 HCheckTime public bool AuditByID2(Int64 sItemID, ref string sReturn) { try { string HCheckEmp = ClsPub.CurUserName; oCn.RunProc("Update " + MvarItemKey + " set HCheckEmp = '" + HCheckEmp + "',HCheckTime=getdate() where HItemID='" + sItemID + "'", ref Pub_Class.ClsPub.sExeReturnInfo); sReturn = ""; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } //反审核2 HCheckTime public bool DeAuditByID2(Int64 sItemID, ref string sReturn) { try { oCn.RunProc("Update " + MvarItemKey + " set HCheckEmp = '', HCheckTime=null where HItemID='" + sItemID + "'", ref Pub_Class.ClsPub.sExeReturnInfo); sReturn = ""; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } //关闭2 HCloseTime public bool CloseByID2(Int64 sItemID, ref string sReturn) { try { string HCloseEmp = ClsPub.CurUserName; oCn.RunProc("Update " + MvarItemKey + " set HCloseEmp = '" + HCloseEmp + "',HCloseTime=getdate() where HItemID='" + sItemID + "'", ref Pub_Class.ClsPub.sExeReturnInfo); sReturn = ""; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } //反关闭2 HCloseTime public bool DeCloseByID2(Int64 sItemID, ref string sReturn) { try { oCn.RunProc("Update " + MvarItemKey + " set HCloseEmp = '', HCloseTime=null where HItemID='" + sItemID + "'", ref Pub_Class.ClsPub.sExeReturnInfo); sReturn = ""; return true; } catch (Exception e) { sReturn = e.Message; throw (e); } } //删除 public bool DeleteByID(Int64 sItemID) { try { oCn.RunProc("Delete from " + MvarItemKey + " where HItemID='" + sItemID + "'", ref Pub_Class.ClsPub.sExeReturnInfo); return true; } catch (Exception e) { throw (e); } } //删除 public bool DeleteByNumber(string sNumber) { try { oCn.RunProc("Delete from " + MvarItemKey + " where HNumber='" + sNumber + "'", ref Pub_Class.ClsPub.sExeReturnInfo); return true; } catch (Exception e) { throw (e); } } /// /// 审核 /// /// 内码 /// 操作人 /// public bool CheckByHItemID(Int64 HItemID, string HMaker, ref string sReturn) { try { DataSet DS = oCn.RunProcReturn("select * from " + MvarItemKey + " where HItemID='" + HItemID + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo); if (DS.Tables[0].Rows.Count == 0) { sReturn = "未查询到任何数据,请刷新数据后重新选择!"; return false; } else { if (DS.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") { sReturn = "单据已审核,不允许重复审核!"; return false; } //审核 oCn.BeginTran(); oCn.RunProc("Update " + MvarItemKey + " set HCheckEmp = '" + HMaker + "',HCheckTime=getdate() where HItemID=" + HItemID, ref Pub_Class.ClsPub.sExeReturnInfo); //写入日志 DBUtility.ClsPub.Add_Log("", MvarReportTitle+ "审核,代码:" + DS.Tables[0].Rows[0]["HNumber"].ToString() + ",名称:" + DS.Tables[0].Rows[0]["HName"].ToString(), HMaker); sReturn = ""; oCn.Commit(); return true; } } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); throw (e); } } /// /// 反审核 /// /// 内码 /// 操作人 /// public bool AbandonCheckByHItemID(Int64 HItemID, string HMaker, ref string sReturn) { try { DataSet DS = oCn.RunProcReturn("select * from " + MvarItemKey + " where HItemID='" + HItemID + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo); if (DS.Tables[0].Rows.Count == 0) { sReturn = "未查询到任何数据,请刷新数据后重新选择!"; return false; } else { if (DS.Tables[0].Rows[0]["HCheckEmp"].ToString() == "") { sReturn = "单据未审核,不允许反审核!"; return false; } //反审核 oCn.BeginTran(); oCn.RunProc("Update " + MvarItemKey + " set HCheckEmp = '',HCheckTime=null where HItemID=" + HItemID, ref Pub_Class.ClsPub.sExeReturnInfo); //写入日志 DBUtility.ClsPub.Add_Log("", MvarReportTitle + "反审核,代码:" + DS.Tables[0].Rows[0]["HNumber"].ToString() + ",名称:" + DS.Tables[0].Rows[0]["HName"].ToString(), HMaker); sReturn = ""; oCn.Commit(); return true; } } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); throw (e); } } /// /// 禁用 /// /// 内码 /// 操作人 /// public bool StopByHItemID(Int64 HItemID, string HMaker, ref string sReturn) { try { DataSet DS = oCn.RunProcReturn("select * from " + MvarItemKey + " where HItemID='" + HItemID + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo); if (DS.Tables[0].Rows.Count == 0) { sReturn = "未查询到任何数据,请刷新数据后重新选择!"; return false; } else { if (DS.Tables[0].Rows[0]["HStopEmp"].ToString() != "") { sReturn = "单据已禁用,不允许重复禁用!"; return false; } DataSet DsHavChildCodes = oCn.RunProcReturn("select HItemID from " + MvarItemKey + " where HStopflag=0 and HParentID='" + HItemID + "'", MvarItemKey, ref Pub_Class.ClsPub.sExeReturnInfo); if (DsHavChildCodes.Tables[0].Rows.Count > 0) { sReturn = "所选单据存在未禁用的子项目,不允许禁用!"; return false; } //禁用 oCn.BeginTran(); oCn.RunProc("Update " + MvarItemKey + " set HStopflag=1,HStopEmp = '" + HMaker + "',HStopTime=getdate() where HItemID=" + HItemID, ref Pub_Class.ClsPub.sExeReturnInfo); //写入日志 DBUtility.ClsPub.Add_Log("", MvarReportTitle + "禁用,代码:" + DS.Tables[0].Rows[0]["HNumber"].ToString() + ",名称:" + DS.Tables[0].Rows[0]["HName"].ToString(), HMaker); sReturn = ""; oCn.Commit(); return true; } } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); throw (e); } } /// /// 反禁用 /// /// 内码 /// 操作人 /// public bool AbandonStopByHItemID(Int64 HItemID, string HMaker, ref string sReturn) { try { DataSet DS = oCn.RunProcReturn("select * from " + MvarItemKey + " where HItemID='" + HItemID + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo); if (DS.Tables[0].Rows.Count == 0) { sReturn = "未查询到任何数据,请刷新数据后重新选择!"; return false; } else { if (DS.Tables[0].Rows[0]["HStopEmp"].ToString() == "") { sReturn = "单据未禁用,不允许反禁用!"; return false; } DataSet DsHavChildCodes = oCn.RunProcReturn("select HItemID from " + MvarItemKey + " where HStopflag=1 and HItemID='" + DS.Tables[0].Rows[0]["HParentID"].ToString() + "'", MvarItemKey, ref Pub_Class.ClsPub.sExeReturnInfo); if (DsHavChildCodes.Tables[0].Rows.Count > 0) { sReturn = "所选单据上级项目已禁用,不允许反禁用!"; return false; } //禁用 oCn.BeginTran(); oCn.RunProc("Update " + MvarItemKey + " set HStopflag=0,HStopEmp = '',HStopTime=null where HItemID=" + HItemID, ref Pub_Class.ClsPub.sExeReturnInfo); //写入日志 DBUtility.ClsPub.Add_Log("", MvarReportTitle + "反禁用,代码:" + DS.Tables[0].Rows[0]["HNumber"].ToString() + ",名称:" + DS.Tables[0].Rows[0]["HName"].ToString(), HMaker); sReturn = ""; oCn.Commit(); return true; } } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); throw (e); } } #endregion } }