获得数据表中指定 列的Cell值与参数值 满足比较关系的第一个行号

 

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 == nullreturn "";
            
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;
        }

    }

}

 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值