|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (sWhere == null || sWhere.Equals("")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_Sc_ICMOChangeBillList_Query order by 单据号 ", "h_v_Sc_ICMOChangeBillList_Query"); | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_Sc_ICMOChangeBillList_Query order by 单据号 desc", "h_v_Sc_ICMOChangeBillList_Query"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string sql1 = "select * from h_v_Sc_ICMOChangeBillList_Query where 1 = 1 "; | 
|---|
|  |  |  | string sql = sql1 + sWhere + " order by 单据号 "; | 
|---|
|  |  |  | string sql = sql1 + sWhere + " order by 单据号 desc"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Sc_ICMOChangeBillList_Query"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //反写源单数据 | 
|---|
|  |  |  | oCN.BeginTran(); | 
|---|
|  |  |  | //检查源单是否存在 | 
|---|
|  |  |  | string sql = "select * from Sc_ICMOBillSub where HInterID = " + oBill.omodel.HMainSourceInterID + " and HEntryID =" + oBill.omodel.HMainSourceEntryID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "Sc_ICMOBillSub"); | 
|---|
|  |  |  | if(ds==null || ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | sql = "update Sc_ICMOBillSub set HQty = " + oBill.DetailColl[0].HQty_New + " where HInterID = " + oBill.omodel.HMainSourceInterID + " and HEntryID =" + oBill.omodel.HMainSourceEntryID; | 
|---|
|  |  |  | else if (ds.Tables[0].Rows[0]["HBillStatus"].ToString() != "2") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "审核失败!原因:源单未处于审核状态!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.BeginTran(); | 
|---|
|  |  |  | //反写源单数据 | 
|---|
|  |  |  | sql = "exec h_p_Sc_ICMOBill_ReWriteByICMOChangeBill " + oBill.omodel.HInterID; | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //审核提交 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RollBack(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RollBack(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString(); | 
|---|