protected void Page_Load(object sender, EventArgs e) { try { Aim.Portal.Web.WebPortalService.CheckLogon(); } catch { Response.Write("<script> window.location.href = '/Login.aspx';</script>"); Response.End(); } string action = Request["action"]; string where = ""; DataTable dt = null; string id = Request["id"]; InWarehouse iwEnt = null; IList<InWarehouseDetail> iwdEnts = null; switch (action) { case "load": if (!string.IsNullOrEmpty(Request["InWarehouseNo"])) { where += " and InWarehouseNo like '%" + Request["InWarehouseNo"].Trim() + "%'"; } if (!string.IsNullOrEmpty(Request["SupplierName"])) { where += " and SupplierName like '%" + Request["SupplierName"].Trim() + "%'"; } if (!string.IsNullOrEmpty(Request["State"])) { where += " and State = '" + Request["State"] + "'"; } if (!string.IsNullOrEmpty(Request["ProductCode"])) { where += " and Id in (select distinct InWarehouseId from SHHG_AimExamine..InWarehouseDetail where ProductCode like '%" + Request["ProductCode"] + "%')"; } sql = "select * from SHHG_AimExamine..InWarehouse where InWarehouseType ='采购入库' " + where; dt = DataHelper.QueryDataTable(GetPageSql(sql)); Response.Write("{total:" + totalProperty + ",rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}"); Response.End(); break; case "delete": if (!string.IsNullOrEmpty(id)) { iwEnt = InWarehouse.Find(id); iwdEnts = InWarehouseDetail.FindAllByProperty("InWarehouseId", id); foreach (InWarehouseDetail tempEnt in iwdEnts) { sql = "select sum(isnull(IQuantity,0)) from SHHG_AimExamine..InWarehouseDetail where PurchaseOrderDetailId='" + tempEnt.PurchaseOrderDetailId + "'"; tempEnt.DoDelete(); //删除完入库单明细后更新采购单明细的生成入库单数量 PurchaseOrderDetail podEnt = PurchaseOrderDetail.Find(tempEnt.PurchaseOrderDetailId); podEnt.RuKuDanQuan = DataHelper.QueryValue<Int32>(sql); podEnt.DoUpdate(); } iwEnt.DoDelete(); } break; } }
protected void Page_Load(object sender, EventArgs e) { id = RequestData.Get <string>("id"); if (!string.IsNullOrEmpty(id)) { roEnt = ReturnOrder.Find(id); } switch (RequestActionString) { case "delete": //先删除入库单及入库明细 InWarehouse iwEnt = InWarehouse.FindAllByProperty(InWarehouse.Prop_PublicInterface, roEnt.Id).FirstOrDefault <InWarehouse>(); IList <OtherInWarehouseDetail> oiwdEnts = OtherInWarehouseDetail.FindAllByProperty(OtherInWarehouseDetail.Prop_InWarehouseId, iwEnt.Id); foreach (OtherInWarehouseDetail oiwdEnt in oiwdEnts) { oiwdEnt.DoDelete(); } iwEnt.DoDelete(); //更新销售单及销售明细 SaleOrder soEnt = SaleOrder.FindAllByProperty(SaleOrder.Prop_Number, roEnt.OrderNumber).FirstOrDefault <SaleOrder>(); soEnt.ReturnAmount = (soEnt.ReturnAmount.HasValue ? soEnt.ReturnAmount.Value : 0) - (roEnt.ReturnMoney.HasValue ? roEnt.ReturnMoney.Value : 0); soEnt.DoUpdate(); IList <ReturnOrderPart> ropEnts = ReturnOrderPart.FindAllByProperty(ReturnOrderPart.Prop_ReturnOrderId, roEnt.Id); foreach (ReturnOrderPart ropEnt in ropEnts) { OrdersPart opEnt = OrdersPart.Find(ropEnt.OrderPartId); opEnt.ReturnCount = (opEnt.ReturnCount.HasValue ? opEnt.ReturnCount.Value : 0) - ropEnt.Count; opEnt.DoUpdate(); ropEnt.DoDelete(); } roEnt.DoDelete(); break; default: DoSelect(); break; } }