using System; using System.Collections.Generic; using System.Text; using System.Data; namespace Common ... { public class GetV ...{ public GetV() ...{ } public static string dScodeV(DataSet dS_1, int R, int C1, int C2) ...{ string ls_code, ls_name; ls_code = dS_1.Tables[0].Rows[R][C1].ToString().Trim(); ls_name = dS_1.Tables[0].Rows[R][C2].ToString().Trim(); return ls_code + "_" + ls_name; } //====数组中查找====// public static string ArrayV(string[] sarr, string code_value, int len) ...{ if (sarr == null) return ""; for (int i = 0; i < sarr.Length; i++) ...{ if (sarr[i].Length >= len) ...{ if (sarr[i].Substring(0, len) == code_value.Trim()) return sarr[i]; } } return ""; } //====获得数据集的第一个表中 指定 行和列的Cell的值====// public static string dScV(DataSet dS_1, int R, int C) ...{ return dS_1.Tables[0].Rows[R][C].ToString(); } //====获得数据表中指定 列的Cell值与参数值 相等的第一个行号====// public static int if_have(DataTable dT_1, int Col, string as_value) ...{ for (short i = 0; i < dT_1.Rows.Count; i++) ...{ if (dT_1.Rows[i][Col].ToString().Trim() == as_value.Trim()) return i; } return -1; } public static int if_have(DataTable dT_1, string ColName, string as_value) ...{ for (short i = 0; i < dT_1.Rows.Count; i++) ...{ if (dT_1.Rows[i][ColName].ToString().Trim() == as_value.Trim()) return i; } return -1; } //====获得数据表中指定 列的Cell值与参数值 满足比较关系的第一个行号====// public static int if_compare(DataTable dT_1, int Col, string as_type, string as_value) ...{ for (short i = 0; i < dT_1.Rows.Count; i++) ...{ if (as_type == ">=") ...{ if (float.Parse(dT_1.Rows[i][Col].ToString().Trim()) >= float.Parse(as_value.Trim())) return i; } else if (as_type == ">") ...{ if (float.Parse(dT_1.Rows[i][Col].ToString().Trim()) > float.Parse(as_value.Trim())) return i; } else if (as_type == "<=") ...{ if (float.Parse(dT_1.Rows[i][Col].ToString().Trim()) <= float.Parse(as_value.Trim())) return i; } else if (as_type == "<") ...{ if (float.Parse(dT_1.Rows[i][Col].ToString().Trim()) < float.Parse(as_value.Trim())) return i; } } return -1; } }}