|  |  |  | 
|---|
|  |  |  | using System.Collections.Generic; | 
|---|
|  |  |  | using System.Data; | 
|---|
|  |  |  | using System.Data.SqlClient; | 
|---|
|  |  |  | using System.IO; | 
|---|
|  |  |  | using System.Web; | 
|---|
|  |  |  | using System.Web.Http; | 
|---|
|  |  |  | using WebAPI.Models; | 
|---|
|  |  |  | using WebAPI.Service; | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public class Gy_EmployeeController : ApiController | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //获取系统参数 | 
|---|
|  |  |  | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); | 
|---|
|  |  |  | public DBUtility.ClsPub.Enum_BillStatus BillStatus; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private json objJsonResult = new json(); | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | DataSet ds; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 返回职员列表 | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  | //编辑权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee", 1, false, user)) | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee_Query", 1, false, user)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | 
|---|
|  |  |  | //        return objJsonResult; | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  | //} | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 保存按钮 | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | 
|---|
|  |  |  | long HCTPrjID = list[0].HCTPrjID; | 
|---|
|  |  |  | long HProcID = list[0].HProcID; | 
|---|
|  |  |  | string HBasePay = list[0].HBasePay; | 
|---|
|  |  |  | DateTime HInComDate = list[0].HInComDate; | 
|---|
|  |  |  | DateTime HDimissionDate = list[0].HDimissionDate; | 
|---|
|  |  |  | DateTime HInComDate = list[0].HInComDate;   //进厂日期 | 
|---|
|  |  |  | DateTime HDimissionDate = list[0].HDimissionDate;   //离职日期 (允许NULL) | 
|---|
|  |  |  | bool HOverType = list[0].HOverType; | 
|---|
|  |  |  | string HEmpType = list[0].HEmpType; | 
|---|
|  |  |  | string HOtherDeduct3 = list[0].HOtherDeduct3; | 
|---|
|  |  |  | 
|---|
|  |  |  | string HMedicare = list[0].HMedicare; | 
|---|
|  |  |  | bool HNoBrushFlag = list[0].HNoBrushFlag; | 
|---|
|  |  |  | bool HShiftFlag = list[0].HShiftFlag; | 
|---|
|  |  |  | DateTime HContactDate = list[0].HContactDate; | 
|---|
|  |  |  | //DateTime HContactDate = list[0].HContactDate;  //合同日期 | 
|---|
|  |  |  | bool HStopwagesFlag = list[0].HStopwagesFlag; | 
|---|
|  |  |  | string HDimissionReason = list[0].HDimissionReason; | 
|---|
|  |  |  | long HDormID = list[0].HDormID; | 
|---|
|  |  |  | string HArchivesNo = list[0].HArchivesNo; | 
|---|
|  |  |  | DateTime HStayCardEDate = list[0].HStayCardEDate; | 
|---|
|  |  |  | DateTime HCheckCardEDate = Convert.ToDateTime("1900/1/1"); | 
|---|
|  |  |  | DateTime HStayCardEDate = list[0].HStayCardEDate;   //暂住证到期日 | 
|---|
|  |  |  | DateTime HCheckCardEDate = Convert.ToDateTime("1900/1/1");  //审检证到期日 | 
|---|
|  |  |  | string HJobCardNo = list[0].HJobCardNo ?? ""; | 
|---|
|  |  |  | DateTime HJobCardEDate = Convert.ToDateTime("1900/1/1"); | 
|---|
|  |  |  | DateTime HJobCardEDate = Convert.ToDateTime("1900/1/1");  //就业证到期日 | 
|---|
|  |  |  | string HWorkType = list[0].HWorkType; | 
|---|
|  |  |  | long HContractYear = list[0].HContractYear; | 
|---|
|  |  |  | DateTime HContractBDate = list[0].HContractBDate; | 
|---|
|  |  |  | DateTime HContractEDate = list[0].HContractEDate; | 
|---|
|  |  |  | DateTime HContractBDate = list[0].HContractBDate;  //合同开始日 | 
|---|
|  |  |  | DateTime HContractEDate = list[0].HContractEDate;   //合同到期日 | 
|---|
|  |  |  | string HInsuranceNo = list[0].HInsuranceNo; | 
|---|
|  |  |  | DateTime HInsuranceDate = list[0].HInsuranceDate; | 
|---|
|  |  |  | DateTime HInsuranceDate = list[0].HInsuranceDate;   //参保日期 | 
|---|
|  |  |  | bool HInsuranceStatus = list[0].HInsuranceStatus; | 
|---|
|  |  |  | DateTime HSignDate = list[0].HSignDate; | 
|---|
|  |  |  | DateTime HSignDate =  Convert.ToDateTime("1900/1/1");  //签约日期 | 
|---|
|  |  |  | bool HSignStatus = list[0].HSignStatus; | 
|---|
|  |  |  | string HOldCompany = list[0].HOldCompany ?? ""; | 
|---|
|  |  |  | string HMarr = list[0].HMarr ?? ""; | 
|---|
|  |  |  | 
|---|
|  |  |  | string HSpec = list[0].HSpec ?? ""; | 
|---|
|  |  |  | string HCompLev = list[0].HCompLev ?? ""; | 
|---|
|  |  |  | string HEngLev = list[0].HEngLev ?? ""; | 
|---|
|  |  |  | DateTime HGradDate = list[0].HGradDate; | 
|---|
|  |  |  | DateTime HGradDate = list[0].HGradDate;  //毕业日期 | 
|---|
|  |  |  | string HGradSchool = list[0].HGradSchool ?? ""; | 
|---|
|  |  |  | string HSalaryLev = list[0].HSalaryLev ?? ""; | 
|---|
|  |  |  | long HDutyID = list[0].HDutyID; | 
|---|
|  |  |  | 
|---|
|  |  |  | string HStdDayPay = list[0].HStdDayPay ?? ""; | 
|---|
|  |  |  | string HMinDayPay = list[0].HMinDayPay ?? ""; | 
|---|
|  |  |  | string HMinMonthPay = list[0].HMinMonthPay ?? ""; | 
|---|
|  |  |  | DateTime HMadeDate = list[0].HMadeDate; | 
|---|
|  |  |  | //DateTime HMadeDate = list[0].HMadeDate;  //建立日期 | 
|---|
|  |  |  | string HEmpRate = list[0].HEmpRate ?? ""; | 
|---|
|  |  |  | string HExamRate = list[0].HExamRate ?? ""; | 
|---|
|  |  |  | DateTime HHealthCardEDate = Convert.ToDateTime("1900/1/1"); | 
|---|
|  |  |  | DateTime HHealthCardEDate = Convert.ToDateTime("1900/1/1");  //健康证到期日 | 
|---|
|  |  |  | long HUSEORGID = list[0].HUSEORGID; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ////判断权限 | 
|---|
|  |  |  | //if (!ClsPub.Security_Log(msg5, 1, false, msg4)) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HEmpType,HPayType,HOverType,HNoBrushFlag,HShiftFlag,HStopwagesFlag" + | 
|---|
|  |  |  | ",HPostalCode,HBank,HBasePay,HExamLevPostMoney,HBSTDeptID" + | 
|---|
|  |  |  | ",HOtherDeduct3,HInsurance,HMedicare,HDrydock" + | 
|---|
|  |  |  | ",HBankAccount,HGroupID,HDeptID,HWorkTypeID,HCTPrjID,HAddress" + | 
|---|
|  |  |  | ",HBankAccount,HGroupID,HDeptID,HWorkTypeID,HCTPrjID,HUSEORGID,HAddress" + | 
|---|
|  |  |  | ") " + | 
|---|
|  |  |  | " Values('" + HNumber + "','" + HName + "','" + HShortNumber + "'," + HEmpRate.ToString() + "," + HExamRate.ToString() + | 
|---|
|  |  |  | "," + HLevel + "," + HParentID + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + HHighestPay.ToString() + "," + HOverPayRate.ToString() + | 
|---|
|  |  |  | "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "'" + ",'" + HHelpCode + "'," + HInsuranceSubsidy.ToString() + "" + | 
|---|
|  |  |  | ",'" + HBirthDay + "','" + HGradDate + "','" + HInsuranceDate + "','" + HContractBDate + "','" + HContractEDate + "'" + | 
|---|
|  |  |  | " Values('" + HNumber + "','" + HName + "','" + HShortNumber + "','" + HEmpRate.ToString() + "','" + HExamRate.ToString() + | 
|---|
|  |  |  | "','" + HLevel + "','" + HParentID + "','" + Convert.ToString(HEndFlag ? 1 : 0) + "','" + HHighestPay.ToString() + "','" + HOverPayRate.ToString() + | 
|---|
|  |  |  | "','" + Convert.ToString(HStopflag ? 1 : 0) + "','" + HRemark + "'" + ",'" + HHelpCode + "','" + HInsuranceSubsidy.ToString() + | 
|---|
|  |  |  | "','" + HBirthDay + "','" + HGradDate + "','" + HInsuranceDate + "','" + HContractBDate + "','" + HContractEDate + "'" + | 
|---|
|  |  |  | ",'" + HJobCardEDate + "','" + HCheckCardEDate + "','" + HStayCardEDate + "','" + HHealthCardEDate + "'" + | 
|---|
|  |  |  | "," + HAge.ToString() + ",'" + HSalaryLev + "'," + HContractYear.ToString() + "," + Convert.ToString(HInsuranceStatus ? 1 : 0) + "," + Convert.ToString(HSignStatus ? 1 : 0) + | 
|---|
|  |  |  | ",'" + HSex + "','" + HMarr + "','" + HBlighty + "','" + HNation + "','" + HBlightyType + "'" + | 
|---|
|  |  |  | ",'" + HAge.ToString() + "','" + HSalaryLev + "','" + HContractYear.ToString() + "','" + Convert.ToString(HInsuranceStatus ? 1 : 0) + "','" + Convert.ToString(HSignStatus ? 1 : 0) + | 
|---|
|  |  |  | "','" + HSex + "','" + HMarr + "','" + HBlighty + "','" + HNation + "','" + HBlightyType + "'" + | 
|---|
|  |  |  | ",'" + HGovStatus + "','" + HBloodType + "','" + HStature + "','" + HAvoird + "','" + HKnowLev + "'" + | 
|---|
|  |  |  | ",'" + HProTitleID + "','" + HGradSchool + "','" + HEngLev + "','" + HCompLev + "','" + HSpec + "'" + | 
|---|
|  |  |  | ",'" + HEmail + "','" + HNowAdd + "','" + HHomeAdd + "','" + HIDCard + "','" + HLinkPhone + "','" + HMobilePhone + "','" + HFax + "'" + | 
|---|
|  |  |  | ",'" + HOldCompany + "','" + HInsuranceNo + "','" + HJobCardNo + "','" + HArchivesNo + "','" + HWorkType + "','" + HDimissionReason + "'" + | 
|---|
|  |  |  | ",'" + HDimissionDate + "','" + HInComDate + "','" + HSignDate + "','" + HRelDate + "'" + | 
|---|
|  |  |  | "," + HPostID.ToString() + "," + HDormID.ToString() + "," + HDutyID.ToString() + "," + HLeftMoneyRate.ToString() + | 
|---|
|  |  |  | ",'" + HEmpType + "'" + ",'" + HPayType + "'" + "," + DBUtility.ClsPub.BoolToString(HOverType) + "" + "," + DBUtility.ClsPub.BoolToString(HNoBrushFlag) + "" + "," + DBUtility.ClsPub.BoolToString(HShiftFlag) + "" + "," + DBUtility.ClsPub.BoolToString(HStopwagesFlag) + "" + | 
|---|
|  |  |  | ",'" + HPostalCode + "','" + HBank + "'," + HBasePay.ToString() + "," + HExamLevPostMoney.ToString() + ",'" + HBSTDeptID + "'" + | 
|---|
|  |  |  | "," + HOtherDeduct3.ToString() + "" + "," + HInsurance.ToString() + "" + "," + HMedicare.ToString() + "" + "," + HDrydock.ToString() + "" + | 
|---|
|  |  |  | ",'" + HBankAccount + "'" + "," + HGroupID.ToString() + "" + "," + HDeptID.ToString() + "," + HWorkTypeID.ToString() + "," + HCTPrjID.ToString() + ",'" + HAddress + "'" + "')", ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | ",'" + HPostID.ToString() + "','" + HDormID.ToString() + "','" + HDutyID.ToString() + "','" + HLeftMoneyRate.ToString() + | 
|---|
|  |  |  | "','" + HEmpType + "'" + ",'" + HPayType + "'" + ",'" + DBUtility.ClsPub.BoolToString(HOverType) + "','" + DBUtility.ClsPub.BoolToString(HNoBrushFlag) + "','" + DBUtility.ClsPub.BoolToString(HShiftFlag) + "','" + DBUtility.ClsPub.BoolToString(HStopwagesFlag) + | 
|---|
|  |  |  | "','" + HPostalCode + "','" + HBank + "','" + HBasePay.ToString() + "','" + HExamLevPostMoney.ToString() + "','" + HBSTDeptID + "'" + | 
|---|
|  |  |  | ",'" + HOtherDeduct3.ToString() + "','" + HInsurance.ToString() + "','" + HMedicare.ToString() + "','" + HDrydock.ToString() + | 
|---|
|  |  |  | "','" + HBankAccount + "'" + ",'" + HGroupID.ToString() + "','" + HDeptID.ToString() + "','" + HWorkTypeID.ToString() + "','" + HCTPrjID.ToString() + "','" + HUSEORGID + "','" + HAddress + "')", ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | //修改上级为非末级代码 | 
|---|
|  |  |  | oCN.RunProc("Update Gy_Employee set HStopflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | oCN.Commit(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RollBack(); | 
|---|
|  |  |  | //oCN.RollBack(); | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "Exception!" + e.Message; | 
|---|
|  |  |  | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ///// <summary> | 
|---|
|  |  |  | ///// 保存职员 | 
|---|
|  |  |  | ///// </summary> | 
|---|
|  |  |  | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | oCN.BeginTran();//开始事务 | 
|---|
|  |  |  | string HNumber = ""; | 
|---|
|  |  |  | string HName = ""; | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from Gy_Employee where HItemID=" + HItemID, "Gy_Employee"); | 
|---|
|  |  |  | if (ds == null || ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | objJsonResult.Message = "没有数据,无法删除!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; ; | 
|---|
|  |  |  | }else if (ds.Tables[0].Rows[0]["HCheckEmp"] !=null && ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "职员已经审核不能删除!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | HNumber = ds.Tables[0].Rows[0]["HNumber"].ToString(); | 
|---|
|  |  |  | HName = ds.Tables[0].Rows[0]["HName"].ToString(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]); | 
|---|
|  |  |  | if (HStopflag) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.RunProc("update Gy_Employee set HStopflag=1 where HItemID=" + HItemID); | 
|---|
|  |  |  | oCN.RunProc("delete from Gy_Employee where HItemID=" + HItemID); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //写入日志 | 
|---|
|  |  |  | string Operation = "删除";                                          //操作 | 
|---|
|  |  |  | string ComputerName = System.Net.Dns.GetHostName();                 //设备名称 | 
|---|
|  |  |  | string WorkList = Operation + "职员,职员代码:" + HNumber + ";职员名称:" + HName ;         //操作详情 | 
|---|
|  |  |  | string MvarReportTitle = "职员列表";                                //操作模块 | 
|---|
|  |  |  | string SystemName = "LMES-" + MvarReportTitle + "模块";             //操作模块 | 
|---|
|  |  |  | string IPAddress = ""; | 
|---|
|  |  |  | //string IPAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();   //IP地址 | 
|---|
|  |  |  | //string IPAddress = System.Web.HttpContext.Current.Request.UserHostAddress; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " + | 
|---|
|  |  |  | "(getdate(),'" + user + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','" + Operation + "')" | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.Commit();//提交事务 | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 职员审核、反审核 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="HInterID">单据ID</param> | 
|---|
|  |  |  | /// <param name="IsAudit">审核(0),反审核(1)</param> | 
|---|
|  |  |  | /// <param name="CurUserName">审核人</param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | [Route("Gy_Employee/AuditGy_Employee")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object AuditGy_Employee(int HInterID, int IsAudit, string CurUserName) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //审核权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee_Check", 1, false, CurUserName)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "审核失败!无权限!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var ds = oCN.RunProcReturn("select * from Gy_Employee where HItemID=" + HInterID, "Gy_Employee"); | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (IsAudit == 0)  //审核判断 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "单据已审核!不能再次审核!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (IsAudit == 1) //反审核判断 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (ds.Tables[0].Rows[0]["HCheckEmp"].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 Gy_Employee set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "审核成功"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (IsAudit == 1) //反审核判断 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RunProc("update Gy_Employee set HCheckEmp='',HCheckTime=null where HItemID=" + 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 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 职员禁用、反禁用 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="HInterID">单据ID</param> | 
|---|
|  |  |  | /// <param name="IsStop">禁用(0),反禁用(1)</param> | 
|---|
|  |  |  | /// <param name="CurUserName">审核人</param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | [Route("Gy_Employee/StopGy_Employee")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object StopGy_Employee(int HInterID, int IsStop, string CurUserName) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //审核权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee_Stop", 1, false, CurUserName)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "禁用失败!无权限!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var ds = oCN.RunProcReturn("select * from Gy_Employee where HItemID=" + HInterID, "Gy_Employee"); | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (IsStop == 0)  //禁用判断 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "单据已禁用!不能再次禁用!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (IsStop == 1) //反禁用判断 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (ds.Tables[0].Rows[0]["HStopEmp"].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 (IsStop == 0)  //禁用判断 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RunProc("update Gy_Employee set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "禁用成功"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (IsStop == 1) //反禁用判断 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RunProc("update Gy_Employee set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + 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 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 职员 金蝶同步 | 
|---|
|  |  |  | [Route("Gy_Employee/SaveGy_EmployeeListApi")] | 
|---|
|  |  |  | [HttpPost] | 
|---|
|  |  |  | public object SaveGy_EmployeeListApi([FromBody] JObject msg) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var _value = msg["model"].ToString(); | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | ListModels oListModels = new ListModels(); | 
|---|
|  |  |  | List<Model.ClsGy_Employee_Model> lsmain = new List<Model.ClsGy_Employee_Model>(); | 
|---|
|  |  |  | lsmain = oListModels.getObjectByJson_Gy_Employee(_value); | 
|---|
|  |  |  | string sql = string.Empty; | 
|---|
|  |  |  | //保存 | 
|---|
|  |  |  | oCN.BeginTran(); | 
|---|
|  |  |  | sql = $"delete Gy_Employee where HItemID = {lsmain[0].HItemID}"; | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  | sql = "set identity_insert Gy_Employee on"; | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.RunProc($@"insert into Gy_Employee(HItemID,HNumber, HName, HShortNumber, HEmpRate, HExamRate | 
|---|
|  |  |  | ,HLevel,HParentID,HEndflag,HHighestPay,HOverPayRate | 
|---|
|  |  |  | ,HStopflag,HRemark,HHelpCode,HInsuranceSubsidy | 
|---|
|  |  |  | ,HBirthday,HGradDate,HInsuranceDate,HContractBDate,HContractEDate | 
|---|
|  |  |  | ,HJobCardEDate,HCheckCardEDate,HStayCardEDate,HHealthCardEDate | 
|---|
|  |  |  | ,HAge,HSalaryLev,HContractYear,HInsuranceStatus,HSignStatus | 
|---|
|  |  |  | ,HSex,HMarr,HBlighty,HNation,HBlightyType | 
|---|
|  |  |  | ,HGovStatus,HBloodType,HStature,HAvoird,HKnowLev | 
|---|
|  |  |  | ,HProTitleID,HGradSchool,HEngLev,HCompLev,HSpec | 
|---|
|  |  |  | ,HEmail,HNowAdd,HHomeAdd,HIDCard,HLinkPhone,HMobilePhone,HFax | 
|---|
|  |  |  | ,HOldCompany,HInsuranceNo,HJobCardNo,HArchivesNo,HWorkType,HDimissionReason | 
|---|
|  |  |  | ,HDimissionDate,HInComDate,HSignDate,HRelDate | 
|---|
|  |  |  | ,HPostID,HDormID,HDutyID,HLeftMoneyRate | 
|---|
|  |  |  | ,HEmpType,HPayType,HOverType,HNoBrushFlag,HShiftFlag,HStopwagesFlag | 
|---|
|  |  |  | ,HPostalCode,HBank,HBasePay,HExamLevPostMoney,HBSTDeptID | 
|---|
|  |  |  | ,HOtherDeduct3,HInsurance,HMedicare,HDrydock | 
|---|
|  |  |  | ,HBankAccount,HGroupID,HDeptID,HWorkTypeID,HCTPrjID,HUSEORGID,HAddress) | 
|---|
|  |  |  | values({lsmain[0].HItemID},'{lsmain[0].HNumber}','{lsmain[0].HName}','{lsmain[0].HShortNumber}',{lsmain[0].HEmpRate},{lsmain[0].HExamRate},{lsmain[0].HLevel},{lsmain[0].HParentID},{Convert.ToString(lsmain[0].HEndFlag ? 1 : 0)},{lsmain[0].HHighestPay},{lsmain[0].HOverPayRate},{Convert.ToString(lsmain[0].HStopflag ? 1 : 0) },'{lsmain[0].HRemark}','{lsmain[0].HHelpCode}',{lsmain[0].HInsuranceSubsidy},'{lsmain[0].HBirthDay}','{lsmain[0].HGradDate}','{lsmain[0].HInsuranceDate}','{lsmain[0].HContractBDate}','{lsmain[0].HContractEDate}','{lsmain[0].HJobCardEDate}','{lsmain[0].HCheckCardEDate}','{lsmain[0].HStayCardEDate}','{lsmain[0].HHealthCardEDate}',{lsmain[0].HAge},'{lsmain[0].HSalaryLev}',{lsmain[0].HContractYear},{lsmain[0].HInsuranceStatus},{lsmain[0].HSignStatus},'{lsmain[0].HSex}','{lsmain[0].HMarr}','{lsmain[0].HBlighty}','{lsmain[0].HNation}','{lsmain[0].HBlightyType}','{lsmain[0].HGovStatus}','{lsmain[0].HBloodType}','{lsmain[0].HStature}','{lsmain[0].HAvoird}','{lsmain[0].HKnowLev}','{lsmain[0].HProTitleID}','{lsmain[0].HGradSchool}','{lsmain[0].HEngLev}','{lsmain[0].HCompLev}','{lsmain[0].HSpec}','{lsmain[0].HEmail}','{lsmain[0].HNowAdd}','{lsmain[0].HHomeAdd}','{lsmain[0].HIDCard}','{lsmain[0].HLinkPhone}','{lsmain[0].HMobilePhone}','{lsmain[0].HFax}','{lsmain[0].HOldCompany}','{lsmain[0].HInsuranceNo}','{lsmain[0].HJobCardNo}','{lsmain[0].HArchivesNo}','{lsmain[0].HWorkType}','{lsmain[0].HDimissionReason}','{lsmain[0].HDimissionDate}','{lsmain[0].HInComDate}','{lsmain[0].HSignDate}','{lsmain[0].HRelDate}',{lsmain[0].HPostID},{lsmain[0].HDormID},{lsmain[0].HDutyID},{lsmain[0].HLeftMoneyRate},'{lsmain[0].HEmpType}','{lsmain[0].HPayType}','{lsmain[0].HOverType}',{lsmain[0].HNoBrushFlag},{lsmain[0].HShiftFlag},{lsmain[0].HStopwagesFlag},'{lsmain[0].HPostalCode}','{lsmain[0].HBank}',{lsmain[0].HBasePay},{lsmain[0].HExamLevPostMoney},{lsmain[0].HBSTDeptID},{lsmain[0].HOtherDeduct3},{lsmain[0].HInsurance},{lsmain[0].HMedicare},{lsmain[0].HDrydock},'{lsmain[0].HBankAccount}',{lsmain[0].HGroupID},{lsmain[0].HDeptID},{lsmain[0].HWorkTypeID},{lsmain[0].HCTPrjID},{lsmain[0].HUSEORGID},'{lsmain[0].HAddress}')", ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | //修改上级为非末级代码 | 
|---|
|  |  |  | sql = "set identity_insert Gy_Employee off"; | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  | oCN.Commit(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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_Employee/Gy_EmployeeViewApi")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public json Gy_EmployeeViewApi(string Number, string Type) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string sql = string.Empty; | 
|---|
|  |  |  | string sReturn = ""; | 
|---|
|  |  |  | if (oSystemParameter.ShowBill(ref sReturn) == true) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //系统参数是否为私有云模式,N为公有云模式,Y为私有云模式 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CloudMode == "Y") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | #region [私有云模式,直接调用数据库存储过程更新] | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.BeginTran(); | 
|---|
|  |  |  | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | DataSet DS = oCn.RunProcReturn("exec h_p_WMS_ERPBasicInfoToLocal '" + Number + "','" + Type + "'", "h_p_WMS_ERPBasicInfoToLocal"); | 
|---|
|  |  |  | if (DS == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "基础资料同步失败"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBack"]) == "2") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "ERP中不存在该代码"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "基础资料同步成功"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "Exception!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | #region [公有云模式,调用WEBAPI的方式进行更新] | 
|---|
|  |  |  | var json = new | 
|---|
|  |  |  | { | 
|---|
|  |  |  | CreateOrgId = 0, | 
|---|
|  |  |  | Number = Number, | 
|---|
|  |  |  | Id = "" | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | #region [金蝶部分] | 
|---|
|  |  |  | //登录金蝶 | 
|---|
|  |  |  | var loginRet = InvokeHelper.Login(); | 
|---|
|  |  |  | var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); | 
|---|
|  |  |  | //判断是否登录成功 | 
|---|
|  |  |  | if (isSuccess < 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = loginRet; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查看 获取数据 | 
|---|
|  |  |  | var _result = InvokeHelper.View("BD_Empinfo", JsonConvert.SerializeObject(json)); | 
|---|
|  |  |  | var _saveObj = JObject.Parse(_result); | 
|---|
|  |  |  | //判断数据是否获取成功 | 
|---|
|  |  |  | if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "金蝶职员同步失败jsonRoot:" + _result; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  | //获取数据 | 
|---|
|  |  |  | DataSet Ds; | 
|---|
|  |  |  | Ds = oCN.RunProcReturn("select * from Gy_Employee where HNumber = '" + Number + "'", "Gy_Employee"); | 
|---|
|  |  |  | if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"].ToString()) != 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region [表数据赋值] | 
|---|
|  |  |  | var jsonData = new | 
|---|
|  |  |  | { | 
|---|
|  |  |  | HItemID = _saveObj["Result"]["Result"]["PersonId_Id"], | 
|---|
|  |  |  | HERPItemID = _saveObj["Result"]["Result"]["PersonId_Id"], | 
|---|
|  |  |  | HNumber = _saveObj["Result"]["Result"]["Number"], | 
|---|
|  |  |  | HName         = _saveObj["Result"]["Result"]["Name"][0]["Value"], | 
|---|
|  |  |  | HShortNumber  = _saveObj["Result"]["Result"]["Number"], | 
|---|
|  |  |  | HParentID     = 0, | 
|---|
|  |  |  | HLevel        = 1, | 
|---|
|  |  |  | HEndFlag      = 1, | 
|---|
|  |  |  | HStopflag     = _saveObj["Result"]["Result"]["ForbidStatus"].ToString() == "A" ? 0 : 1, | 
|---|
|  |  |  | HRemark       = "CLD-ERP导入", | 
|---|
|  |  |  | HDeptID       = 0, | 
|---|
|  |  |  | HGroupID      = 0, | 
|---|
|  |  |  | HUseFlag      = "已使用", | 
|---|
|  |  |  | HMakeTime     = _saveObj["Result"]["Result"]["CreateDate"], | 
|---|
|  |  |  | HCREATEORGID  = _saveObj["Result"]["Result"]["CreateOrgId_Id"], | 
|---|
|  |  |  | HUSEORGID = _saveObj["Result"]["Result"]["UseOrgId_Id"], | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  | // 删除主表对应数据 | 
|---|
|  |  |  | sql = $"delete from Gy_Employee where HItemID = " + jsonData.HItemID + " and HNumber = '" + Number + "'"; | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sql = "set identity_insert Gy_Employee on"; | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //插入表 | 
|---|
|  |  |  | sql = $@" | 
|---|
|  |  |  | insert into Gy_Employee | 
|---|
|  |  |  | (HItemID,HERPItemID,HNumber,HName,HShortNumber,HParentID | 
|---|
|  |  |  | ,HLevel,HEndFlag,HStopflag,HRemark,HDeptID,HGroupID,HUseFlag,HMakeTime,HCREATEORGID,HUSEORGID | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | values | 
|---|
|  |  |  | ({jsonData.HItemID},{jsonData.HItemID},'{jsonData.HNumber}','{jsonData.HName}', | 
|---|
|  |  |  | '{jsonData.HShortNumber}',{jsonData.HParentID},{jsonData.HLevel},{jsonData.HEndFlag},{jsonData.HStopflag},'{jsonData.HRemark}',{jsonData.HDeptID},{jsonData.HGroupID},'{jsonData.HUseFlag}','{jsonData.HMakeTime}',{jsonData.HCREATEORGID},{jsonData.HUSEORGID})"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sql = "set identity_insert Gy_Employee off"; | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "职员同步成功!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "基础资料读取失败!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 根据班组返回职员信息 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 根据班组返回职员信息 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | [Route("Gy_EmployeeController/GetEmpInfoByGroup_Json")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object GetEmpInfoByGroup_Json(Int64 HGroupID) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //返回列表信息 | 
|---|
|  |  |  | ds = oCN.RunProcReturn("exec h_p_Pay_GetEmployeeByGroup " + HGroupID.ToString(), "h_p_Pay_GetEmployeeByGroup"); | 
|---|
|  |  |  | //ds = oCN.RunProcReturn("select * from h_v_IF_EmployeeList where 禁用标记='' and HGroupID=" + HGroupID + " order by 职员代码", "h_v_IF_EmployeeList"); | 
|---|
|  |  |  | if (ds == null || ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "所选班组无对应职员信息!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  | //添加列名 | 
|---|
|  |  |  | 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 = 1; | 
|---|
|  |  |  | 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 职员附件上传 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 文件上传 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | [Route("Gy_Employee_UploadFile")] | 
|---|
|  |  |  | [HttpPost] | 
|---|
|  |  |  | public object Gy_Employee_UploadFile() | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string HBillNo = HttpContext.Current.Request.Params["HBillNo"];  //单据号 | 
|---|
|  |  |  | string HRemark = HttpContext.Current.Request.Params["HRemark"];  //备注 | 
|---|
|  |  |  | string HUserName = HttpContext.Current.Request.Params["HUserName"];  //创建人 | 
|---|
|  |  |  | HttpPostedFile files = HttpContext.Current.Request.Files["file"]; | 
|---|
|  |  |  | string path = HttpContext.Current.Server.MapPath("~/../Files/Gy_Employee/" + HBillNo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName); | 
|---|
|  |  |  | if (dyResult != null && dyResult.result == 1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "上传成功!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = dyResult.returnval; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | dynamic Result_Ob = new { result = 1, returnval = "上传成功!" }; | 
|---|
|  |  |  | string filePath = Path.GetFullPath(files.FileName);//文件上传路径 | 
|---|
|  |  |  | string fileExtension = Path.GetExtension(files.FileName);// 文件扩展名 | 
|---|
|  |  |  | string filename = files.FileName;//文件名 | 
|---|
|  |  |  | string fileSavePath = path;// 上传保存路径 | 
|---|
|  |  |  | int filesize = files.ContentLength;//获取上传文件的大小单位为字节byte | 
|---|
|  |  |  | int Maxsize = 40000 * 1024;//定义上传文件的最大空间大小为40M | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (files == null || files.ContentLength <= 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Result_Ob = new { result = 0, returnval = "文件不能为空!" }; | 
|---|
|  |  |  | return Result_Ob; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (filesize >= Maxsize) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Result_Ob = new { result = 0, returnval = "上传文件超过40M,不能上传!" }; | 
|---|
|  |  |  | return Result_Ob; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string fileurl = Path.Combine(fileSavePath, filename); | 
|---|
|  |  |  | if (Directory.Exists(fileurl) == true)  //如果存在重名文件就提示 | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Result_Ob = new { result = 0, returnval = "存在同名文件!" }; | 
|---|
|  |  |  | return Result_Ob; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //删除数据表数据 | 
|---|
|  |  |  | ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList"); | 
|---|
|  |  |  | if (Directory.Exists(path)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | File.Delete(fileurl);      //删除指定文件 | 
|---|
|  |  |  | files.SaveAs(fileurl); | 
|---|
|  |  |  | string StrPath = "/files/Gy_Employee/" + HBillNo + "/" + filename; | 
|---|
|  |  |  | if (File.Exists(fileurl)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //这里可以执行一些其它的操作,比如更新数据库 | 
|---|
|  |  |  | //写入数据表 | 
|---|
|  |  |  | oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + | 
|---|
|  |  |  | ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + | 
|---|
|  |  |  | ",HFileClsID,HSourceBillNo" + | 
|---|
|  |  |  | ") values('" | 
|---|
|  |  |  | + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + | 
|---|
|  |  |  | ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + | 
|---|
|  |  |  | "','" + 0 + "','" + HBillNo + | 
|---|
|  |  |  | "') "); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Directory.CreateDirectory(fileSavePath); //添加文件夹 | 
|---|
|  |  |  | files.SaveAs(fileurl); | 
|---|
|  |  |  | string StrPath = "/files/Gy_Employee/" + HBillNo + "/" + filename; | 
|---|
|  |  |  | if (File.Exists(fileurl)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //这里可以执行一些其它的操作,比如更新数据库 | 
|---|
|  |  |  | //写入数据表 | 
|---|
|  |  |  | oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + | 
|---|
|  |  |  | ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + | 
|---|
|  |  |  | ",HFileClsID,HSourceBillNo" + | 
|---|
|  |  |  | ") values('" | 
|---|
|  |  |  | + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + | 
|---|
|  |  |  | ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + | 
|---|
|  |  |  | "','" + 0 + "','" + HBillNo + | 
|---|
|  |  |  | "') "); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Result_Ob = new { result = 0, returnval = e.Message }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return Result_Ob; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 根据单据号查找上传文件列表 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="sWhere"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | [Route("Gy_Employee_Filelist")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object Gy_Employee_Filelist(string HBillNo) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var url = fileip + "/files/Gy_Employee/" + HBillNo + "/"; | 
|---|
|  |  |  | //@"C:\\files\\" | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url  from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList"); | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 根据ID,单据号,文件名 删除文件 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="sWhere"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | [Route("Gy_Employee_DeleteFilelist")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object Gy_Employee_DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID); | 
|---|
|  |  |  | string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/EquipTechParamFolder/" + HSourceBillNo), HFileName); | 
|---|
|  |  |  | File.Delete(fileurl);      //删除指定文件 | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "删除成功!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "Exception!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|