WebAPI/Controllers/XSGL/Xs_SeOrderBillController.cs
@@ -87,12 +87,12 @@
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_IF_SeOrderBillList order by hmainid desc", "h_v_IF_SeOrderBillList");
                    ds = oCN.RunProcReturn("select * from h_v_IF_SeOrderBillList order by hmainid desc,hsubid asc", "h_v_IF_SeOrderBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_IF_SeOrderBillList where 1 = 1 ";
                    string sql = sql1 + sWhere+ " order by hmainid desc";
                    string sql = sql1 + sWhere+ " order by hmainid desc,hsubid asc";
                    ds = oCN.RunProcReturn(sql, "h_v_IF_SeOrderBillList");
                }
@@ -1153,10 +1153,22 @@
                            objJsonResult.data = 1;
                            return objJsonResult;
                        }
                        string sql = "select count(*) Xs_ExceptiveCheckRequestBillCount from Xs_ExceptiveCheckRequestBillMain where HMainSourceInterID = " + BillOld.omodel.HInterID;
                        ds = oCN.RunProcReturn(sql, "Xs_ExceptiveCheckRequestBillMain");
                        if (ds != null && Int64.Parse(ds.Tables[0].Rows[0]["Xs_ExceptiveCheckRequestBillCount"].ToString()) > 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "保存失败,单据存在下游单据[特批申请单]!";
                            objJsonResult.data = 1;
                            return objJsonResult;
                        }
                    }
                    UserName = oItem.HMaker;  //制单人
                    oItem.HBillType = "1401";
                    oItem.HBillSubType = "1401";
                    //oItem.HBillSubType = "1401";
                    oItem.HSALEORGID = oItem.HOrgID;
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                    oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
@@ -1197,9 +1209,23 @@
                    //oItemSub.HSourceBillType = ""; //源单类型
                    //oItemSub.HRelationQty = 0;     //关联数量
                    //oItemSub.HRelationMoney = 0;   //关联金额 
                    oBill.DetailColl.Add(oItemSub);
                    if (oItemSub.HMaterID != 0)
                    {
                        oBill.DetailColl.Add(oItemSub);
                    }
                }
                //进行 会计期间 结账 的判断和控制
                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;
@@ -1253,7 +1279,7 @@
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_IF_SeOrderBillList where hmainid =" + HInterID, "h_v_IF_SeOrderBillList");
                ds = oCN.RunProcReturn("select * from h_v_IF_SeOrderBillList where hmainid =" + HInterID + " order by hsubid asc", "h_v_IF_SeOrderBillList");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
@@ -1328,22 +1354,80 @@
                    return objJsonResult;
                }
                //删除前控制=========================================
                string sql1 = "exec h_p_Xs_SeOrderBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql1, "h_p_Xs_SeOrderBill_BeforeDelCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //==================================================================================
                //进行 会计期间 结账 的判断和控制
                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;
                }
                oCN.BeginTran();
                oCN.RunProc("delete from Xs_SeOrderBillMain where HInterID = " + HInterID);
                oCN.RunProc("delete from Xs_SeOrderBillSub where HInterID='" + HInterID + "'");
                //删除后控制==================================================================================
                string sql2 = "exec h_p_Xs_SeOrderBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql2, "h_p_Xs_SeOrderBill_AfterDelCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    s = "删除后判断失败,请与网络管理人员联系";
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + s;
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    s = ds.Tables[0].Rows[0]["HRemark"].ToString();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + s;
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                //==============================================================================================
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.Message = "您已删除单据号为" + BillOld.omodel.HBillNo + "的销售订单!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
@@ -1432,6 +1516,18 @@
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        foreach(Model.ClsXs_SeOrderBillSub oSub in oBill.DetailColl)
                        {
                            if (oSub.HCloseMan != "")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "单据中存在行关闭的记录!反审核失败!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                        }
                    }
                }
                else
@@ -1447,8 +1543,51 @@
                //进行需要进行的审核/反审核操作
                if (IsAudit == 0) //审核提交
                {
                    ds = oCN.RunProcReturn("exec h_p_Kf_CheckSeOrderBill_CrediControl " + oBill.omodel.HInterID, "h_p_Kf_CheckSeOrderBill_CrediControl");
                    if(ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //审核前控制=========================================
                    string sql1 = "exec h_p_Xs_SeOrderBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Xs_SeOrderBill_BeforeCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                        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 (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Xs_SeOrderBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
@@ -1467,8 +1606,39 @@
                }
                if (IsAudit == 1) //反审核提交
                {
                    //反审核前控制=========================================
                    DataSet ds = oCN.RunProcReturn("Exec h_p_Xs_SeOrderBill_BeforeAbandonCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'", "h_p_Xs_SeOrderBill_BeforeAbandonCheckCtrl");
                    if (ds == null)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反审核失败!原因:" + "反审核前判断失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反审核失败!原因:" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                        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;
                    }
                    //反审核提交AbandonCheck
                    if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Xs_SeOrderBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
@@ -1511,6 +1681,7 @@
        {
            string ModRightNameCheck = "Xs_SeOrderBill_Close";
            DBUtility.ClsPub.CurUserName = CurUserName;
            string sql = "";
            try
            {
                //检查权限
@@ -1577,6 +1748,18 @@
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //判断单据是否为自动关闭
                        sql = "select * from Xs_SeOrderBillMain where HInterID = " + HInterID;
                        ds = oCN.RunProcReturn(sql, "Xs_SeOrderBillMain");
                        if (ds.Tables[0].Rows[0]["HCloseType"].ToString() == "False")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "反关闭失败!单据为自动关闭,不能进行手动反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
@@ -1612,6 +1795,15 @@
                }
                if (IsAudit == 1) //反关闭提交
                {
                    ds = oCN.RunProcReturn("exec h_p_Kf_CheckSeOrderBill_CrediControl " + oBill.omodel.HInterID, "h_p_Kf_CheckSeOrderBill_CrediControl");
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //反关闭提交
                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
@@ -1627,6 +1819,195 @@
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "关闭失败或者反关闭失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 销售订单 行关闭/行反关闭
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">关闭(0),反关闭(1)</param>
        /// <param name="CurUserName">关闭人</param>
        /// <returns></returns>
        [Route("Xs_SeOrderBill/CloseRowXs_SeOrderBill")]
        [HttpGet]
        public object CloseRowXs_SeOrderBill(int HInterID,int HEntryID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "Xs_SeOrderBill_Close";
            string SubBillName = "Xs_SeOrderBillSub";                   //子表表名
            DBUtility.ClsPub.CurUserName = CurUserName;
            DataSet ds = null;
            try
            {
                //检查权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "行关闭失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsXs_SeOrderBill oBill = new DAL.ClsXs_SeOrderBill();              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    if (oBill.omodel.HDeleteMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已作废!不能进行行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HCloseMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已关闭!不能进行行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HChecker.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据未审核!不能进行行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    string sql = "select * from " + SubBillName + " where HInterID = " + HInterID + " and HEntryID = " + HEntryID;
                    ds = oCN.RunProcReturn(sql, "Xs_SeOrderBillSub");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "该行数据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (IsAudit == 0)  //行关闭判断
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "行已关闭!不能再次行关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //行反关闭判断
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "行未关闭!不需要再行反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //判断行是否为自动关闭
                        string temp = ds.Tables[0].Rows[0]["HCloseType"].ToString();
                        if (ds.Tables[0].Rows[0]["HCloseType"].ToString() == "False")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            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 == 0) //行关闭提交
                {
                    //行关闭提交
                    if (oBill.CloseRow(lngBillKey,HEntryID,oBill.omodel.HBillNo,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) //行反关闭提交
                {
                    oBill.oCn.BeginTran();
                    //行反关闭提交
                    if (oBill.CancelRow(lngBillKey, HEntryID, oBill.omodel.HBillNo, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        ds = oCN.RunProcReturn("exec h_p_Kf_CheckSeOrderBill_CrediControl " + oBill.omodel.HInterID, "h_p_Kf_CheckSeOrderBill_CrediControl");
                        if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
                            objJsonResult.data = null;
                            oBill.oCn.RollBack();
                            return objJsonResult;
                        }
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭成功";
                        objJsonResult.data = null;
                        oBill.oCn.Commit();
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        oBill.oCn.RollBack();
                        return objJsonResult;
                    }
                }
@@ -1845,11 +2226,11 @@
            try
            {
                string sql = @"select 
                            c.HEmpID
                            ISNULL(c.HEmpID,0) HEmpID
                            ,e.HName HEmpName
                            ,c.HDeptID
                            ,ISNULL(c.HDeptID,0) HDeptID
                            ,d.HName HDeptName
                            ,d.HEmpID HManagerID
                            ,ISNULL(d.HEmpID,0) HManagerID
                            ,e1.HName HManagerName
                            from Gy_Czygl as c
                            left join Gy_Employee as e on c.HEmpID = e.HItemID
@@ -1885,5 +2266,345 @@
            }
        }
        #endregion
        #region 销售订单 根据用户获取用户关联客户过滤条件
        [Route("Xs_SeOrderBill/getCusIDListByUser")]
        [HttpGet]
        public object getCusIDListByUser(string CurUserID, string CurUserName)
        {
            string sWhere = "";
            string ModRightNameCheck = "Gy_UserLookAllCus";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //权限判断:是否可以查看所有客户
                if (DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    sWhere = "";
                }
                else
                {
                    sWhere = " and HCusID in (select hcusid from Gy_UserCustomerRelation Where HUserID = '" + CurUserID + "' union all select 166351 hcusid)";
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = sWhere;
                return objJsonResult;
            }
            catch (Exception e)
            {
                sWhere = " and 1=0 ";
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = sWhere;
                return objJsonResult;
            }
        }
        #endregion
        #region 销售订单 下推生产订单(无列表)-获取数据
        [Route("Xs_SeOrderBill/loadXs_SeOrderBill_InitICMO")]
        [HttpGet]
        public object loadXs_SeOrderBill_InitICMO(long HInterID,long HEntryID)
        {
            try
            {
                string sql = "select * from h_v_IF_SeOrderBillList where hmainid = " + HInterID + " and HSubID = " + HEntryID;
                ds = oCN.RunProcReturn(sql, "h_v_IF_SeOrderBillList");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "false!";
                    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>
        /// <param name="HInterID">单据ID</param>
        /// <returns></returns>
        [Route("Xs_SeOrderBill/CheckSeOrderBill_IsExist")]
        [HttpGet]
        public object CheckSeOrderBill_IsExist(int HInterID)
        {
            try
            {
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsXs_SeOrderBill oBill = new DAL.ClsXs_SeOrderBill();                              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    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;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "程序错误!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 销售订单 下查
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <returns></returns>
        [Route("Xs_SeOrderBill/SeOrderBill_LookDown")]
        [HttpGet]
        public object SeOrderBill_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_Xs_SeOrderBill_lookdown " + HInterID;
                ds = oCN.RunProcReturn(sql, "h_p_Xs_SeOrderBill_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
        #region 销售订单 根据主内码与子内码获取销售订单数据
        [Route("Xs_SeOrderBill/loadXs_SeOrderBill_Push")]
        [HttpGet]
        public object loadXs_SeOrderBill_Push(long HInterID,long HSubID)
        {
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_IF_SeOrderBillList where hmainid =" + HInterID + " and hsubid = " + HSubID, "h_v_IF_SeOrderBillList");
                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 销售订单 根据职员获取部门、主管
        [Route("Xs_SeOrderBill/getEmpInfoByHEmpID")]
        [HttpGet]
        public object getEmpInfoByHEmpID(long HEmpID)
        {
            try
            {
                string sql = "select a.HItemID HEmpID,a.HName HEmpName,ISNULL(a.HDeptID,0) HDeptID,b.HName HDeptName,ISNULL(b.HEmpID,0) HManagerID,c.HName HManagerName " +
                    " from Gy_Employee as a " +
                    " left join Gy_Department as b on a.HDeptID = b.HItemID " +
                    " left join Gy_Employee as c on b.HEmpID = c.HItemID " +
                    " where a.HItemID = " + HEmpID;
                ds = oCN.RunProcReturn(sql, "Gy_Employee");
                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 销售订单 获取排序后的数据
        [Route("Xs_SeOrderBill/sortList")]
        [HttpGet]
        public object sortList(string sWhere, string user)
        {
            try
            {
                //判断查询权限
                if (!DBUtility.ClsPub.Security_Log("Xs_SeOrderBillQuery", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限查询!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_IF_SeOrderBillList order by hmainid desc", "h_v_IF_SeOrderBillList");
                }
                else
                {
                    string sql1 = "select * from h_v_IF_SeOrderBillList where 1 = 1 ";
                    string sql = sql1 + sWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_IF_SeOrderBillList");
                }
                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
    }
}