|  |  | 
 |  |  | using System.Data.SqlClient; | 
 |  |  | using System.Web.Http; | 
 |  |  | using WebAPI.Models; | 
 |  |  | using System.Windows.Forms; | 
 |  |  |  | 
 |  |  | namespace WebAPI.Controllers | 
 |  |  | { | 
 |  |  | 
 |  |  |                     oBill.DetailColl.Add(oItemSub); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //进行 会计期间 结账 的判断和控制 | 
 |  |  |                 string s = ""; | 
 |  |  |                 int sYear = 0; | 
 |  |  |                 int sPeriod = 0; | 
 |  |  |                 DateTime HDate = DateTime.Now; | 
 |  |  |                 if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.Message = s; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //保存 | 
 |  |  |                 //保存完毕后处理 | 
 |  |  |                 bool bResult; | 
 |  |  | 
 |  |  |                 } | 
 |  |  |                 else                                                                    //编辑保存 | 
 |  |  |                 { | 
 |  |  |                     string s = ""; | 
 |  |  |                     if (BillOld.ShowBill(lsmain[0].HInterID, ref s) == false) | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //进行 会计期间 结账 的判断和控制 | 
 |  |  |                 string s = ""; | 
 |  |  |                 int sYear = 0; | 
 |  |  |                 int sPeriod = 0; | 
 |  |  |                 DateTime HDate = DateTime.Now; | 
 |  |  |                 if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.Message = s; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //进行需要进行的审核/反审核操作 | 
 |  |  |                 if (IsAudit == 0) //审核提交 | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                     //==================================================================================       | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                     //审核提交 | 
 |  |  |                     //增加关联 | 
 |  |  |                     oCN.BeginTran(); | 
 |  |  |                     //增加关联 | 
 |  |  |                     oCN.RunProc("exec h_p_Kf_SellOutBill_Check " + HInterID + ",'" + oBill.BillType + "','" + CurUserName + "'"); | 
 |  |  |                     if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_SellOutBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) | 
 |  |  |                     { | 
 |  |  |                         oCN.Commit(); | 
 |  |  |                         objJsonResult.code = "1"; | 
 |  |  |                         objJsonResult.count = 1; | 
 |  |  |                         objJsonResult.Message = "审核成功"; | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  |                     else | 
 |  |  |                     //审核更新 及时库存表 减少库存 | 
 |  |  |                     ds = oCN.RunProcReturn("exec h_KF_UPDateICinventory  '" + HInterID + "','" + oBill.BillType + "','1'", "h_KF_UPDateICinventory"); | 
 |  |  |                     //写入日志 | 
 |  |  |                     string WorkList = "审核单据,单据号:" + oBill.omodel.HBillNo; | 
 |  |  |                     string SystemName = "LMES-销售出库单模块"; | 
 |  |  |                     oCN.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " + | 
 |  |  |                         "(getdate(),'" + CurUserName + "','" + SystemInformation.ComputerName + "','" + WorkList + "','" + SystemName + "','','审核')" | 
 |  |  |                         ); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                     //审核后控制=========================================       | 
 |  |  |                     string sql = "exec h_p_Kf_SellOutBill_AfterCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, "h_p_Kf_SellOutBill_AfterCheckCtrl"); | 
 |  |  |                     if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) | 
 |  |  |                     { | 
 |  |  |                         oCN.RollBack(); | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 0; | 
 |  |  |                         objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; | 
 |  |  |                         objJsonResult.Message = "审核失败!原因:审核过程中出错,请与网络管理人员联系"; | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  |                     if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") | 
 |  |  |                     { | 
 |  |  |                         oCN.RollBack(); | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 0; | 
 |  |  |                         objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  |                     //=========================================       | 
 |  |  |  | 
 |  |  |                     oCN.Commit(); | 
 |  |  |                     objJsonResult.code = "1"; | 
 |  |  |                     objJsonResult.count = 1; | 
 |  |  |                     objJsonResult.Message = "审核成功"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |  | 
 |  |  |                     //if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_SellOutBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) | 
 |  |  |                     //{ | 
 |  |  |                     //    objJsonResult.code = "1"; | 
 |  |  |                     //    objJsonResult.count = 1; | 
 |  |  |                     //    objJsonResult.Message = "审核成功"; | 
 |  |  |                     //    objJsonResult.data = null; | 
 |  |  |                     //    return objJsonResult; | 
 |  |  |                     //} | 
 |  |  |                     //else | 
 |  |  |                     //{ | 
 |  |  |                     //    objJsonResult.code = "0"; | 
 |  |  |                     //    objJsonResult.count = 0; | 
 |  |  |                     //    objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; | 
 |  |  |                     //    objJsonResult.data = null; | 
 |  |  |                     //    return objJsonResult; | 
 |  |  |                     //} | 
 |  |  |                 } | 
 |  |  |                 if (IsAudit == 1) //反审核提交 | 
 |  |  |                 { | 
 |  |  | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |         #region 销售出库单 根据主内码与子内码获取发货通知单数据 | 
 |  |  |         [Route("Kf_SellOutBill/loadXs_SeOutStockBill_Push")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object loadXs_SeOrderBill_Push(long HInterID, long HSubID) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |  | 
 |  |  |                 ds = oCN.RunProcReturn("select * from h_v_IF_SeOutStockBillList where hmainid =" + HInterID + " and hsubid = " + HSubID, "h_v_IF_SeOutStockBillList"); | 
 |  |  |                 if (ds == null || ds.Tables[0].Rows.Count == 0) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "未查询到源单信息!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "1"; | 
 |  |  |                     objJsonResult.count = 1; | 
 |  |  |                     objJsonResult.Message = "Sucess!"; | 
 |  |  |                     objJsonResult.data = ds.Tables[0]; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "Exception!" + e.ToString(); | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |         #region 销售出库单 检查单据是否存在 | 
 |  |  |         /// <summary> | 
 |  |  |         /// </summary> | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |         #region 销售出库单 下查 | 
 |  |  |         /// <summary> | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="HInterID">单据ID</param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         [Route("Kf_SellOutBill/SellOutBill_LookDown")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object SellOutBill_LookDown(int HInterID) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 List<object> columnNameListSum = new List<object>(); | 
 |  |  |                 List<object> columnNameList0 = new List<object>(); | 
 |  |  |                 //List<object> columnNameList1 = new List<object>(); | 
 |  |  |                 //List<object> columnNameList2 = new List<object>(); | 
 |  |  |                 //List<object> columnNameList3 = new List<object>(); | 
 |  |  |                 //List<object> columnNameList4 = new List<object>(); | 
 |  |  |  | 
 |  |  |                 string sql = "exec h_p_Kf_SellOutBill_lookdown " + HInterID; | 
 |  |  |                 ds = oCN.RunProcReturn(sql, "h_p_Kf_SellOutBill_lookdown"); | 
 |  |  |  | 
 |  |  |                 //添加 销售调价单 列名 | 
 |  |  |                 foreach (DataColumn col in ds.Tables[0].Columns) | 
 |  |  |                 { | 
 |  |  |                     Type dataType = col.DataType; | 
 |  |  |                     string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
 |  |  |                     columnNameList0.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 ////添加 生产订单 列名 | 
 |  |  |                 //foreach (DataColumn col in ds.Tables[1].Columns) | 
 |  |  |                 //{ | 
 |  |  |                 //    Type dataType = col.DataType; | 
 |  |  |                 //    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
 |  |  |                 //    columnNameList1.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 | 
 |  |  |                 //} | 
 |  |  |  | 
 |  |  |                 ////添加 特批申请单 列名 | 
 |  |  |                 //foreach (DataColumn col in ds.Tables[2].Columns) | 
 |  |  |                 //{ | 
 |  |  |                 //    Type dataType = col.DataType; | 
 |  |  |                 //    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
 |  |  |                 //    columnNameList2.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 | 
 |  |  |                 //} | 
 |  |  |  | 
 |  |  |                 ////添加 销售出库单 列名 | 
 |  |  |                 //foreach (DataColumn col in ds.Tables[3].Columns) | 
 |  |  |                 //{ | 
 |  |  |                 //    Type dataType = col.DataType; | 
 |  |  |                 //    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
 |  |  |                 //    columnNameList3.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 | 
 |  |  |                 //} | 
 |  |  |  | 
 |  |  |                 ////添加 工序流转卡 列名 | 
 |  |  |                 //foreach (DataColumn col in ds.Tables[4].Columns) | 
 |  |  |                 //{ | 
 |  |  |                 //    Type dataType = col.DataType; | 
 |  |  |                 //    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
 |  |  |                 //    columnNameList4.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 | 
 |  |  |                 //} | 
 |  |  |  | 
 |  |  |                 columnNameListSum.Add(columnNameList0); | 
 |  |  |                 //columnNameListSum.Add(columnNameList1); | 
 |  |  |                 //columnNameListSum.Add(columnNameList2); | 
 |  |  |                 //columnNameListSum.Add(columnNameList3); | 
 |  |  |                 //columnNameListSum.Add(columnNameList4); | 
 |  |  |  | 
 |  |  |                 objJsonResult.code = "1"; | 
 |  |  |                 objJsonResult.count = 1; | 
 |  |  |                 objJsonResult.Message = "Sucess!"; | 
 |  |  |                 objJsonResult.data = ds.Tables; | 
 |  |  |                 objJsonResult.list = columnNameListSum; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "Exception!" + e.ToString(); | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |     } | 
 |  |  | } |