private void DataPortal_Fetch(string plctaskno) { using (BypassPropertyChecks) { using (var cn = new MySqlConnection(AppUtil._LocalConnectionString)) { cn.Open(); using (var cm = cn.CreateCommand()) { cm.CommandText = "SELECT * FROM T_SORTING_LINE_TASK t WHERE t.indexno = @plctaskno limit 1"; cm.Parameters.AddWithValue("@plctaskno", Convert.ToInt32(plctaskno)); using (var dr = new SafeDataReader(cm.ExecuteReader())) { while (dr.Read()) { LoadProperty(IdProperty, dr.GetString("ID")); LoadProperty(SORTINGTASKNOProperty, dr.GetString("SORTINGTASKNO")); LoadProperty(ORDERDATEProperty, dr.GetString("ORDERDATE")); LoadProperty(PICKLINECODEProperty, dr.GetString("PICKLINECODE")); LoadProperty(PICKLINENAMEProperty, dr.GetString("PICKLINENAME")); LoadProperty(CUSTCODEProperty, dr.GetString("CUSTCODE")); LoadProperty(CUSTNAMEProperty, dr.GetString("CUSTNAME")); LoadProperty(INDEXNOProperty, dr.GetInt32("INDEXNO")); LoadProperty(OUTPORTProperty, dr.GetString("OUTPORT")); LoadProperty(LINECODEProperty, dr.GetString("LINECODE")); LoadProperty(LINENAMEProperty, dr.GetString("LINENAME")); LoadProperty(CORPCODEProperty, dr.GetString("CORPCODE")); LoadProperty(CORPNAMEProperty, dr.GetString("CORPNAME")); LoadProperty(ShortNameProperty, dr.GetString("ShortName")); LoadProperty(PLCADDRESSProperty, dr.GetInt32("PLCADDRESS")); LoadProperty(ISLOCKProperty, dr.GetInt32("islock")); LoadProperty(StatusProperty, dr.GetInt32("Status")); LoadProperty(SortingTimeProperty, dr.GetDateTime("SortingTime")); LoadProperty(FinishTimeProperty, dr.GetDateTime("FinishTime")); } } // load child objects using (var cmProducts = cn.CreateCommand()) { cmProducts.CommandText = "SELECT * FROM T_SORTING_LINE_DETAIL_TASK tl WHERE tl.taskid = @id order by tl.LINEBOXNAME"; cmProducts.Parameters.AddWithValue("@id", ID); using (var drTaskDetails = new SafeDataReader(cmProducts.ExecuteReader())) { LoadProperty(SortingLineTaskDetailsProperty, SortingLineTaskDetails.GetSortingLineTaskDetails(drTaskDetails)); } } } } } }
private void DataPortal_Fetch(QueryCondition queryCondition) { using (var cn = new MySqlConnection(AppUtil._LocalConnectionString)) { cn.Open(); using (MySqlCommand cm = cn.CreateCommand()) { //用3状态代替查询1,2两种状态 if (queryCondition.Status == "3") { cm.CommandText = "SELECT * FROM T_SORTING_LINE_TASK t WHERE t.status <> 0 order by t.indexno desc limit 100"; } else { if (queryCondition.IsAll) { cm.CommandText = "SELECT * FROM T_SORTING_LINE_TASK t WHERE t.status = " + queryCondition.Status + " order by t.indexno " + queryCondition.Sqce; } else { cm.CommandText = "SELECT * FROM T_SORTING_LINE_TASK t WHERE t.status = " + queryCondition.Status + " order by t.indexno " + queryCondition.Sqce + " limit 100"; } } using (var dr = new SafeDataReader(cm.ExecuteReader())) { while (dr.Read()) { IsReadOnly = false; SortingLineTask sortingLineTask; sortingLineTask = SortingLineTask.GetSortingLineTask(dr); Add(sortingLineTask); IsReadOnly = true; } } if (queryCondition.Status == "1") { foreach (SortingLineTask st in this) { // load child objects using (MySqlCommand cmProducts = cn.CreateCommand()) { cmProducts.CommandText = "SELECT * FROM T_SORTING_LINE_DETAIL_TASK tl WHERE tl.taskid = @id"; cmProducts.Parameters.AddWithValue("@id", st.ID); using (var drTaskDetails = new SafeDataReader(cmProducts.ExecuteReader())) { st.SortingLineTaskDetails = (SortingLineTaskDetails.GetSortingLineTaskDetails(drTaskDetails)); } } } } } } }