public R_WO_REGION CreateLanguageClass(DataRow dr) { Row_R_WO_REGION row = (Row_R_WO_REGION)NewRow(); row.loadData(dr); return(row.GetDataObject()); }
//对查询整个表的数据进行分页 public List <R_WO_REGION> ShowAllDataAndShowPage(OleExec DB, string strWorkOrder, int CurrentPage, int PageSize, out int TotalData) { string strSql = string.Empty; bool isGetAll = true; DataTable dt = new DataTable(); OleDbParameter[] paramet; List <R_WO_REGION> LanguageList = new List <R_WO_REGION>(); strSql = $@" select count(*) from r_wo_region a "; if (strWorkOrder.Length > 0) { strSql = strSql + $@"where upper(a.workorderno) like'%{strWorkOrder}%'"; isGetAll = false; } TotalData = Convert.ToInt32(DB.ExecuteScalar(strSql, CommandType.Text)); strSql = $@"select * from (select rownum rnumber,a.* from r_wo_region a "; if (isGetAll) { strSql = strSql + " order by edit_time desc) where rnumber>((:CurrentPage-1)*:PageSize) and rnumber<=((:CurrentPage1-1)*:PageSize1+:PageSize2) order by edit_time desc"; //oldb 的參數只能是按照順序對應,不能復用, paramet = new OleDbParameter[] { new OleDbParameter(":CurrentPage", CurrentPage), new OleDbParameter(":PageSize", PageSize), new OleDbParameter(":CurrentPage1", CurrentPage), new OleDbParameter(":PageSize1", PageSize), new OleDbParameter(":PageSize2", PageSize) }; dt = DB.ExecuteDataTable(strSql, CommandType.Text, paramet); } else { strSql = strSql + $@" where upper(a.workorderno) like'%{strWorkOrder}%' order by edit_time desc) where rnumber>((:CurrentPage-1)*:PageSize) and rnumber<=((:CurrentPage1-1)*:PageSize1+:PageSize2) order by edit_time desc"; //oldb 的參數只能是按照順序對應,不能復用, paramet = new OleDbParameter[] { new OleDbParameter(":CurrentPage", CurrentPage), new OleDbParameter(":PageSize", PageSize), new OleDbParameter(":CurrentPage1", CurrentPage), new OleDbParameter(":PageSize1", PageSize), new OleDbParameter(":PageSize2", PageSize) }; dt = DB.ExecuteDataTable(strSql, CommandType.Text, paramet); } if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Row_R_WO_REGION ret = (Row_R_WO_REGION)NewRow(); ret.loadData(dt.Rows[i]); LanguageList.Add(ret.GetDataObject()); } return(LanguageList); } else { return(null); } }
/// <summary> /// 查詢SN所在的工單區間 /// </summary> /// <param name="sn"></param> /// <param name="DB"></param> /// <returns></returns> public List <R_WO_REGION> ShowWORegionBySN(string sn, OleExec DB) { string sql = string.Empty; List <R_WO_REGION> WORegionList = new List <R_WO_REGION>(); DataTable dt = new DataTable(); sql = $@"Select * From R_WO_Region Where 1=1 and :strStartSN>=Min_SN and :strEndSN<=Max_SN and Length(:strStartSN)=Length(Min_SN)"; OleDbParameter[] parameter = new OleDbParameter[3]; parameter[0] = new OleDbParameter(":strStartSN", sn); parameter[1] = new OleDbParameter(":strEndSN", sn); parameter[2] = new OleDbParameter(":strStartSN", sn); dt = DB.ExecuteDataTable(sql, CommandType.Text, parameter); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Row_R_WO_REGION ret = (Row_R_WO_REGION)NewRow(); ret.loadData(dt.Rows[i]); WORegionList.Add(ret.GetDataObject()); } } return(WORegionList); }