llj
2 天以前 1c90213ebd42e2d00324a71a67a60d07e4c8a7da
WebAPI/Controllers/Cg_ContractTransportBillListController.cs
@@ -35,7 +35,7 @@
                List<object> columnNameList = new List<object>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log_second("Cg_ContractTransportBill_Check", 1, false, user))
                if (!DBUtility.ClsPub.Security_Log_second("Cg_ContractTransportBill_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
@@ -47,13 +47,13 @@
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Cg_ContractTransportBillList order by 单据号 desc", "h_v_Cg_ContractTransportBillList");
                    ds = oCN.RunProcReturn("select * from h_v_Cg_ContractTransportBillList_Query order by 单据号 desc", "h_v_Cg_ContractTransportBillList_Query");
                }
                else
                {
                    string sql1 = "select * from  h_v_Cg_ContractTransportBillList  where 1 = 1 ";
                    string sql1 = "select * from  h_v_Cg_ContractTransportBillList_Query  where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by 单据号 desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Cg_ContractTransportBillList");
                    ds = oCN.RunProcReturn(sql, "h_v_Cg_ContractTransportBillList_Query");
                }
                //添加列名
@@ -83,6 +83,62 @@
        #endregion
        #region 承运商合同分页列表
        [Route("Cg_ContractTransportBillListController/page")]
        [HttpGet]
        public json Sc_MouldProdOutBillPage(string sWhere, string user, int page, int size, string Type)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                //列表进入时判断权限,选源单进入不判断权限
                    if (!DBUtility.ClsPub.Security_Log("Cg_ContractTransportBill_Query", 3, false, user))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "您没有该模块权限,请与管理员联系!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                sWhere = sWhere.Replace("'", "''");
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_Cg_ContractTransportBillList " + page + "," + size + ",'','" + Type + "'", "h_p_Cg_ContractTransportBillList");
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_Cg_ContractTransportBillList " + page + "," + size + ",'" + sWhere + "','" + Type + "'", "h_p_Cg_ContractTransportBillList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "0";
                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                objJsonResult.Message = "成功!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "查询列表信息失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 删除     
        [Route("Cg_ContractTransportBillListController/DeleteBill")]
        [HttpGet]
@@ -90,6 +146,7 @@
        {
            try
            {
                string s = "";
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Cg_ContractTransportBill_Delete", 1, false, user))
                {
@@ -115,7 +172,7 @@
                if (BillOld.ShowBill(Int64.Parse(HInterID), ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    //删除前控制=========================================      
                    string sql1 = "exec h_p_Cg_ContractTransportBill_BeforeDelCtrl  " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                    string sql1 = "exec h_p_Cg_ContractTransportBill_BeforeDelCtrl  " + BillOld.omodel.HInterID + ",'" + user + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Cg_ContractTransportBill_BeforeDelCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
@@ -135,38 +192,51 @@
                        return objJsonResult;
                    }
                    //==================================================================================  
                    oCN.RunProc("delete from Cg_ContractTransportBillMain where HInterID = " + HInterID);
                    oCN.RunProc("delete from Cg_ContractTransportBillSub where HInterID= " + HInterID);
                    //删除单据(包含删除后控制、写入日志)
                    if (!BillOld.DeleteBill(BillOld.omodel.HInterID, BillOld.omodel.HBillNo, "h_p_Cg_ContractTransportBill_AfterDelCtrl", user, ref ClsPub.sExeReturnInfo))
                    //删除后控制==================================================================================
                    string sql2 = "exec h_p_Cg_ContractTransportBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                    ds = oCN.RunProcReturn(sql2, "h_p_Cg_ContractTransportBill_AfterDelCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        s = "删除后判断失败,请与网络管理人员联系";
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "删除成功!";
                        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 = "删除成功";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.Message = "删除成功";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
@@ -342,12 +412,12 @@
                //保存
                //保存完毕后处理
                bool bResult;
                if (refSav == "Add")
                if (refSav == "Add"|| refSav=="1")
                {
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else if (refSav == "Update")
                else if (refSav == "Update" || refSav == "3")
                {
                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                }
@@ -382,5 +452,102 @@
            }
        }
        #endregion
        #region 审核、反审核
        /// <summary>
        ///
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">审核(0),反审核(1)</param>
        /// <param name="CurUserName">审核人</param>
        /// <returns></returns>
        [Route("Cg_ContractTransportBillEdit/AuditCg_ContractTransportBillEdit")]
        [HttpGet]
        public object AuditCg_ContractTransportBillEdit(int HInterID, int IsAudit, string CurUserName)
        {
            try
            {
                //审核权限
                if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier_Check", 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "审核失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                var ds = oCN.RunProcReturn("select * from Cg_ContractTransportBillMain where HInterID=" + HInterID, "Cg_ContractTransportBillMain");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (IsAudit == 0)  //审核判断
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不能再次审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //反审核判断
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未审核!不需要反审核!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                if (IsAudit == 0)  //审核判断
                {
                    oCN.RunProc("update Cg_ContractTransportBillMain set HChecker='" + CurUserName + "',HCheckDate=getdate() ,HBillStatus=2 where HInterID=" + HInterID);
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "审核成功";
                    objJsonResult.data = null;
                }
                if (IsAudit == 1) //反审核判断
                {
                    oCN.RunProc("update Cg_ContractTransportBillMain set HChecker='',HCheckDate=null,HBillStatus=1 where HInterID=" + HInterID);
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "反审核成功";
                    objJsonResult.data = null;
                }
                oCN.Commit();
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}