| | |
| | | |
| | | 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"); |
| | | } |
| | | |
| | |
| | | } |
| | | UserName = oItem.HMaker; //制单人 |
| | | oItem.HBillType = "1401"; |
| | | oItem.HBillSubType = "1401"; |
| | | //oItem.HBillSubType = "1401"; |
| | | oItem.HSALEORGID = oItem.HOrgID; |
| | | |
| | | oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); |
| | |
| | | //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; |
| | |
| | | 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"; |
| | |
| | | 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(); |
| | | |
| | |
| | | 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 |
| | |
| | | } |
| | | //================================================================================== |
| | | |
| | | //进行 会计期间 结账 的判断和控制 |
| | | 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(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Xs_SeOrderBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | { |
| | |
| | | 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(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Xs_SeOrderBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | |
| | | } |
| | | if (IsAudit == 1) //反关闭提交 |
| | | { |
| | | oBill.oCn.BeginTran(); |
| | | 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) |
| | | { |
| | | 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; |
| | | } |
| | | |
| | | oBill.oCn.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反关闭成功"; |
| | |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | oBill.oCn.RollBack(); |
| | | 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.count = 0; |
| | | objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | oBill.oCn.RollBack(); |
| | | return objJsonResult; |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | string sql = "select * from Gy_UserCustomerRelation where HUserID = '" + CurUserID + "'"; |
| | | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | sWhere = " and 1 = 0"; |
| | | } |
| | | else |
| | | { |
| | | sWhere = " and HCusID in ("; |
| | | for (var i = 0; i < ds.Tables[0].Rows.Count; i++) |
| | | { |
| | | if (i < ds.Tables[0].Rows.Count - 1) |
| | | { |
| | | sWhere += ds.Tables[0].Rows[i]["HCusID"].ToString() + ","; |
| | | } |
| | | else |
| | | { |
| | | sWhere += ds.Tables[0].Rows[i]["HCusID"].ToString() + ")"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //sWhere = " and 1=1 "; |
| | | sWhere = " and HCusID in (select hcusid from Gy_UserCustomerRelation Where HUserID = '" + CurUserID + "' union all select 166351 hcusid)"; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | |
| | | } |
| | | } |
| | | #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 |
| | | } |
| | | } |