public AscmCuxWipReleaseHeaders Get(int id) { AscmCuxWipReleaseHeaders ascmCuxWipReleaseHeaders = null; try { ascmCuxWipReleaseHeaders = YnDaoHelper.GetInstance().nHibernateHelper.Get <AscmCuxWipReleaseHeaders>(id); } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Get AscmCuxWipReleaseHeaders)", ex); throw ex; } return(ascmCuxWipReleaseHeaders); }
public void Update(AscmCuxWipReleaseHeaders ascmDeliveryNotify) { using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction()) { try { YnDaoHelper.GetInstance().nHibernateHelper.Update <AscmCuxWipReleaseHeaders>(ascmDeliveryNotify); tx.Commit();//正确执行提交 } catch (Exception ex) { tx.Rollback();//回滚 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmCuxWipReleaseHeaders)", ex); throw ex; } } }
public List <AscmCuxWipReleaseLines> GetList(int releaseHeaderId, string whereOther = "") { List <AscmCuxWipReleaseLines> list = null; try { string sort = " order by inventoryItemId "; //if (!string.IsNullOrEmpty(sortName)) //{ // sort = " order by " + sortName.Trim() + " "; // if (!string.IsNullOrEmpty(sortOrder)) // sort += sortOrder.Trim(); //} AscmCuxWipReleaseHeaders ascmCuxWipReleaseHeaders = AscmCuxWipReleaseHeadersService.GetInstance().Get(releaseHeaderId); string sql = "from AscmCuxWipReleaseLines where releaseHeaderId=" + releaseHeaderId; string where = "", whereQueryWord = ""; //if (!string.IsNullOrEmpty(queryWord)) // whereQueryWord = " (name like '%" + queryWord.Trim() + "%' or description like '%" + queryWord.Trim() + "%')"; where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord); where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereOther); if (!string.IsNullOrEmpty(where)) { sql += " and " + where; } //IList<AscmCuxWipReleaseLines> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find<AscmCuxWipReleaseLines>(sql + sort); IList <AscmCuxWipReleaseLines> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmCuxWipReleaseLines>(sql + sort); if (ilist != null) { list = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList <AscmCuxWipReleaseLines>(ilist); SetMaterial(list); SetWipRequirementOperations(list); //计算未发数 foreach (AscmCuxWipReleaseLines ascmCuxWipReleaseLines in list) { ascmCuxWipReleaseLines.QUANTITY_AV = 0; if (ascmCuxWipReleaseLines.ascmWipRequirementOperations != null) { if (ascmCuxWipReleaseHeaders.releaseType == "RETURN") { ascmCuxWipReleaseLines.QUANTITY_AV = ascmCuxWipReleaseLines.ascmWipRequirementOperations.quantityIssued; } else { int sign_REQUIRED_QUANTITY = 0; if (ascmCuxWipReleaseLines.ascmWipRequirementOperations.requiredQuantity > 0) { sign_REQUIRED_QUANTITY = 1; } else if (ascmCuxWipReleaseLines.ascmWipRequirementOperations.requiredQuantity < 0) { sign_REQUIRED_QUANTITY = -1; } int sign_QUANTITY_ISSUED = 0; if (ascmCuxWipReleaseLines.ascmWipRequirementOperations.quantityIssued > 0) { sign_QUANTITY_ISSUED = 1; } else if (ascmCuxWipReleaseLines.ascmWipRequirementOperations.quantityIssued < 0) { sign_QUANTITY_ISSUED = -1; } if (sign_REQUIRED_QUANTITY == sign_QUANTITY_ISSUED) { ascmCuxWipReleaseLines.QUANTITY_AV = ascmCuxWipReleaseLines.ascmWipRequirementOperations.requiredQuantity - ascmCuxWipReleaseLines.ascmWipRequirementOperations.quantityIssued; } else if (Math.Abs(ascmCuxWipReleaseLines.ascmWipRequirementOperations.requiredQuantity) >= Math.Abs(ascmCuxWipReleaseLines.ascmWipRequirementOperations.quantityIssued)) { ascmCuxWipReleaseLines.QUANTITY_AV = ascmCuxWipReleaseLines.ascmWipRequirementOperations.requiredQuantity - ascmCuxWipReleaseLines.ascmWipRequirementOperations.quantityIssued; } } } } } } catch (Exception ex) { YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Find AscmCuxWipReleaseLines)", ex); throw ex; } return(list); }
/* * 2014/5/12 by chenyao */ public List <AscmCuxWipReleaseHeaders> GetList(YnPage ynPage, string releaseNumber, string startScheduledStartDate, string endScheduledStartDate, int?statusType) { List <AscmCuxWipReleaseHeaders> list = null; string sql = "select {0} from cux_wip_release_headers wrh,wip_discrete_jobs wdj,wip_entities we,mtl_system_items_b msib"; string where = string.Empty; where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "wrh.wip_entity_id = wdj.wip_entity_id"); where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "wdj.wip_entity_id = we.wip_entity_id"); where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "wdj.primary_item_id = msib.inventory_item_id"); where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "wdj.organization_id = 775"); where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "wrh.organization_id = 775"); where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "wrh.release_type = 'ISSUE'"); if (!string.IsNullOrWhiteSpace(releaseNumber)) { where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "wrh.release_number = '" + releaseNumber.Trim() + "'"); } string whereStartScheduledStartDate = "", whereEndScheduledStartDate = ""; DateTime dtStartScheduledStartDate, dtEndScheduledStartDate; if (!string.IsNullOrEmpty(startScheduledStartDate) && DateTime.TryParse(startScheduledStartDate, out dtStartScheduledStartDate)) { whereStartScheduledStartDate = "wdj.scheduled_start_date >= to_date('" + dtStartScheduledStartDate.ToString("yyyy-MM-dd 00:00") + "', 'yyyy-mm-dd hh24:mi')"; whereEndScheduledStartDate = "wdj.scheduled_start_date < to_date('" + dtStartScheduledStartDate.AddDays(1).ToString("yyyy-MM-dd 00:00") + "', 'yyyy-mm-dd hh24:mi')"; } if (!string.IsNullOrEmpty(endScheduledStartDate) && DateTime.TryParse(endScheduledStartDate, out dtEndScheduledStartDate)) { whereEndScheduledStartDate = "wdj.scheduled_start_date < to_date('" + dtEndScheduledStartDate.AddDays(1).ToString("yyyy-MM-dd 00:00") + "', 'yyyy-mm-dd hh24:mi')"; } where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereStartScheduledStartDate); where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereEndScheduledStartDate); if (statusType.HasValue) { where = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, "wdj.status_type = " + statusType.Value); } sql += " where " + where; string selectCount = string.Format(sql, "count(1)"); sql = string.Format(sql, "wrh.release_header_id,wrh.release_number,wrh.wip_entity_id,we.wip_entity_name,wdj.scheduled_start_date,wdj.wip_supply_type,wdj.schedule_group_id,wdj.net_quantity,wdj.status_type,wdj.description,msib.segment1"); sql += " order by wrh.release_header_id"; OracleParameter[] commandParameters = new OracleParameter[] { new OracleParameter { ParameterName = "i_sql", OracleDbType = OracleDbType.Varchar2, Size = 2000, Value = sql, Direction = ParameterDirection.Input }, new OracleParameter { ParameterName = "i_sql_count", OracleDbType = OracleDbType.Varchar2, Size = 2000, Value = selectCount, Direction = ParameterDirection.Input }, new OracleParameter { ParameterName = "i_pagesize", OracleDbType = OracleDbType.Int32, Value = ynPage.pageSize, Direction = ParameterDirection.Input }, new OracleParameter { ParameterName = "i_currentpage", OracleDbType = OracleDbType.Int32, Value = ynPage.currentPage, Direction = ParameterDirection.Input }, new OracleParameter { ParameterName = "o_totalcount", OracleDbType = OracleDbType.Int32, Direction = ParameterDirection.Output }, new OracleParameter { ParameterName = "o_pagecount", OracleDbType = OracleDbType.Int32, Direction = ParameterDirection.Output }, new OracleParameter { ParameterName = "o_cursor", OracleDbType = OracleDbType.RefCursor, Direction = ParameterDirection.Output } }; try { ISession session = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession(); OracleCommand command = (OracleCommand)session.Connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "cux_ascm_interface_utl.sp_exec_page"; Array.ForEach <OracleParameter>(commandParameters, P => command.Parameters.Add(P)); OracleDataAdapter da = new OracleDataAdapter(command); DataSet ds = new DataSet(); da.Fill(ds); DataTable dt = ds.Tables[0]; if (dt != null && dt.Rows != null && dt.Rows.Count > 0) { list = new List <AscmCuxWipReleaseHeaders>(); foreach (DataRow dr in dt.Rows) { AscmCuxWipReleaseHeaders cuxWipReleaseHeaders = new AscmCuxWipReleaseHeaders(); cuxWipReleaseHeaders.releaseHeaderId = Convert.ToInt32(dr["release_header_id"]); cuxWipReleaseHeaders.releaseNumber = dr["release_number"].ToString(); cuxWipReleaseHeaders.wipEntityId = Convert.ToInt32(dr["wip_entity_id"]); cuxWipReleaseHeaders.wipEntityName = dr["wip_entity_name"].ToString(); cuxWipReleaseHeaders.scheduledStartDate = dr["scheduled_start_date"].ToString(); cuxWipReleaseHeaders.wipSupplyType = Convert.ToInt32(dr["wip_supply_type"]); cuxWipReleaseHeaders.scheduleGroupId = Convert.ToInt32(dr["schedule_group_id"]); cuxWipReleaseHeaders.netQuantity = Convert.ToDecimal(dr["net_quantity"]); cuxWipReleaseHeaders.statusType = Convert.ToInt32(dr["status_type"]); cuxWipReleaseHeaders.description = dr["description"].ToString(); cuxWipReleaseHeaders.primaryItemDocNumber = dr["segment1"].ToString(); list.Add(cuxWipReleaseHeaders); } } int totalCount = 0; int.TryParse(commandParameters[4].Value.ToString(), out totalCount); ynPage.SetRecordCount(totalCount); int pageCount = 0; int.TryParse(commandParameters[5].Value.ToString(), out pageCount); ynPage.pageCount = pageCount; } catch (Exception ex) { throw ex; } return(list); }