| | |
| | | } |
| | | } |
| | | #endregion |
| | | /// <summary> |
| | | /// 新增模具档案-保存按钮 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | |
| | | #region[器具档案保存与修改保存方法] |
| | | [Route("Gy_Mould_Edit/AddBill")] |
| | | [HttpPost] |
| | | public object AddBill([FromBody] JObject oMain) |
| | |
| | | string HMouldUseStatus = mainList[0].HMouldUseStatus; |
| | | int HCREATEORGID = mainList[0].HCREATEORGID; |
| | | int HUSEORGID = mainList[0].HUSEORGID; |
| | | bool HTransPackFlag = mainList[0].HTransPackFlag; //周转容器标记 |
| | | bool HSendPackFlag = mainList[0].HSendPackFlag; //发货容器标记 |
| | | int HMouldLength = mainList[0].HMouldLength; //长 |
| | | int HMouldWidth = mainList[0].HMouldWidth; //宽 |
| | | int HMouldHeight = mainList[0].HMouldHeight; //高 |
| | | int HMouldFoldHeight = mainList[0].HMouldFoldHeight; //折叠高度 |
| | | |
| | | int HUserID = mainList[0].HUserID; // 使用人(Gy_Employee) |
| | | string HBrand = mainList[0].HBrand; // 品牌 |
| | | string HCalibrationType = mainList[0].HCalibrationType; // 校准类型 (内/外校) |
| | | string HLocation = mainList[0].HLocation; // 位置 |
| | | DateTime HCalibrationDate = mainList[0].HCalibrationDate; // 校准日期 |
| | | string HCalibrationCycle = mainList[0].HCalibrationCycle; // 校准周期 |
| | | string HProductDesignSize = mainList[0].HProductDesignSize; // 产品设计尺寸 |
| | | string HGaugeDesignSize = mainList[0].HGaugeDesignSize; // 检具设计尺寸 |
| | | int HProductQTY = mainList[0].HProductQTY; // 产品数量 |
| | | |
| | | //保存前控制========================================= |
| | | string HBillNote = ""; |
| | |
| | | ",HPrintQty,HMouldStatus,HWhID,HRoutingID,HCaveQty" + |
| | | ",HBomID,HVersion,HSPGroupID,HSPID,HDesignLife,HNowSupID,HNowSupTypeID" + |
| | | ",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID,HBarCode,HMadeSupID" + |
| | | ",HMouldClass,HNowWHID,HNowSPID,HInitLife,HMouldUseStatus,HCREATEORGID,HUSEORGID) " + |
| | | " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + |
| | | ",HMouldClass,HNowWHID,HNowSPID,HInitLife,HMouldUseStatus,HCREATEORGID,HUSEORGID " + |
| | | ",HMouldLength,HMouldWidth,HMouldHeight,HMouldFoldHeight,HTransPackFlag,HSendPackFlag," + |
| | | "HUserID,HBrand,HCalibrationType,HLocation,HCalibrationDate,HCalibrationCycle,HProductDesignSize,HGaugeDesignSize,HProductQTY ) " + |
| | | |
| | | " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + |
| | | "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()" + |
| | | ",'" + HMouldNo + "','" + HName + "','" + HModel + "','" + HModel2 + "','" + HDiameter + "'" + |
| | | ",'" + HSubjoin + "','" + HSubjoin2 + "','" + HPICNo + "','" + HWorkMaterModel + "'" + |
| | |
| | | "," + HPrintQty + ",'" + HMouldStatus + "'," + HWHID + "," + HRoutingID + "," + HCaveQty + |
| | | "," + HBOMID + ",'" + HVersion + "'," + HSPGroupID + "," + HSPID + ",'" + HDesignLife + "','" + HNowSupID + "','" + HNowSupTypeID + "'" + |
| | | ",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'," + HMadeSupID + |
| | | ",'"+ HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + "','" + HMouldUseStatus + "',"+ HCREATEORGID + ","+ HUSEORGID + ") "); |
| | | ",'" + HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + "','" + HMouldUseStatus + "'," + HCREATEORGID + "," + HUSEORGID + |
| | | "," + HMouldLength + "," + HMouldWidth + "," + HMouldHeight + "," + HMouldFoldHeight + "," + Convert.ToString(HTransPackFlag ? 1 : 0) + "," + Convert.ToString(HSendPackFlag ? 1 : 0) + "," + |
| | | "'" + HUserID + "','" + HBrand + "','" + HCalibrationType + "','" + HLocation + "','" + HCalibrationDate + "','" + HCalibrationCycle + "','" + HProductDesignSize + "','" + HGaugeDesignSize + "','" + HProductQTY + "') "); |
| | | |
| | | //子表 |
| | | oCN.RunProc("Insert into Gy_MouldFileSub " + |
| | |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.HInterID = HInterID.ToString(); |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 修改单据-保存按钮 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Gy_Mould_Edit/AddBill1")] |
| | | [HttpPost] |
| | | public object AddBill1([FromBody] JObject oMain) |
| | |
| | | string HMouldUseStatus = mainList[0].HMouldUseStatus; |
| | | int HUSEORGID = mainList[0].HUSEORGID; |
| | | DateTime HNextMainDate = mainList[0].HNextMainDate; |
| | | bool HTransPackFlag = mainList[0].HTransPackFlag; //周转容器标记 |
| | | bool HSendPackFlag = mainList[0].HSendPackFlag; //发货容器标记 |
| | | int HMouldLength = mainList[0].HMouldLength; //长 |
| | | int HMouldWidth = mainList[0].HMouldWidth; //宽 |
| | | int HMouldHeight = mainList[0].HMouldHeight; //高 |
| | | int HMouldFoldHeight = mainList[0].HMouldFoldHeight; //折叠高度 |
| | | |
| | | |
| | | int HUserID = mainList[0].HUserID; // 使用人(Gy_Employee) |
| | | string HBrand = mainList[0].HBrand; // 品牌 |
| | | string HCalibrationType = mainList[0].HCalibrationType; // 校准类型 (内/外校) |
| | | string HLocation = mainList[0].HLocation; // 位置 |
| | | DateTime HCalibrationDate = mainList[0].HCalibrationDate; // 校准日期 |
| | | string HCalibrationCycle = mainList[0].HCalibrationCycle; // 校准周期 |
| | | string HProductDesignSize = mainList[0].HProductDesignSize; // 产品设计尺寸 |
| | | string HGaugeDesignSize = mainList[0].HGaugeDesignSize; // 检具设计尺寸 |
| | | int HProductQTY = mainList[0].HProductQTY; // 产品数量 |
| | | |
| | | //若MAINDI重复则重新获取 |
| | | oCN.BeginTran(); |
| | | |
| | |
| | | } |
| | | //========================================================= |
| | | |
| | | string sql = "UpDate Gy_MouldFileMain set " + |
| | | " HBillNo='" + HBillNo + "'" + //固定赋值=============== |
| | | ",HDate='" + HDate + "'" + |
| | | ",HYear='" + HYear.ToString() + "'" + |
| | | ",HPeriod='" + HPeriod.ToString() + "'" + |
| | | ",HRemark='" + HRemark + "'" + |
| | | ",HUpDater='" + HUpDater + "'" + |
| | | ",HUpDateDate=getdate()" + |
| | | //======================================== |
| | | ",HMouldNo='" + HMouldNo + "'" + |
| | | ",HName='" + HName + "'" + |
| | | ",HModel='" + HModel + "'" + |
| | | ",HModel2='" + HModel2 + "'" + |
| | | ",HDiameter='" + HDiameter + "'" + |
| | | ",HSubjoin='" + HSubjoin + "'" + |
| | | ",HSubjoin2='" + HSubjoin2 + "'" + |
| | | ",HPICNo='" + HPICNo + "'" + |
| | | ",HWorkMaterModel='" + HWorkMaterModel + "'" + |
| | | ",HMaterID=" + HMaterID.ToString() + |
| | | ",HUSEORGID=" + HUSEORGID.ToString() + |
| | | ",HMaterNumber='" + HMaterNumber + "'" + |
| | | ",HMouldClass='" + HMouldClass + "'" + |
| | | ",HMouldType=" + HMouleTypeID.ToString() + |
| | | ",HUnitID=" + HUnitID.ToString() + |
| | | ",HOutComDate='" + HOutComDate + "'" + |
| | | ",HOutComNo='" + HOutComNo + "'" + |
| | | ",HDeptID=" + HDeptID.ToString() + |
| | | ",HSupID=" + HSupID.ToString() + |
| | | ",HSupNumber='" + HSupNumber + "'" + |
| | | ",HPrintQty=" + HPrintQty.ToString() + |
| | | ",HMouldStatus='" + HMouldStatus + "'" + |
| | | ",HSaveLife='" + HSaveLife + "'" + |
| | | ",HWhID=" + HWHID.ToString() + |
| | | ",HRoutingID=" + HRoutingID.ToString() + |
| | | ",HBomID=" + HBOMID.ToString() + |
| | | ",HVersion='" + HVersion + "'" + |
| | | ",HSPGroupID=" + HSPGroupID.ToString() + |
| | | ",HSPID=" + HSPID.ToString() + |
| | | ",HDesignLife=" + HDesignLife.ToString() + |
| | | ",HCaveQty=" + HCaveQty.ToString() + |
| | | ",HUseLife=" + HUseLife.ToString() + |
| | | ",HLeaveLife=" + HLeaveLife.ToString() + |
| | | ",HProdQty=" + HProdQty.ToString() + |
| | | ",HMouldDotCheckRuleInterID=" + HMouldDotCheckRuleInterID.ToString() + |
| | | ",HMouldMaintainRuleInterID=" + HMouldMaintainRuleInterID.ToString() + |
| | | ",HMouldOWNER='" + HMouldOWNER + "'" + |
| | | ",HNowSupID=" + HNowSupID.ToString() + |
| | | ",HNowSupTypeID=" + HNowSupTypeID.ToString() + |
| | | ",HProdWeight=" + HProdWeight.ToString() + |
| | | ",HBarCode='" + HBarCode.ToString() + "'" + |
| | | ",HMadeSupID=" + HMadeSupID + |
| | | ",HNowWHID=" + HNowWHID + |
| | | ",HNowSPID=" + HNowSPID + |
| | | ",HInitLife='" + HInitLife + "'" + |
| | | ",HNextMainDate='" + HNextMainDate + |
| | | "',HMouldUseStatus='" + HMouldUseStatus + |
| | | "' where HInterID=" + HInterID.ToString(); |
| | | |
| | | //主表 |
| | | oCN.RunProc(sql); |
| | | |
| | | //修改子项目代码 |
| | | //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_Department,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | //将上级 为非末级 |
| | | // oCN.RunProc("Update Gy_Department set HEndflag=0 where HItemID=" + HInterID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | //主表 |
| | | oCN.RunProc("UpDate Gy_MouldFileMain set " + |
| | | " HBillNo='" + HBillNo + "'" + //固定赋值=============== |
| | | ",HDate='" + HDate + "'" + |
| | | ",HYear='" + HYear.ToString() + "'" + |
| | | ",HPeriod='" + HPeriod.ToString() + "'" + |
| | | ",HRemark='" + HRemark + "'" + |
| | | ",HUpDater='" + HUpDater + "'" + |
| | | ",HUpDateDate=getdate()" + |
| | | //======================================== |
| | | ",HMouldNo='" + HMouldNo + "'" + |
| | | ",HName='" + HName + "'" + |
| | | ",HModel='" + HModel + "'" + |
| | | ",HModel2='" + HModel2 + "'" + |
| | | ",HDiameter='" + HDiameter + "'" + |
| | | ",HSubjoin='" + HSubjoin + "'" + |
| | | ",HSubjoin2='" + HSubjoin2 + "'" + |
| | | ",HPICNo='" + HPICNo + "'" + |
| | | ",HWorkMaterModel='" + HWorkMaterModel + "'" + |
| | | ",HMaterID=" + HMaterID.ToString() + |
| | | ",HUSEORGID=" + HUSEORGID.ToString() + |
| | | ",HMaterNumber='" + HMaterNumber + "'" + |
| | | ",HMouldClass='" + HMouldClass + "'" + |
| | | ",HMouldType=" + HMouleTypeID.ToString() + |
| | | ",HUnitID=" + HUnitID.ToString() + |
| | | ",HOutComDate='" + HOutComDate + "'" + |
| | | ",HOutComNo='" + HOutComNo + "'" + |
| | | ",HDeptID=" + HDeptID.ToString() + |
| | | ",HSupID=" + HSupID.ToString() + |
| | | ",HSupNumber='" + HSupNumber + "'" + |
| | | ",HPrintQty=" + HPrintQty.ToString() + |
| | | ",HMouldStatus='" + HMouldStatus + "'" + |
| | | ",HSaveLife='" + HSaveLife + "'" + |
| | | ",HWhID=" + HWHID.ToString() + |
| | | ",HRoutingID=" + HRoutingID.ToString() + |
| | | ",HBomID=" + HBOMID.ToString() + |
| | | ",HVersion='" + HVersion + "'" + |
| | | ",HSPGroupID=" + HSPGroupID.ToString() + |
| | | ",HSPID=" + HSPID.ToString() + |
| | | ",HDesignLife=" + HDesignLife.ToString() + |
| | | ",HCaveQty=" + HCaveQty.ToString() + |
| | | ",HUseLife=" + HUseLife.ToString() + |
| | | ",HLeaveLife=" + HLeaveLife.ToString() + |
| | | ",HProdQty=" + HProdQty.ToString() + |
| | | ",HMouldDotCheckRuleInterID=" + HMouldDotCheckRuleInterID.ToString() + |
| | | ",HMouldMaintainRuleInterID=" + HMouldMaintainRuleInterID.ToString() + |
| | | ",HMouldOWNER='" + HMouldOWNER + "'" + |
| | | ",HNowSupID=" + HNowSupID.ToString() + |
| | | ",HNowSupTypeID=" + HNowSupTypeID.ToString() + |
| | | ",HProdWeight=" + HProdWeight.ToString() + |
| | | ",HBarCode='" + HBarCode.ToString() + "'" + |
| | | ",HMadeSupID=" + HMadeSupID + |
| | | ",HNowWHID=" + HNowWHID + |
| | | ",HNowSPID=" + HNowSPID + |
| | | ",HTransPackFlag=" + Convert.ToString(HTransPackFlag ? 1 : 0) + |
| | | ",HSendPackFlag=" + Convert.ToString(HSendPackFlag ? 1 : 0) + |
| | | ",HMouldLength=" + HMouldLength + |
| | | ",HMouldWidth=" + HMouldWidth + |
| | | ",HMouldHeight=" + HMouldHeight + |
| | | ",HMouldFoldHeight=" + HMouldFoldHeight + |
| | | ",HInitLife='" + HInitLife + |
| | | "',HNextMainDate='" + HNextMainDate + |
| | | "',HMouldUseStatus='" + HMouldUseStatus + |
| | | "',HUserID='" + HUserID + |
| | | "',HBrand='" + HBrand + |
| | | "',HCalibrationType='" + HCalibrationType + |
| | | "',HLocation='" + HLocation + |
| | | "',HCalibrationDate='" + HCalibrationDate + |
| | | "',HCalibrationCycle='" + HCalibrationCycle + |
| | | "',HProductDesignSize='" + HProductDesignSize + |
| | | "',HGaugeDesignSize='" + HGaugeDesignSize + |
| | | "',HProductQTY='" + HProductQTY + |
| | | "' where HInterID=" + HInterID.ToString()); |
| | | |
| | | oCN.RunProc("delete from Gy_MouldFileSub_SubMater where HInterID='" + HInterID + "'"); |
| | | oCN.RunProc("delete from Gy_MouldFileSub_MaintainRule where HInterID='" + HInterID + "'"); |
| | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "修改单据成功!"; |
| | | //objJsonResult.data = null; |
| | | objJsonResult.HInterID = HInterID.ToString(); |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 磨具档案修改按钮方法-计算下次保养/校正日期-获取档案最近一次的保养记录 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | #endregion |
| | | |
| | | #region [模具档案修改按钮方法-计算下次保养/校正日期-获取档案最近一次的保养记录] |
| | | [Route("Gy_Mould_Edit/calculateHNextMainDate")] |
| | | [HttpGet] |
| | | public object calculateHNextMainDate(long HInterID) |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | /// <summary> |
| | | /// 磨具档案修改按钮方法 |
| | |
| | | #region [模具档案批量生成] |
| | | [Route("Gy_Mould/SaveBatchGen_MouldFile")] |
| | | [HttpGet] |
| | | public object SaveBatchGen_MouldFile(long HInterID, string StarNum, string EndNum) |
| | | public object SaveBatchGen_MouldFile(long HInterID, string StarNum, string EndNum,string user) |
| | | { |
| | | int StarNum1 = int.Parse(StarNum); |
| | | int EndNum1 = int.Parse(EndNum); |
| | |
| | | ",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID" + |
| | | ") " + |
| | | " values('3899','3899'," + HItemID + ",'" + Num1 + j + "',getdate()" + |
| | | "," + dr["HYear"] + "," + dr["HPeriod"] + ",'" + dr["HRemark"] + "','" + dr["HMaker"] + "',getdate(),'" + Num1 + j + |
| | | "," + dr["HYear"] + "," + dr["HPeriod"] + ",'" + dr["HRemark"] + "','" + user + "',getdate(),'" + Num1 + j + |
| | | "','" + Num1 + j + "','" + dr["HName"] + "','" + dr["HModel"] + "','" + dr["HModel2"] + "','" + dr["HDiameter"] + "'" + |
| | | ",'" + dr["HSubjoin"] + "','" + dr["HSubjoin2"] + "','" + dr["HPICNo"] + "','" + dr["HWorkMaterModel"] + "'" + |
| | | "," + dr["HMaterID"] + ",'" + dr["HMaterNumber"] + "',0," + dr["HUnitID"] + |
| | | "," + dr["HMaterID"] + ",'" + dr["HMaterNumber"] + "',"+dr["HMouldType"]+"," + dr["HUnitID"] + |
| | | ",'" + dr["HOutComDate"] + "','" + dr["HOutComNo"] + "'," + dr["HDeptID"] + "," + dr["HSupID"] + ",'" + dr["HSupNumber"] + "'" + |
| | | "," + dr["HPrintQty"] + ",'" + dr["HMouldStatus"] + "'," + dr["HWHID"] + "," + dr["HRoutingID"] + ",'" + dr["HCaveQty"] + |
| | | "'," + dr["HBOMID"] + ",'" + dr["HVersion"] + "'," + dr["HSPGroupID"] + "," + dr["HSPID"] + ",'" + dr["HDesignLife"] + "','" + dr["HNowSupID"] + "','" + dr["HNowSupTypeID"] + "'" + |
| | |
| | | HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["对应ERP物料"].ToString()); |
| | | HUnitName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["计量单位"].ToString()); |
| | | HDeptName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["使用部门"].ToString()); |
| | | HWHName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认仓库"].ToString()); |
| | | HSPName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认仓位"].ToString()); |
| | | HWHName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认仓库"].ToString()); |
| | | HSPName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认仓位"].ToString()); |
| | | HSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["供应商"].ToString()); |
| | | HSupNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["供应商代码"].ToString()); |
| | | HMadeSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["制造商"].ToString()); |
| | |
| | | "," + HPrintQty + ",'" + HMouldStatus + "'," + HWHID + "," + HRoutingID + "," + HCaveQty + |
| | | "," + HBOMID + ",'" + HVersion + "'," + HSPGroupID + "," + HSPID + ",'" + HDesignLife + "','" + HNowSupID + "','" + HNowSupTypeID + "'" + |
| | | ",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'," + HMadeSupID + |
| | | ",'" + HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + "') "); |
| | | ",'" + HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + " ) "); |
| | | } |
| | | else |
| | | { |
| | |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 器具档案 文件上传 |
| | | [Route("Gy_MouldFileBIllMain/UploadFile_Gy_MouldFilen")] |
| | | [HttpPost] |
| | | public object UploadFile_Gy_MouldFilen() |
| | | { |
| | | |
| | | 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_MouldFilen/" + HBillNo); |
| | | dynamic dyResult = UploadFile_Gy_MouldFilen(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_Gy_MouldFilen(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_MouldFilen/" + 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_MouldFilen/" + 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_MouldFileBIllMain/Gy_MouldFilen_Filelist")] |
| | | [HttpGet] |
| | | public object Gy_MouldFilen_Filelist(string HBillNo) |
| | | { |
| | | var url = fileip + "/Files/Gy_MouldFilen/" + HBillNo + "/"; |
| | | |
| | | 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_MouldFileBIllMain/Gy_MouldFilen_DeleteFilelist")] |
| | | [HttpGet] |
| | | public object Gy_MouldFilen_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/Gy_MouldFilen/" + 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 |
| | | |
| | | |
| | | //根据条码找物料信息 |
| | | [Route("Gy_Material/findMaterialByNumber")] |
| | |
| | | try |
| | | { |
| | | ds = oCN.RunProcReturn($"select * from Gy_BarCodeBill where HBarCode='{HbarCode}' ", "Gy_Material"); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "成功"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | 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 = "成功"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | } |
| | | catch (Exception) |
| | | { |