Example #1
0
        public IList<PartInfoMaintainInfo> GetPartInfoListByPartNo(string partNo)
        {
            try
            {
                _Schema.SQLContext sqlCtx = new _Schema.SQLContext();
                IList<PartInfoMaintainInfo> ret = new List<PartInfoMaintainInfo>();
                //string pn, string bomNodeType, string type, string custpn, string descr, string remark, string autodl, string editor, DateTime cdt, DateTime udt, string descr2  
                string SQLStatement = @"select ID,PartNo,InfoType,InfoValue,Editor,Cdt,Udt from PartInfo with(NOLOCK) where PartNo=@PartNo
                                                            Union
                                                            (
                                                                 select '',@PartNo,Code,'','','','' from PartTypeAttribute with(NOLOCK) where PartType 
                                                                  in(  select PartType from Part where PartNo=@PartNo)
                                                                 and Code not in 
                                                                 (
                                                                  select InfoType from PartInfo with(NOLOCK) where PartNo=@PartNo
                                                                 ) 
                                                             );";

               
                sqlCtx.Params.Add("PartNo", new SqlParameter("@PartNo", SqlDbType.VarChar));
                sqlCtx.Params["PartNo"].Value = partNo;
                        
                using (DataTable dt = _Schema.SqlHelper.ExecuteDataFill(_Schema.SqlHelper.ConnectionString_GetData,
                                                                                                                             CommandType.Text, SQLStatement,
                                                                                                                             sqlCtx.Params.Values.ToArray<SqlParameter>()))
                {
                    string colName;
                    object value;
                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            PartInfoMaintainInfo partInfo = new PartInfoMaintainInfo();
                                                
                                 foreach (FieldInfo f in partInfo.GetType().GetFields())
                                    {
                                        
                                         colName=f.Name;
                                         value=dr[colName];
                                         partInfo.GetType().GetField(colName).SetValue(partInfo, value);

                                    }

                            //

                                 ret.Add(partInfo);
                        }


                    }


                }
                return ret;
            }
            catch (Exception)
            {
                throw;
            }
        
        
        
        }