| using System; | 
| using System.Collections.Generic; | 
| using System.Text; | 
| using System.Data; | 
|   | 
| namespace DAL | 
| { | 
|     public class ClsSc_ICMOBillStatus_Tmp : DBUtility.ClsXt_BaseBill  | 
|     { | 
|         //Éú²ú״̬ÁÙʱ±í | 
|         public Model.ClsSc_ICMOBillStatus_Tmp omodel = new Model.ClsSc_ICMOBillStatus_Tmp();  | 
|   | 
|         public ClsSc_ICMOBillStatus_Tmp() | 
|         { | 
|             base.MvarItemKeySub = ""; | 
|             base.MvarItemKeySub2 = ""; | 
|             base.MvarItemKeySub3 = ""; | 
|             base.MvarItemKeySub4 = ""; | 
|             base.MvarItemKey = "Sc_ICMOBillStatus_Tmp"; | 
|             base.MvarReportTitle="Éú²ú״̬ÁÙʱ±í"; | 
|             base.BillType = "3722";  | 
|         } | 
|   | 
|         #region ¹Ì¶¨´úÂë | 
|   | 
|         ~ClsSc_ICMOBillStatus_Tmp() | 
|         {  | 
|         } | 
|         | 
|         #endregion   ×Ô¶¨Òå·½·¨ | 
|         //Ð޸ĵ¥¾Ý | 
|         public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 // | 
|                 oCn.BeginTran(); | 
|                 //¸üÐÂÖ÷±í | 
|                 oCn.RunProc("UpDate Sc_ICMOBillStatus_Tmp set  " + | 
|                 " HYear=" + omodel.HYear.ToString() + | 
|                 ",HPeriod=" + omodel.HPeriod.ToString() + | 
|                 ",HBillType='" + omodel.HBillType + "'" + | 
|                 ",HDate='" + omodel.HDate.ToShortDateString() + "'" + | 
|                 ",HICMOInterID=" + omodel.HICMOInterID.ToString() + | 
|                 ",HICMOBillNo='" + omodel.HICMOBillNo + "'" + | 
|                 ",HSplitNO='" + omodel.HSplitNO + "'" + | 
|                 ",HICMOStatus=" + omodel.HICMOStatus.ToString() + | 
|                 ",HMaterID=" + omodel.HMaterID.ToString() + | 
|                 ",HMaterNumber='" + omodel.HMaterNumber + "'" + | 
|                 ",HUnitID=" + omodel.HUnitID.ToString() + | 
|                 ",HUnitNumber='" + omodel.HUnitNumber + "'" + | 
|                 ",HSourceID=" + omodel.HSourceID.ToString() + | 
|                 ",HSourceNumber='" + omodel.HSourceNumber + "'" + | 
|                 ",HPlanQty=" + omodel.HPlanQty.ToString() + | 
|                 ",HSplitPlanQty=" + omodel.HSplitPlanQty.ToString() + | 
|                 ",HSplitRelationQty=" + omodel.HSplitRelationQty.ToString() + | 
|                 ",HDatePlanQty=" + omodel.HDatePlanQty.ToString() + | 
|                 ",HUnitFinishQty=" + omodel.HUnitFinishQty.ToString() + | 
|                 ",HDateFinishQty=" + omodel.HDateFinishQty.ToString() + | 
|                 ",HBadQty=" + omodel.HBadQty.ToString() + | 
|                 ",HUnitBadQty=" + omodel.HUnitBadQty.ToString() + | 
|                 ",HWasterQty=" + omodel.HWasterQty.ToString() + | 
|                 ",HSumTimes=" + omodel.HSumTimes.ToString() + | 
|                 ",HFinishFlag=" + DBUtility.ClsPub.BoolToString(omodel.HFinishFlag) + | 
|                 ",HCurWorkFlag=" + DBUtility.ClsPub.BoolToString(omodel.HCurWorkFlag) + | 
|                 ",HCurQualityFlag=" + DBUtility.ClsPub.BoolToString(omodel.HCurQualityFlag) + | 
|                 ",HBeginDate='" + omodel.HBeginDate.ToShortDateString() + "'" + | 
|                 ",HEndDate='" + omodel.HEndDate.ToShortDateString() + "'" + | 
|                 ",HRemark='" + omodel.HRemark + "'" + | 
|                 ",HSourceInterID=" + omodel.HSourceInterID.ToString() + | 
|                 ",HSourceEntryID=" + omodel.HSourceEntryID.ToString() + | 
|                 ",HSourceBillNo='" + omodel.HSourceBillNo + "'" + | 
|                 ",HSourceBillType='" + omodel.HSourceBillType + "'" + | 
|                 ",HRelationInterID=" + omodel.HRelationInterID.ToString() + | 
|                 " where HInterID=" + lngBillKey.ToString()); | 
|                 //ɾ³ý¹ØÁª | 
|                 DeleteRelation(ref sReturn, lngBillKey); | 
|                  | 
|                 sReturn = "Ð޸ĵ¥¾Ý³É¹¦£¡"; | 
|                 oCn.Commit(); | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 throw (e); | 
|             } | 
|         } | 
|         //ÐÂÔöµ¥¾Ý | 
|         public override bool AddBill(ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 //µÃµ½mainid | 
|                 omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo); | 
|                 //ÈôMAINDIÖØ¸´ÔòÖØÐ»ñÈ¡ | 
|                 oCn.BeginTran(); | 
|                 //Ö÷±í | 
|                 oCn.RunProc("Insert Into Sc_ICMOBillStatus_Tmp   " + | 
|                 "(HYear,HPeriod,HBillType,HDate,HICMOInterID" + | 
|                 ",HICMOBillNo,HSplitNO,HICMOStatus,HMaterID,HMaterNumber" + | 
|                 ",HUnitID,HUnitNumber,HSourceID,HSourceNumber,HPlanQty" + | 
|                 ",HSplitPlanQty,HSplitRelationQty,HDatePlanQty,HUnitFinishQty,HDateFinishQty" + | 
|                 ",HBadQty,HUnitBadQty,HWasterQty,HSumTimes,HFinishFlag" + | 
|                 ",HCurWorkFlag,HCurQualityFlag,HBeginDate,HEndDate,HRemark" + | 
|                 ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationInterID" + | 
|                 ") " + | 
|                 " values(" + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HBillType + "','" + omodel.HDate.ToShortDateString() + "'," + omodel.HICMOInterID.ToString() + | 
|                 ",'" + omodel.HICMOBillNo + "','" + omodel.HSplitNO + "'," + omodel.HICMOStatus.ToString() + "," + omodel.HMaterID.ToString() + ",'" + omodel.HMaterNumber + "'" + | 
|                 "," + omodel.HUnitID.ToString() + ",'" + omodel.HUnitNumber + "'," + omodel.HSourceID.ToString() + ",'" + omodel.HSourceNumber + "'," + omodel.HPlanQty.ToString() + | 
|                 "," + omodel.HSplitPlanQty.ToString() + "," + omodel.HSplitRelationQty.ToString() + "," + omodel.HDatePlanQty.ToString() + "," + omodel.HUnitFinishQty.ToString() + "," + omodel.HDateFinishQty.ToString() + | 
|                 "," + omodel.HBadQty.ToString() + "," + omodel.HUnitBadQty.ToString() + "," + omodel.HWasterQty.ToString() + "," + omodel.HSumTimes.ToString() + "," + DBUtility.ClsPub.BoolToString(omodel.HFinishFlag) + | 
|                 "," + DBUtility.ClsPub.BoolToString(omodel.HCurWorkFlag) + "," + DBUtility.ClsPub.BoolToString(omodel.HCurQualityFlag) + ",'" + omodel.HBeginDate.ToShortDateString() + "','" + omodel.HEndDate.ToShortDateString() + "','" + omodel.HRemark + "'" + | 
|                 "," + omodel.HSourceInterID.ToString() + "," + omodel.HSourceEntryID.ToString() + ",'" + omodel.HSourceBillNo + "','" + omodel.HSourceBillType + "'," + omodel.HRelationInterID.ToString() + | 
|                 ") "); | 
|                   | 
|                 sReturn = "ÐÂÔöµ¥¾Ý³É¹¦£¡"; | 
|                 oCn.Commit(); | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 throw (e); | 
|             } | 
|         } | 
|         //ÏÔʾµ¥¾Ý | 
|         public override bool ShowBill(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 //²éѯÖ÷±í | 
|                 DataSet Ds ; | 
|                 Ds = oCn.RunProcReturn("Select * from Sc_ICMOBillStatus_Tmp Where HInterID=" + lngBillKey.ToString(), "Sc_ICMOBillStatus_Tmp"); | 
|                 if(Ds.Tables[0].Rows.Count==0) | 
|                 { | 
|                     sReturn = "µ¥¾ÝδÕÒµ½£¡"; | 
|                     return false; | 
|                 } | 
|                 //¸³Öµ | 
|                 omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]); | 
|                 omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]); | 
|                 omodel.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillType"]); | 
|                 omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]); | 
|                 omodel.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOInterID"]); | 
|                 omodel.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HICMOBillNo"]); | 
|                 omodel.HSplitNO = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSplitNO"]); | 
|                 omodel.HICMOStatus = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOStatus"]); | 
|                 omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]); | 
|                 omodel.HMaterNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaterNumber"]); | 
|                 omodel.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HUnitID"]); | 
|                 omodel.HUnitNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUnitNumber"]); | 
|                 omodel.HSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceID"]); | 
|                 omodel.HSourceNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceNumber"]); | 
|                 omodel.HPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HPlanQty"]); | 
|                 omodel.HSplitPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HSplitPlanQty"]); | 
|                 omodel.HSplitRelationQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HSplitRelationQty"]); | 
|                 omodel.HDatePlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HDatePlanQty"]); | 
|                 omodel.HUnitFinishQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HUnitFinishQty"]); | 
|                 omodel.HDateFinishQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HDateFinishQty"]); | 
|                 omodel.HBadQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HBadQty"]); | 
|                 omodel.HUnitBadQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HUnitBadQty"]); | 
|                 omodel.HWasterQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HWasterQty"]); | 
|                 omodel.HSumTimes = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSumTimes"]); | 
|                 omodel.HFinishFlag = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HFinishFlag"]); | 
|                 omodel.HCurWorkFlag = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCurWorkFlag"]); | 
|                 omodel.HCurQualityFlag = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCurQualityFlag"]); | 
|                 omodel.HBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HBeginDate"]); | 
|                 omodel.HEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HEndDate"]); | 
|                 omodel.HRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]); | 
|                 omodel.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceInterID"]); | 
|                 omodel.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceEntryID"]); | 
|                 omodel.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceBillNo"]); | 
|                 omodel.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceBillType"]); | 
|                 omodel.HRelationInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HRelationInterID"]); | 
|                 // | 
|                  | 
|                   | 
|                 sReturn = "ÏÔʾµ¥¾Ý³É¹¦£¡"; | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         //ÅжÏÊÇ·ñ¿ª¹¤ | 
|         public bool IsStarted(long HInterID,long HEntryID, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 DataSet DS; | 
|                 DS = oCn.RunProcReturn("select HBeginDate from Sc_ICMOBillStatus_Tmp where HInterID=" + HInterID.ToString() + " ", "Sc_ICMOBillStatus_Tmp"); | 
|                 if (DS.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     sReturn = "µ¥¾ÝδÕÒµ½£¡"; | 
|                     return false; | 
|                 } | 
|                 if (DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HBeginDate"]) > DBUtility.ClsPub.isDate("1900-01-01")) | 
|                 { | 
|                     sReturn = "ÒÑ¿ª¹¤£¡"; | 
|                     return true; | 
|                 } | 
|                 else | 
|                 { | 
|                     sReturn = "먦¹¤£¡"; | 
|                     return false; | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         //UPDATEÉú²ú״̬±í ÉèÖÿªÊ¼Ê±¼ä¡¢µ±Ç°Éú²ú±ê¼Ç¡¢ÈÎÎñµ¥×´Ì¬1£© | 
|         public bool Fun_SetStart(long HInterID, long HEntryID,long HSourceID, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 // | 
|                 oCn.BeginTran(); | 
|                 //¸üб¾Éú²ú×ÊÔ´È«²¿ ²»Êǵ±Ç°±ê¼Ç | 
|                 oCn.RunProc("UpDate Sc_ICMOBillStatus_Tmp set " + | 
|                 "HCurWorkFlag=0" + | 
|                 " where HSourceID=" + HSourceID.ToString() + " "); | 
|                 //¸üР | 
|                 oCn.RunProc("UpDate Sc_ICMOBillStatus_Tmp set " + | 
|                 "HICMOStatus=1" + | 
|                 ",HCurWorkFlag=1" + | 
|                 ",HBeginDate='" + DBUtility.ClsPub.GetServerDate(-1) + "'" + | 
|                 " where HInterID=" + HInterID.ToString() + " "); | 
|                 // | 
|                 sReturn = "Ð޸ĵ¥¾Ý³É¹¦£¡"; | 
|                 oCn.Commit(); | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|   | 
|         //ÅжÏÊÇ·ñÍ깤 | 
|         public bool IsEnded(long HInterID, long HEntryID, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 DataSet DS; | 
|                 DS = oCn.RunProcReturn("select HEndDate from Sc_ICMOBillStatus_Tmp where HInterID=" + HInterID.ToString() + " ", "Sc_ICMOBillStatus_Tmp"); | 
|                 if (DS.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     sReturn = "µ¥¾ÝδÕÒµ½£¡"; | 
|                     return false; | 
|                 } | 
|                 if (DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HEndDate"]) > DBUtility.ClsPub.isDate("1900-01-01")) | 
|                 { | 
|                     sReturn = "ÒÑÍ깤£¡"; | 
|                     return true; | 
|                 } | 
|                 else | 
|                 { | 
|                     sReturn = "δÍ깤£¡"; | 
|                     return false; | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         //UPDATEÉú²ú״̬±í ÉèÖÿªÊ¼Ê±¼ä¡¢µ±Ç°Éú²ú±ê¼Ç¡¢Í깤±ê¼Ç1¡¢ÈÎÎñµ¥×´Ì¬3£© | 
|         public bool Fun_SetEnd(long HInterID, long HEntryID, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 // | 
|                 oCn.BeginTran(); | 
|                 //¸üÐÂÖ÷±í | 
|                 oCn.RunProc("UpDate Sc_ICMOBillStatus_Tmp set " + | 
|                 "HICMOStatus=3" + | 
|                 ",HCurWorkFlag=0" + | 
|                 ",HFinishFlag=1" + | 
|                 ",HEndDate='" + DBUtility.ClsPub.GetServerDate(-1) + "'" + | 
|                 " where HInterID=" + HInterID.ToString() + " "); | 
|                 // | 
|                 sReturn = "Ð޸ĵ¥¾Ý³É¹¦£¡"; | 
|                 oCn.Commit(); | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 throw (e); | 
|             } | 
|         } | 
|         | 
|     }  | 
|      | 
| } |