public void UpdateResultVehicleInfo(RESULT_VEHICLE_INFO entity) { PropertyInfo[] propertyInfos = entity.GetType().GetProperties(); string strSql = "UPDATE RESULT_VEHICLE_INFO SET "; foreach (PropertyInfo p in propertyInfos) { if (p.Name != "ID" && p.Name != "JCLSH") { strSql += string.Format("{0}='{1}',", p.Name, p.GetValue(entity, null)); } } strSql = strSql.Substring(0, strSql.Length - 1); strSql += string.Format(" WHERE JCLSH ='{0}'", entity.JCLSH); SqlHelper.ExcuteNonQuery(CommandType.Text, strSql); }
public void SaveBaseData() { PropertyInfo[] propertyInfos = m_RESULT_VEHICLE_INFO.GetType().GetProperties(); foreach (Control col in tabBase.Controls) { if (col is FieldTxt) { FieldTxt fieldTxt = (FieldTxt)col; foreach (PropertyInfo p in propertyInfos) { if (p.Name == fieldTxt.Name.Replace("txt", "")) { p.SetValue(m_RESULT_VEHICLE_INFO, Convert.ChangeType(fieldTxt.Text, p.PropertyType), null); } } } } IRESULT_VEHICLE_INFO_BLL bll = ObjectFactory.CreateObject <IRESULT_VEHICLE_INFO_BLL>(); bll.UpdateResultVehicleInfo(m_RESULT_VEHICLE_INFO); }
public void LoadBaseData(string strJCLSH) { IRESULT_VEHICLE_INFO_BLL bll = ObjectFactory.CreateObject <IRESULT_VEHICLE_INFO_BLL>(); m_RESULT_VEHICLE_INFO = bll.GetResultVehicleInfoByJCLSH(strJCLSH); PropertyInfo[] propertyInfo = m_RESULT_VEHICLE_INFO.GetType().GetProperties(); foreach (Control col in tabBase.Controls) { if (col is FieldTxt) { FieldTxt fieldTxt = (FieldTxt)col; foreach (PropertyInfo p in propertyInfo) { if (p.Name == fieldTxt.Name.Replace("txt", "")) { fieldTxt.Text = (string)p.GetValue(m_RESULT_VEHICLE_INFO, null); } } } } }