using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using WebAPI.Models; namespace WebAPI.Controllers.基础资料.基础资料 { public class Gy_StockCheckItemBillController : ApiController { public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更) private json objJsonResult = new json(); public DataSet ds = new DataSet(); public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); public Models.ClsGy_StockCheckItemBill BillNew0 = new ClsGy_StockCheckItemBill(); #region 盘点方案列表 [Route("Gy_StockCheckItemBill/Get_StockCheckItemList")] [HttpGet] public object Get_StockCheckItemList(string sWhere) { try { ds = StockCheckItemList(sWhere); if (ds == null) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "查询数据异常,请与管理员联系!"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "返回记录成功!"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "查询数据异常,请与管理员联系!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } public static DataSet StockCheckItemList(string sWhere) { string sql1 = string.Format(@"select * from h_v_Gy_StockCheckItemList"); if (sWhere == null || sWhere.Equals("")) { return new SQLHelper.ClsCN().RunProcReturn(sql1 + sWhere + " order by hitemid desc", "h_v_Gy_StockCheckItemList"); } else { string sql = sql1 + sWhere + "order by hitemid desc"; return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Gy_StockCheckItemList"); } } #endregion #region [盘点方案删除功能] [Route("Gy_StockCheckItemBill/set_DeleteBill")] [HttpGet] public object set_DeleteBill(string HItemID) { Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HItemID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } ds = oCn.RunProcReturn("select * from Gy_StockCheckItem where HItemID=" + lngBillKey, "Gy_StockCheckItem"); if (ds != null) { oCn.RunProc("Delete from Gy_StockCheckItem where HItemID=" + lngBillKey); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "删除成功!"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据不存在,请查看是否重复删除"; objJsonResult.data = null; return objJsonResult; } } #endregion #region [编辑显示表头] [Route("Gy_StockCheckItemBill/GetStockCheckItemByID")] [HttpGet] public object GetStockCheckItemByID(string HID) { Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } ds = oCn.RunProcReturn("select * from Gy_StockCheckItem where HItemID=" + lngBillKey, "Gy_ConkReason"); if (ds != null) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = ""; objJsonResult.data = ds.Tables[0]; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据不存在"; objJsonResult.data = null; return objJsonResult; } } #endregion #region 保存盘点方案 [Route("Gy_StockCheckItemBill/SaveGy_StockCheckItem")] [HttpPost] public object SaveGy_StockCheckItem([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg2 = _value.ToString(); string[] sArray = msg2.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg1 = sArray[0].ToString(); string msg3 = sArray[1].ToString();//当前人 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); ListModels oListModels = new ListModels(); try { Models.ClsGy_StockCheckItemBill oBill = new Models.ClsGy_StockCheckItemBill(); List lsmain = new List(); msg1 = msg1.Replace("\\", ""); msg1 = msg1.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Gy_StockCheckItem(msg1); foreach (Models.ClsGy_StockCheckItemBill oItem in lsmain) { if (oItem.HNumber.Trim() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!代码不能为空!"; objJsonResult.data = 1; return objJsonResult; } if (oItem.HName.Trim() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!名称不能为空!"; objJsonResult.data = 1; return objJsonResult; } //得到短代码 string sShortNumber; sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim()); if (sShortNumber.Trim() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!短代码为空!"; objJsonResult.data = 1; return objJsonResult; } oItem.HShortNumber = sShortNumber;//短代码 oItem.HEndFlag = true;//末级标志 oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //等级 oBill = oItem; } //保存 //保存完毕后处理 if (oBill.HItemID == 0) { oCn.RunProc("Insert into Gy_StockCheckItem " + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + ",HLevel,HEndFlag,HStopflag,HRemark,HUseFlag,HMakeTime,HMakeEmp,HEndDate,HOrgID) " + " Values('" + oBill.HNumber + "','" + oBill.HName + "','" + oBill.HHelpCode + "','" + oBill.HShortNumber + "'," + oBill.HParentID.ToString() + "," + oBill.HLevel.ToString() + "," + Convert.ToString(oBill.HEndFlag ? 1 : 0) + "," + Convert.ToString(oBill.HStopflag ? 1 : 0) + ",'" + oBill.HRemark + "','" + oBill.HUseFlag + "',getdate(),'" + msg3 + "','" + oBill.HEndDate.ToString() + "'," + oBill.HOrgID.ToString()+ ")", ref DBUtility.ClsPub.sExeReturnInfo); //修改上级为非末级代码 oCn.RunProc("Update Gy_StockCheckItem set HEndflag=0 where HItemID=" + oBill.HParentID, ref DBUtility.ClsPub.sExeReturnInfo); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { oCN.RunProc("UpDate Gy_StockCheckItem set " + " HNumber='" + oBill.HNumber + "'" + //固定赋值=============== ",HName='" + oBill.HName + "'" + ",HShortNumber='" + oBill.HShortNumber + "'" + ",HHelpCode='" + oBill.HHelpCode + "'" + ",HUseFlag='" + oBill.HUseFlag + "'" + ",HRemark='" + oBill.HRemark + "'" + ",HEndDate='" + oBill.HEndDate + "'" + ",HModifyTime=getdate()" + ",HModifyEmp='" + msg3 + "'" + ",HStopflag=" + Convert.ToString(oBill.HStopflag ? 1 : 0) + " where HItemID=" + oBill.HItemID.ToString()); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "修改成功!"; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region 盘点分析列表 [Route("Gy_StockCheckItemBill/Get_InventoryAnalysisList")] [HttpGet] public object Get_InventoryAnalysisList(string sWhere,string sID) { DataSet ds; List list = new List(); string sql; try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sID == null || sID == "") { sql = string.Format(@"select k.HBarCode 条码,m.HBillNo 器具编号,s.HName 盘点方案, case when k.HCorrespondentTypeID=1 then '供应商' when k.HCorrespondentTypeID=2 then '客户' when k.HCorrespondentTypeID=4 then '仓库' end 实际位置类型, case when k.HCorrespondentTypeID=1 then p.HName when k.HCorrespondentTypeID=2 then c.HName when k.HCorrespondentTypeID=4 then w.HName end 实际位置, case when m.HNowSupTypeID=1 then '供应商' when m.HNowSupTypeID=2 then '客户' when m.HNowSupTypeID=4 then '仓库' end 账面位置类型, case when m.HNowSupTypeID=1 then p1.HName when m.HNowSupTypeID=2 then c1.HName when m.HNowSupTypeID=4 then w1.HName end 账面位置 from Sc_MouldStockBillMain_Temp k left join Gy_MouldFileMain m on k.HBarCode=m.HBarCode left join Gy_StockCheckItem s on k.HSourceInterID=s.HItemID left join Gy_Supplier p on k.HCorrespondentID=p.HItemID left join Gy_Supplier p1 on m.HNowSupID=p1.HItemID left join Gy_Customer c on k.HCorrespondentID=c.HItemID left join Gy_Customer c1 on m.HNowSupID=c1.HItemID left join Gy_Warehouse w on k.HCorrespondentID=w.HItemID left join Gy_Warehouse w1 on m.HNowSupID=w1.HItemID where k.HBillType='3822' and " + sWhere); } else { sql = string.Format(@"select k.HBarCode 条码,m.HBillNo 器具编号,s.HName 盘点方案, case when k.HCorrespondentTypeID=1 then '供应商' when k.HCorrespondentTypeID=2 then '客户' when k.HCorrespondentTypeID=4 then '仓库' end 实际位置类型, case when k.HCorrespondentTypeID=1 then p.HName when k.HCorrespondentTypeID=2 then c.HName when k.HCorrespondentTypeID=4 then w.HName end 实际位置, case when m.HNowSupTypeID=1 then '供应商' when m.HNowSupTypeID=2 then '客户' when m.HNowSupTypeID=4 then '仓库' end 账面位置类型, case when m.HNowSupTypeID=1 then p1.HName when m.HNowSupTypeID=2 then c1.HName when m.HNowSupTypeID=4 then w1.HName end 账面位置 from Sc_MouldStockBillMain_Temp k left join Gy_MouldFileMain m on k.HBarCode=m.HBarCode left join Gy_StockCheckItem s on k.HSourceInterID=s.HItemID left join Gy_Supplier p on k.HCorrespondentID=p.HItemID left join Gy_Supplier p1 on m.HNowSupID=p1.HItemID left join Gy_Customer c on k.HCorrespondentID=c.HItemID left join Gy_Customer c1 on m.HNowSupID=c1.HItemID left join Gy_Warehouse w on k.HCorrespondentID=w.HItemID left join Gy_Warehouse w1 on m.HNowSupID=w1.HItemID where k.HBillType='3822' and " + sWhere + " and k.HSourceInterID=(select HItemID from Gy_StockCheckItem where HItemID=" + sID + ") and k.HMakeDate<=(select HEndDate from Gy_StockCheckItem where HItemID=" + sID + ")"); } ds = oCN.RunProcReturn(sql, "Sc_MouldStockBillMain_Temp"); list.Add(ds.Tables[0]); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.list = list; return objJsonResult; } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "查询数据异常,请与管理员联系!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 盘点记录列表 [Route("Gy_StockCheckItemBill/Get_MouldStockBillMainTemp")] [HttpGet] public object Get_MouldStockBillMainTemp(string sWhere) { try { ds = MouldStockBillMainTemp(sWhere); if (ds == null) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "查询数据异常,请与管理员联系!"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "返回记录成功!"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "查询数据异常,请与管理员联系!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } public static DataSet MouldStockBillMainTemp(string sWhere) { string sql1 = string.Format(@"select * from h_v_Gy_MouldStockBillMainTempList where 1=1 "); if (sWhere == null || sWhere.Equals("")) { return new SQLHelper.ClsCN().RunProcReturn(sql1 + sWhere + " order by 制单日期 desc", "h_v_Gy_MouldStockBillMainTempList"); } else { string sql = sql1 + sWhere + "order by 制单日期 desc"; return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Gy_MouldStockBillMainTempList"); } } #endregion #region [盘点方案删除功能] [Route("Gy_StockCheckItemBill/set_DeleteBill_Temp")] [HttpGet] public object set_DeleteBill_Temp(string HItemID) { Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HItemID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } ds = oCn.RunProcReturn("select * from Sc_MouldStockBillMain_Temp where HItemID=" + lngBillKey, "Sc_MouldStockBillMain_Temp"); if (ds != null) { oCn.RunProc("Delete from Sc_MouldStockBillMain_Temp where HItemID=" + lngBillKey); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "删除成功!"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据不存在,请查看是否重复删除"; objJsonResult.data = null; return objJsonResult; } } #endregion #region 盘点分析审核 #region 调拨—直接调拨 [Route("Gy_StockCheckItemBill/MakeProdMove")] [HttpGet] public object MakeProdMove(string HBarCode, string user, string userID) { try { string HBillNo = ""; Int64 HInterID = 0;//显示的字段 ds = oCn.RunProcReturn("select * from Gy_MouldFileMain where HBarCode='" + HBarCode + "'", "Gy_MouldFileMain"); DataRow dr = ds.Tables[0].Rows[0]; HInterID = DBUtility.ClsPub.CreateBillID("3814", ref DBUtility.ClsPub.sExeReturnInfo); HBillNo = DBUtility.ClsPub.CreateBillCode("3814", ref DBUtility.ClsPub.sExeReturnInfo, true); string sql = "Insert Into Sc_MouldStockBillMain " + "(HBillType,HBillSubType,HInterID,HBillNo,HDate" + ",HMaker,HMakeDate" + /*"HYear, HPeriod,"*/ ",HSupID,HSupTypeID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" + ",HKeeperID,HDeptID,HInnerBillNo,HRedBlueFlag" + ") " + " values('3814','3814'," + HInterID + ",'" + HBillNo + "',getdate()" + ", '" + user + "',getdate()" + ", " + dr["HSupID"].ToString() + ", 1," + dr["HWhID"].ToString() + ",0,0,0,0" + ", 0," + dr["HDeptID"].ToString() + ",' ',0" + ") "; string sql1 = string.Format(@"Insert Into Sc_MouldStockBillSub (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark,HSourceInterID, HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaterID,HPropertyID,HSecUnitRate,HSecUnitID,HUnitID, HBatchNo,HQtyMust,HQty,HPrice,HMoney,HDesignLife,HLeaveLife,HUseLife,HWHID,HSCWHID,HSPID,HSCSPID,HSPGroupID,HCorrespondentTypeID,HCorrespondentID, HStockOrgID,HOWNERID,HOtherOrgID,HOWNERTYPEID) values(" + HInterID + ",1,'',getdate(),0,'',0,0,'',''," + "0,0," + dr["HInterID"].ToString() + ",0,0,0," + dr["HUnitID"].ToString() + ",0," + dr["HProdQty"].ToString() + "," + dr["HProdQty"].ToString() + ",0," + "0," + dr["HDesignLife"].ToString() + "," + dr["HLeaveLife"].ToString() + "," + dr["HUseLife"].ToString() + "," + dr["HWHID"].ToString() + ",0," + dr["HSPID"].ToString() + ",0,0" + ",0,0," + userID + ",0,0,'')"); //主表 oCn.RunProc(sql); oCn.RunProc(sql1); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "初始化失败!"; objJsonResult.data = null; } return objJsonResult; } #endregion #region 盘盈—其他入库单 [Route("Gy_StockCheckItemBill/MakeOtherIn")] [HttpGet] public object MakeOtherIn(string HBarCode, string user, string userID) { try { string HBillNo = ""; Int64 HInterID = 0;//显示的字段 ds = oCn.RunProcReturn("select * from Gy_MouldFileMain where HBarCode='" + HBarCode + "'", "Gy_MouldFileMain"); DataRow dr = ds.Tables[0].Rows[0]; HInterID = DBUtility.ClsPub.CreateBillID("3827", ref DBUtility.ClsPub.sExeReturnInfo); HBillNo = DBUtility.ClsPub.CreateBillCode("3827", ref DBUtility.ClsPub.sExeReturnInfo, true); string sql = "Insert Into Sc_MouldStockBillMain " + "(HBillType,HBillSubType,HInterID,HBillNo,HDate" + ",HMaker,HMakeDate" + /*"HYear, HPeriod,"*/ ",HSupID,HSupTypeID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" + ",HKeeperID,HDeptID,HInnerBillNo,HRedBlueFlag" + ") " + " values('3827','3827'," + HInterID + ",'" + HBillNo + "',getdate()" + ", '" + user + "',getdate()" + ", " + dr["HSupID"].ToString() + ", 1," + dr["HWhID"].ToString() + ",0,0,0,0" + ", 0," + dr["HDeptID"].ToString() + ",' ',0" + ") "; string sql1 = string.Format(@"Insert Into Sc_MouldStockBillSub (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark,HSourceInterID, HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaterID,HPropertyID,HSecUnitRate,HSecUnitID,HUnitID, HBatchNo,HQtyMust,HQty,HPrice,HMoney,HDesignLife,HLeaveLife,HUseLife,HWHID,HSCWHID,HSPID,HSCSPID,HSPGroupID,HCorrespondentTypeID,HCorrespondentID, HStockOrgID,HOWNERID,HOtherOrgID,HOWNERTYPEID) values(" + HInterID + ",1,'',getdate(),0,'',0,0,'',''," + "0,0," + dr["HInterID"].ToString() + ",0,0,0," + dr["HUnitID"].ToString() + ",0," + dr["HProdQty"].ToString() + "," + dr["HProdQty"].ToString() + ",0," + "0," + dr["HDesignLife"].ToString() + "," + dr["HLeaveLife"].ToString() + "," + dr["HUseLife"].ToString() + "," + dr["HWHID"].ToString() + ",0," + dr["HSPID"].ToString() + ",0,0" + ",0,0," + userID + ",0,0,'')"); //主表 oCn.RunProc(sql); oCn.RunProc(sql1); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "初始化失败!"; objJsonResult.data = null; } return objJsonResult; } #endregion #region 盘亏—处理出库单 [Route("Gy_StockCheckItemBill/MakeScrapOut")] [HttpGet] public object MakeScrapOut(string HBarCode, string user, string userID) { try { string HBillNo = ""; Int64 HInterID = 0;//显示的字段 ds = oCn.RunProcReturn("select * from Gy_MouldFileMain where HBarCode='" + HBarCode + "'", "Gy_MouldFileMain"); DataRow dr = ds.Tables[0].Rows[0]; HInterID = DBUtility.ClsPub.CreateBillID("3832", ref DBUtility.ClsPub.sExeReturnInfo); HBillNo = DBUtility.ClsPub.CreateBillCode("3832", ref DBUtility.ClsPub.sExeReturnInfo, true); string sql = "Insert Into Sc_MouldStockBillMain " + "(HBillType,HBillSubType,HInterID,HBillNo,HDate" + ",HMaker,HMakeDate" + /*"HYear, HPeriod,"*/ ",HSupID,HSupTypeID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" + ",HKeeperID,HDeptID,HInnerBillNo,HRedBlueFlag" + ") " + " values('3832','3832'," + HInterID + ",'" + HBillNo + "',getdate()" + ", '" + user + "',getdate()" + ", " + dr["HSupID"].ToString() + ", 1," + dr["HWhID"].ToString() + ",0,0,0,0" + ", 0," + dr["HDeptID"].ToString() + ",' ',0" + ") "; string sql1 = string.Format(@"Insert Into Sc_MouldStockBillSub (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark,HSourceInterID, HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaterID,HPropertyID,HSecUnitRate,HSecUnitID,HUnitID, HBatchNo,HQtyMust,HQty,HPrice,HMoney,HDesignLife,HLeaveLife,HUseLife,HWHID,HSCWHID,HSPID,HSCSPID,HSPGroupID,HCorrespondentTypeID,HCorrespondentID, HStockOrgID,HOWNERID,HOtherOrgID,HOWNERTYPEID) values(" + HInterID + ",1,'',getdate(),0,'',0,0,'',''," + "0,0," + dr["HInterID"].ToString() + ",0,0,0," + dr["HUnitID"].ToString() + ",0," + dr["HProdQty"].ToString() + "," + dr["HProdQty"].ToString() + ",0," + "0," + dr["HDesignLife"].ToString() + "," + dr["HLeaveLife"].ToString() + "," + dr["HUseLife"].ToString() + "," + dr["HWHID"].ToString() + ",0," + dr["HSPID"].ToString() + ",0,0" + ",0,0," + userID + ",0,0,'')"); //主表 oCn.RunProc(sql); oCn.RunProc(sql1); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "初始化失败!"; objJsonResult.data = null; } return objJsonResult; } #endregion #region 出库—领用出库单 [Route("Gy_StockCheckItemBill/MakeProdOut")] [HttpGet] public object MakeProdOut(string HBarCode, string user, string userID) { try { string HBillNo = ""; Int64 HInterID = 0;//显示的字段 ds = oCn.RunProcReturn("select * from Gy_MouldFileMain where HBarCode='" + HBarCode + "'", "Gy_MouldFileMain"); DataRow dr = ds.Tables[0].Rows[0]; HInterID = DBUtility.ClsPub.CreateBillID("3802", ref DBUtility.ClsPub.sExeReturnInfo); HBillNo = DBUtility.ClsPub.CreateBillCode("3802", ref DBUtility.ClsPub.sExeReturnInfo, true); string sql = "Insert Into Sc_MouldStockBillMain " + "(HBillType,HBillSubType,HInterID,HBillNo,HDate" + ",HMaker,HMakeDate" + /*"HYear, HPeriod,"*/ ",HSupID,HSupTypeID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" + ",HKeeperID,HDeptID,HInnerBillNo,HRedBlueFlag" + ") " + " values('3802','3802'," + HInterID + ",'" + HBillNo + "',getdate()" + ", '" + user + "',getdate()" + ", " + dr["HSupID"].ToString() + ", 1," + dr["HWhID"].ToString() + ",0,0,0,0" + ", 0," + dr["HDeptID"].ToString() + ",' ',0" + ") "; string sql1 = string.Format(@"Insert Into Sc_MouldStockBillSub (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark,HSourceInterID, HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaterID,HPropertyID,HSecUnitRate,HSecUnitID,HUnitID, HBatchNo,HQtyMust,HQty,HPrice,HMoney,HDesignLife,HLeaveLife,HUseLife,HWHID,HSCWHID,HSPID,HSCSPID,HSPGroupID,HCorrespondentTypeID,HCorrespondentID, HStockOrgID,HOWNERID,HOtherOrgID,HOWNERTYPEID) values(" + HInterID + ",1,'',getdate(),0,'',0,0,'',''," + "0,0," + dr["HInterID"].ToString() + ",0,0,0," + dr["HUnitID"].ToString() + ",0," + dr["HProdQty"].ToString() + "," + dr["HProdQty"].ToString() + ",0," + "0," + dr["HDesignLife"].ToString() + "," + dr["HLeaveLife"].ToString() + "," + dr["HUseLife"].ToString() + "," + dr["HWHID"].ToString() + ",0," + dr["HSPID"].ToString() + ",0,0" + ",0,0," + userID + ",0,0,'')"); //主表 oCn.RunProc(sql); oCn.RunProc(sql1); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "初始化失败!"; objJsonResult.data = null; } return objJsonResult; } #endregion #region 退库—领用退库单 [Route("Gy_StockCheckItemBill/MakeProdBack")] [HttpGet] public object MakeProdBack(string HBarCode, string user, string userID) { try { string HBillNo = ""; Int64 HInterID = 0;//显示的字段 ds = oCn.RunProcReturn("select * from Gy_MouldFileMain where HBarCode='" + HBarCode + "'", "Gy_MouldFileMain"); DataRow dr = ds.Tables[0].Rows[0]; HInterID = DBUtility.ClsPub.CreateBillID("3803", ref DBUtility.ClsPub.sExeReturnInfo); HBillNo = DBUtility.ClsPub.CreateBillCode("3803", ref DBUtility.ClsPub.sExeReturnInfo, true); string sql = "Insert Into Sc_MouldStockBillMain " + "(HBillType,HBillSubType,HInterID,HBillNo,HDate" + ",HMaker,HMakeDate" + /*"HYear, HPeriod,"*/ ",HSupID,HSupTypeID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" + ",HKeeperID,HDeptID,HInnerBillNo,HRedBlueFlag" + ") " + " values('3803','3803'," + HInterID + ",'" + HBillNo + "',getdate()" + ", '" + user + "',getdate()" + ", " + dr["HSupID"].ToString() + ", 1," + dr["HWhID"].ToString() + ",0,0,0,0" + ", 0," + dr["HDeptID"].ToString() + ",' ',0" + ") "; string sql1 = string.Format(@"Insert Into Sc_MouldStockBillSub (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark,HSourceInterID, HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaterID,HPropertyID,HSecUnitRate,HSecUnitID,HUnitID, HBatchNo,HQtyMust,HQty,HPrice,HMoney,HDesignLife,HLeaveLife,HUseLife,HWHID,HSCWHID,HSPID,HSCSPID,HSPGroupID,HCorrespondentTypeID,HCorrespondentID, HStockOrgID,HOWNERID,HOtherOrgID,HOWNERTYPEID) values(" + HInterID + ",1,'',getdate(),0,'',0,0,'',''," + "0,0," + dr["HInterID"].ToString() + ",0,0,0," + dr["HUnitID"].ToString() + ",0," + dr["HProdQty"].ToString() + "," + dr["HProdQty"].ToString() + ",0," + "0," + dr["HDesignLife"].ToString() + "," + dr["HLeaveLife"].ToString() + "," + dr["HUseLife"].ToString() + "," + dr["HWHID"].ToString() + ",0," + dr["HSPID"].ToString() + ",0,0" + ",0,0," + userID + ",0,0,'')"); //主表 oCn.RunProc(sql); oCn.RunProc(sql1); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "初始化失败!"; objJsonResult.data = null; } return objJsonResult; } #endregion #region 先领用退库再领用出库 [Route("Gy_StockCheckItemBill/MakeProdOutBack")] [HttpGet] public object MakeProdOutBack(string HBarCode, string user, string userID) { try { string HBillNo = ""; Int64 HInterID = 0;//显示的字段 ds = oCn.RunProcReturn("select * from Gy_MouldFileMain where HBarCode='" + HBarCode + "'", "Gy_MouldFileMain"); DataRow dr = ds.Tables[0].Rows[0]; //出库 HInterID = DBUtility.ClsPub.CreateBillID("3802", ref DBUtility.ClsPub.sExeReturnInfo); HBillNo = DBUtility.ClsPub.CreateBillCode("3802", ref DBUtility.ClsPub.sExeReturnInfo, true); string sql = "Insert Into Sc_MouldStockBillMain " + "(HBillType,HBillSubType,HInterID,HBillNo,HDate" + ",HMaker,HMakeDate" + /*"HYear, HPeriod,"*/ ",HSupID,HSupTypeID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" + ",HKeeperID,HDeptID,HInnerBillNo,HRedBlueFlag" + ") " + " values('3802','3802'," + HInterID + ",'" + HBillNo + "',getdate()" + ", '" + user + "',getdate()" + ", " + dr["HSupID"].ToString() + ", 1," + dr["HWhID"].ToString() + ",0,0,0,0" + ", 0," + dr["HDeptID"].ToString() + ",' ',0" + ") "; string sql1 = string.Format(@"Insert Into Sc_MouldStockBillSub (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark,HSourceInterID, HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaterID,HPropertyID,HSecUnitRate,HSecUnitID,HUnitID, HBatchNo,HQtyMust,HQty,HPrice,HMoney,HDesignLife,HLeaveLife,HUseLife,HWHID,HSCWHID,HSPID,HSCSPID,HSPGroupID,HCorrespondentTypeID,HCorrespondentID, HStockOrgID,HOWNERID,HOtherOrgID,HOWNERTYPEID) values(" + HInterID + ",1,'',getdate(),0,'',0,0,'',''," + "0,0," + dr["HInterID"].ToString() + ",0,0,0," + dr["HUnitID"].ToString() + ",0," + dr["HProdQty"].ToString() + "," + dr["HProdQty"].ToString() + ",0," + "0," + dr["HDesignLife"].ToString() + "," + dr["HLeaveLife"].ToString() + "," + dr["HUseLife"].ToString() + "," + dr["HWHID"].ToString() + ",0," + dr["HSPID"].ToString() + ",0,0" + ",0,0," + userID + ",0,0,'')"); //退库 HInterID = DBUtility.ClsPub.CreateBillID("3803", ref DBUtility.ClsPub.sExeReturnInfo); HBillNo = DBUtility.ClsPub.CreateBillCode("3803", ref DBUtility.ClsPub.sExeReturnInfo, true); string sql2 = "Insert Into Sc_MouldStockBillMain " + "(HBillType,HBillSubType,HInterID,HBillNo,HDate" + ",HMaker,HMakeDate" + /*"HYear, HPeriod,"*/ ",HSupID,HSupTypeID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" + ",HKeeperID,HDeptID,HInnerBillNo,HRedBlueFlag" + ") " + " values('3803','3803'," + HInterID + ",'" + HBillNo + "',getdate()" + ", '" + user + "',getdate()" + ", " + dr["HSupID"].ToString() + ", 1," + dr["HWhID"].ToString() + ",0,0,0,0" + ", 0," + dr["HDeptID"].ToString() + ",' ',0" + ") "; string sql3 = string.Format(@"Insert Into Sc_MouldStockBillSub (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark,HSourceInterID, HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaterID,HPropertyID,HSecUnitRate,HSecUnitID,HUnitID, HBatchNo,HQtyMust,HQty,HPrice,HMoney,HDesignLife,HLeaveLife,HUseLife,HWHID,HSCWHID,HSPID,HSCSPID,HSPGroupID,HCorrespondentTypeID,HCorrespondentID, HStockOrgID,HOWNERID,HOtherOrgID,HOWNERTYPEID) values(" + HInterID + ",1,'',getdate(),0,'',0,0,'',''," + "0,0," + dr["HInterID"].ToString() + ",0,0,0," + dr["HUnitID"].ToString() + ",0," + dr["HProdQty"].ToString() + "," + dr["HProdQty"].ToString() + ",0," + "0," + dr["HDesignLife"].ToString() + "," + dr["HLeaveLife"].ToString() + "," + dr["HUseLife"].ToString() + "," + dr["HWHID"].ToString() + ",0," + dr["HSPID"].ToString() + ",0,0" + ",0,0," + userID + ",0,0,'')"); //主表 oCn.RunProc(sql); oCn.RunProc(sql1); oCn.RunProc(sql2); oCn.RunProc(sql3); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "初始化失败!"; objJsonResult.data = null; } return objJsonResult; } #endregion #endregion } }