/// <summary> /// 插入报废单 /// </summary> /// <param name="ctx">LINQ数据上下文</param> /// <param name="outSourcing">Linq操作数据集</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>插入成功返回True,插入失败返回False</returns> public bool AddScrapBill(DepotManagementDataContext ctx, S_CheckOutInDepotForOutsourcingBill outSourcing, out string error) { error = null; string strBillID = ""; try { ScrapBillServer serverScrapBill = new ScrapBillServer(); S_ScrapBill lnqBill = new S_ScrapBill(); strBillID = m_assignBill.AssignNewNo(serverScrapBill, CE_BillTypeEnum.报废单.ToString()); lnqBill.AuthorizeTime = ServerTime.Time; lnqBill.Bill_ID = strBillID; lnqBill.Bill_Time = ServerTime.Time; lnqBill.BillStatus = "已完成"; lnqBill.Checker = outSourcing.Checker; lnqBill.DeclareDepartment = m_serverDepartment.GetDeptInfoFromPersonnelInfo( outSourcing.DeclarePersonnel).Rows[0]["DepartmentCode"].ToString(); lnqBill.DepartmentDirector = ""; lnqBill.DepotManager = outSourcing.ManagerPersonnel; lnqBill.DepotTime = ServerTime.Time; lnqBill.FillInPersonnel = outSourcing.DeclarePersonnel; lnqBill.FillInPersonnelCode = UniversalFunction.GetPersonnelCode(outSourcing.DeclarePersonnel); lnqBill.NotifyChecker = UniversalFunction.GetPersonnelCode(outSourcing.Checker); lnqBill.ProductType = ""; lnqBill.Remark = "关联委外报检入库单【" + outSourcing.Bill_ID + "】,自动生成"; lnqBill.Sanction = outSourcing.Checker; ctx.S_ScrapBill.InsertOnSubmit(lnqBill); S_ScrapGoods lnqGoods = new S_ScrapGoods(); lnqGoods.BatchNo = outSourcing.BatchNo; lnqGoods.Bill_ID = strBillID; lnqGoods.GoodsID = outSourcing.GoodsID; lnqGoods.Provider = outSourcing.Provider; lnqGoods.Quantity = outSourcing.DeclareWastrelCount; lnqGoods.Reason = "检测报废,关联委外报检入库单【" + outSourcing.Bill_ID + "】,自动生成"; lnqGoods.Remark = "检测报废,关联委外报检入库单【" + outSourcing.Bill_ID + "】,自动生成"; lnqGoods.ResponsibilityDepartment = "GYS"; lnqGoods.ResponsibilityProvider = outSourcing.Provider; lnqGoods.ResponsibilityType = "返 修 废"; lnqGoods.UnitPrice = 0; lnqGoods.WastrelType = 9; lnqGoods.WorkingHours = 0; ctx.S_ScrapGoods.InsertOnSubmit(lnqGoods); m_assignBill.UseBillNo(CE_BillTypeEnum.报废单.ToString(), strBillID); return(true); } catch (Exception ex) { m_assignBill.CancelBillNo(CE_BillTypeEnum.报废单.ToString(), strBillID); error = ex.Message; return(false); } }