博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

C# DataTable 一些方法 和Sql语句

Posted on 2013-03-16 20:00  Hamilton Tan  阅读(1994)  评论(0编辑  收藏  举报

select ldp_eb.new_name as ParameterName,ldi_eb.new_decision_value as NewDecisionValue
from new_level_determination_infoExtensionBase as ldi_eb
inner join new_level_determination_parameterExtensionBase as ldp_eb on ldi_eb.new_level_determination_parameterid=ldp_eb.new_level_determination_parameterId
inner join new_level_determination_parameterExtensionBase as master_ldp_eb on ldp_eb.new_name=master_ldp_eb.new_name
where ldi_eb.new_factory_serviceid='B2B7013E-8D80-E211-8497-00155D002D63'
and (
ldp_eb.new_check_type=100000000--check类型为区间check
and cast(ldi_eb.new_decision_value as int) >= ISNULL(master_ldp_eb.new_parameter_value1,0)
and cast(ldi_eb.new_decision_value as int) <=ISNULL(master_ldp_eb.new_parameter_value2,0)
)
union
(
select ldp_eb.new_name as ParameterName,ldi_eb.new_decision_value as NewDecisionValue
from new_level_determination_infoExtensionBase as ldi_eb
inner join new_level_determination_parameterExtensionBase as ldp_eb on ldi_eb.new_level_determination_parameterid=ldp_eb.new_level_determination_parameterId
inner join new_level_determination_parameterExtensionBase as master_ldp_eb on ldp_eb.new_name=master_ldp_eb.new_name
where ldi_eb.new_factory_serviceid='B2B7013E-8D80-E211-8497-00155D002D63'
and (
ldp_eb.new_check_type=100000001 --check类型为等于check
and ldi_eb.new_decision_value = master_ldp_eb.new_parameter_value1 --如果判定值等于参数1
)
)

select b.new_product_level as ProductLevel
,b.new_level as NewLevel
,b.new_product_levelId as ProductLevelId
from new_level_determination_parameterExtensionBase a
left join new_product_levelExtensionBase b
on a.new_product_levelid = b.new_product_levelId
where new_sys_product_lineid='da219c60-5b3c-e211-b99c-00155d002f0d'


select new_parameter_value1 as ParameterValue1,
new_parameter_value2 as ParameterValue2
from new_level_determination_parameterExtensionBase
where new_name='缺陷分类'
and new_sys_product_lineid='da219c60-5b3c-e211-b99c-00155d002f0d'

select b.new_product_level as ProductLevel
,b.new_level as NewLevel
,b.new_product_levelId as ProductLevelId
,a.new_name as parameterName
,a.new_parameter_value1 as newDecisionValue
from new_level_determination_parameterExtensionBase a
left join new_product_levelExtensionBase b
on a.new_product_levelid = b.new_product_levelId
where new_sys_product_lineid='DA219C60-5B3C-E211-B99C-00155D002F0D'
and a.new_name='缺陷分类'
and a.new_parameter_value1='轻度缺陷'

 

#region 根据维修工单下的产品线ID,获取判定等级和等级级别和产品等级ID DataTable
public DataTable getProductLevel(string productId)
{
string sql = @"
select b.new_product_level as ProductLevel
,b.new_level as NewLevel
,b.new_product_levelId as ProductLevelId
,a.new_name as parameterName
,a.new_parameter_value1 as newDecisionValue
from new_level_determination_parameterExtensionBase a
left join new_product_levelExtensionBase b
on a.new_product_levelid = b.new_product_levelId
where new_sys_product_lineid='{0}'";

sql = string.Format(sql,productId);
DataSet ds = new DataSet();
data.Fill(sql, ds);

return ds.Tables[0];
}
#endregion

//取到判定等级 //这里所有的记录中有且仅有一条记录为4等品,则维修工单的等级为4等级。如果没4等品,找到3等品,则为3等品,以此类推。
DataTable dts = logic.getProductLevel(productLineId);

DataRow[] ary_new_level_determination_parameter = dts.Select("parameterName='" + parameterName + "' and newDecisionValue='" + newDecisionValue + "'", "NewLevel desc");

if (ary_new_level_determination_parameter.Length > 0)
{
if (!String.IsNullOrEmpty(ary_new_level_determination_parameter[0]["ProductLevelId"].ToString()) && !String.IsNullOrEmpty(ary_new_level_determination_parameter[0]["NewLevel"].ToString()))
{
string productLevelid = ary_new_level_determination_parameter[0]["ProductLevelId"].ToString();//产品等级ID
int intNewLevel = int.Parse(ary_new_level_determination_parameter[0]["NewLevel"].ToString());//取到等级级别;

if (intNewLevel > intMaxValue)
{
intMaxValue = intNewLevel;
logic.Updatejudgelevel(MasterID, productLevelid); // 更新该维修工单上的判定等级
}

}
}

string sql = logic.getProcessInfoList(servicesId);
string order = " ProcessInfoId ASC ";
bindGrid(sql, order, gridProcessInfoResult, gridProcessInfoPage);
DataView dvSource = gridProcessInfoResult.DataSource as DataView;
DataTable dtSource = dvSource.Table;
object totalMoney = dtSource.Compute("Sum(TotalMoney)", "");
txtFaultTotalAmount.Value = totalMoney.ToString();//合计金额

 

 

(select Value from stringmap S where attributename='new_auditresult'
and objecttypecode =(select objecttypecode from metadataschema.entity
where logicalname='new_auditresult')
and langid='{0}' and AttributeValue=I.new_auditresult) AS AuditResult,