| using System; | 
| using System.Collections.Generic; | 
| using System.Text; | 
| using System.Data; | 
| using System.Windows.Forms; | 
|   | 
| namespace DAL | 
| { | 
|     public class ClsXs_SeSampleBill_Extend_Ctl : DBUtility.ClsXt_BaseBill | 
|     { | 
|         SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
|         public ClsXs_SeSampleBill_Extend_Model omodel = new ClsXs_SeSampleBill_Extend_Model(); | 
|   | 
|         public ClsXs_SeSampleBill_Extend_Ctl() | 
|         { | 
|             base.MvarItemKeySub = ""; | 
|             base.MvarItemKeySub2 = ""; | 
|             base.MvarItemKeySub3 = ""; | 
|             base.MvarItemKeySub4 = ""; | 
|             base.MvarItemKey = "Xs_SeSampleBill_Extend"; | 
|             base.MvarReportTitle = "需求评审会签表"; | 
|             base.BillType = ""; | 
|             base.HBillSubType = ""; | 
|   | 
|         } | 
|   | 
|         //修改单据 | 
|         public override bool ModifyBill(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             return true; | 
|             //try | 
|             //{ | 
|             //    // | 
|             //    oCn.BeginTran(); | 
|             //    //更新主表 | 
|             //    oCn.RunProc("UpDate Kf_ICStockBillMain set  " + | 
|             //    " HBillNo='" + omodel.HBillNo + "'" +  //固定赋值=============== | 
|             //    ",HDate='" + omodel.HDate + "'" + | 
|             //    ",HYear='" + omodel.HYear.ToString() + "'" + | 
|             //    ",HPeriod='" + omodel.HPeriod.ToString() + "'" + | 
|             //    ",HRemark='" + omodel.HRemark + "'" + | 
|             //    ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" + | 
|             //    ",HUpDateDate=getdate()" + | 
|             //        //======================================== | 
|             //    ",HSupID=" + omodel.HSupID.ToString() + | 
|             //    ",HWHID=" + omodel.HWHID.ToString() + | 
|             //    ",HSCWHID=" + omodel.HSCWHID.ToString() + | 
|             //    ",HManagerID=" + omodel.HMangerID.ToString() + | 
|             //    ",HSecManagerID=" + omodel.HSecManagerID.ToString() + | 
|             //    ",HKeeperID=" + omodel.HKeeperID.ToString() + | 
|             //    ",HDeptID=" + omodel.HDeptID.ToString() + | 
|             //    ",HExplanation='" + omodel.HExplanation + "'" + | 
|             //    ",HInnerBillNo='" + omodel.HInnerBillNo + "'" + | 
|             //    ",HRedBlueFlag=" + DBUtility.ClsPub.BoolToString(omodel.HRedBlueFlag) + | 
|             //    " where HInterID=" + lngBillKey.ToString()); | 
|             //    //删除关联 | 
|             //    DeleteRelation(ref sReturn, lngBillKey); | 
|             //    //删除子表 | 
|             //    DeleteBillSub(lngBillKey); | 
|             //    //插入子表 | 
|             //    omodel.HInterID = lngBillKey; | 
|             //    foreach (Model.ClsKf_EntrustInBillSub oSub in DetailColl) | 
|             //    { | 
|             //        oCn.RunProc("Insert into Kf_ICStockBillSub " + | 
|             //          " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" + | 
|             //          ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + | 
|             //          ",HMaterID,HPropertyID,HSecUnitID,HSecUnitRate,HUnitID,HQtyMust" + | 
|             //          ",HQty,HPrice,HMoney,HWHID,HSCWHID,HSPID" + | 
|             //          ",HSCSPID,HSPGroupID,HBatchNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo" + | 
|             //          ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" + | 
|             //          ") values(" | 
|             //          + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "','" + oSub.HEntryCloseDate.ToShortDateString() + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" + | 
|             //          "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() + | 
|             //          "," + oSub.HMaterID.ToString() + "," + oSub.HPropertyID.ToString() + "," + oSub.HSecUnitID.ToString() + "," + oSub.HSecUnitRate.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQtyMust.ToString() + | 
|             //          "," + oSub.HQty.ToString() + "," + oSub.HPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HWHID.ToString() + "," + oSub.HSCWHID.ToString() + "," + oSub.HSPID.ToString() + | 
|             //          "," + oSub.HSCSPID.ToString() + "," + oSub.HSPGroupID.ToString() + ",'" + oSub.HBatchNo + "'," + oSub.HPOOrderInterID.ToString() + "," + oSub.HPOOrderEntryID.ToString() + ",'" + oSub.HPOOrderBillNo + "'" + | 
|             //          "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" + | 
|             //          ") "); | 
|             //    } | 
|             //    // | 
|             //    //foreach (Model.ClsKf_EntrustInBillSub oSub in DetailColl) | 
|             //    //{ | 
|             //    //    Ds = oCn.RunProcReturn("exec h_p_Kf_EntrustInBill_Qty " + oSub.HICMOInterID, ""); | 
|             //    //    if (Ds.Tables[0].Rows.Count == 0) | 
|             //    //        return; | 
|             //    //    if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBool"]) == "Y") | 
|             //    //    { | 
|             //    //        sReturn = "汇报数量超过计划数量!不允许保存"; | 
|             //    //        return false; | 
|             //    //    } | 
|             //    //} | 
|             //    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.HItemID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo); | 
|                 //若MAINDI重复则重新获取 | 
|                 DataSet Ds; | 
|                 oCn.BeginTran(); | 
|                 //主表 | 
|                 oCn.RunProc("Insert Into Xs_SeSampleBill_Extend   " + | 
|                 "(HBillNo,HCusNumber,HSelType,HReceiveStatus" + | 
|                 ",HRequester,HRequesterDate,HRequesterNote,HStatus" + | 
|                 ") " + | 
|                 " values('" + omodel.HBillNo + "','" + omodel.HCusNumber + "','" + omodel.HSelType + "','" + omodel.HReceiveStatus + "'" + | 
|                 ",'" + omodel.HRequester + "','" + omodel.HRequesterDate + "','" + omodel.HRequesterNote + "'," + omodel.HStatus.ToString() + | 
|                 ") "); | 
|                 // | 
|                 Ds = oCn.RunProcReturn("exec h_p_GetNextChecker_SeSample '" + omodel.HBillNo + "'", "Gy_Czygl"); | 
|                 if (Ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     sReturn = "创建审核流失败!"; | 
|                     oCn.RollBack(); | 
|                     return false; | 
|                 } | 
|                 if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]) != 99) | 
|                 { | 
|                     sReturn = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0][1]); | 
|                     oCn.RollBack(); | 
|                     return false; | 
|                 } | 
|                 sReturn = "新增单据成功!"; | 
|                 oCn.Commit(); | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 throw (e); | 
|             } | 
|         } | 
|         //显示单据 | 
|         public bool ShowBill(string lngBillKey, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 //查询主表 | 
|                 DataSet Ds; | 
|                 Ds = oCn.RunProcReturn("Select * from Xs_SeSampleBill_Extend Where HBillNo='" + lngBillKey + "' and isnull(HBacker,'')=''", "Xs_SeSampleBill_Extend"); | 
|                 if (Ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     sReturn = "单据未找到!"; | 
|                     return false; | 
|                 } | 
|                 //固定赋值=========================================== | 
|                 omodel.HItemID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"]); | 
|                 omodel.HBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillNo"]); | 
|                 //omodel.HInnerBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInnerBillNo"]); | 
|                 omodel.HCusNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCusNumber"]); | 
|                 omodel.HBacker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBacker"]); | 
|                 omodel.HBackDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HBackDate"]); | 
|   | 
|                 omodel.HSelType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSelType"]); | 
|                 omodel.HReceiveMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HReceiveMoney"]); | 
|                 omodel.HReceiveStatus = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HReceiveStatus"]); | 
|                 omodel.HRequester = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRequester"]); | 
|                 omodel.HRequesterDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HRequesterDate"]).ToShortDateString(); | 
|                 omodel.HRequesterNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRequesterNote"]); | 
|   | 
|                 omodel.HManager = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HManager"]); | 
|                 omodel.HManagerDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HManagerDate"]).ToShortDateString(); | 
|                 omodel.HManagerNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HManagerNote"]); | 
|   | 
|                 omodel.HAccManager = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HAccManager"]); | 
|                 omodel.HAccManagerDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HAccManagerDate"]).ToShortDateString(); | 
|                 omodel.HAccManagerNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HAccManagerNote"]); | 
|                 omodel.HLstManager = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HLstManager"]); | 
|                 omodel.HLstManagerDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HLstManagerDate"]).ToShortDateString(); | 
|                 omodel.HLstManagerNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HLstManagerNote"]); | 
|   | 
|                 omodel.HProdMan = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProdMan"]); | 
|                 omodel.HProdManDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HProdManDate"]).ToShortDateString(); | 
|                 omodel.HProdManNote = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProdManNote"]); | 
|                 omodel.HStatus = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HStatus"]); | 
|                 //======================================================== | 
|                 sReturn = "显示单据成功!"; | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         public override bool DeleteBill(long lngBillKey, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 oCn.BeginTran(); | 
|                 //删除主表 | 
|                 oCn.RunProc("Delete From Xs_SeSampleBill_Extend  where HItemID=" + lngBillKey.ToString()); | 
|                 sReturn = "删除单据成功!"; | 
|                 oCn.Commit(); | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         //审核 | 
|         public bool CheckBill(string lngBillKey, double sMoney, string sHCheckItem, string sNote, ref string sReturn) | 
|         { | 
|   | 
|             try | 
|             { | 
|                 DataSet DsA; | 
|                 DataSet Ds; | 
|                 string HChecker = DBUtility.ClsPub.CurUserName; | 
|                 Ds = oCn.RunProcReturn("exec h_p_Xs_SeSampleBill_Extend_Check '" + lngBillKey + "'," + sMoney.ToString() + ",'" + sHCheckItem + "','" + sNote + "','" + HChecker + "'", "Gy_Czygl"); | 
|                 if (Ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     sReturn = "审核失败!"; | 
|                     return false; | 
|                 } | 
|                 sReturn = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0][0]); | 
|                 // | 
|                 DsA = oCn.RunProcReturn("exec h_p_GetNextChecker_SeSample '" + lngBillKey + "'", "Gy_Czygl"); | 
|                 if (DsA.Tables[0].Rows.Count == 0 || DsA == null) | 
|                 { | 
|                     sReturn = "创建审核流失败!"; | 
|                     return false; | 
|                 } | 
|                 if (DBUtility.ClsPub.isLong(DsA.Tables[0].Rows[0][0]) != 99) | 
|                 { | 
|                     sReturn = DBUtility.ClsPub.isStrNull(DsA.Tables[0].Rows[0][1]); | 
|                     return false; | 
|                 } | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|         //关闭 | 
|         public bool CloseBill(string lngBillKey, ref string sReturn) | 
|         { | 
|   | 
|             try | 
|             { | 
|                 string HCloseMan = DBUtility.ClsPub.CurUserName; | 
|                 string HCloseDate = DBUtility.ClsPub.GetServerDate(-1); | 
|                 oCn.RunProc(" Update Xs_SeSampleBill_Extend set HBacker='" + HCloseMan + "',HBackDate='" + HCloseDate + "' Where HBillNo='" + lngBillKey + "'"); | 
|                 //oCn.RunProc(" Delete Xs_SeSampleBill_Extend  Where HBillNo='" + lngBillKey + "'"); | 
|                 DBUtility.ClsPub.Add_Log("", "退回产品需求单:"+lngBillKey, DBUtility.ClsPub.CurUserName); | 
|                 sReturn = ""; | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 throw (e); | 
|             } | 
|         } | 
|   | 
|   | 
|   | 
|   | 
|   | 
|     } | 
| } |