public QccustomerlibraryModelList GetModelListOne(string QcNo)
        {
            QccustomerlibraryModelList result = new QccustomerlibraryModelList();
            CustomSqlSection           sql    = DataAccess.DefaultDB.CustomSql(@"select a.*,b.Name as customerName,c.Name as salesName from QCCustomerLibrary a left join 
                              gen_customer b on a.Buyer_ID=b.Customer_CD 
                              left join GEN_USERS c on  a.Sales=c.USER_ID 
                              where a.Quality_Code='" + QcNo + "'");

            using (DataSet ds = sql.ToDataSet())
            {
                DataTable dt = ds.Tables[0];
                QccustomerlibraryModel m;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    m                   = new QccustomerlibraryModel();
                    m.Iden              = Convert.ToInt32(dt.Rows[i]["Iden"]);
                    m.QualityCode       = dt.Rows[i]["Quality_Code"].ToString();
                    m.BuyerId           = dt.Rows[i]["customerName"].ToString();
                    m.Brand             = dt.Rows[i]["Brand"].ToString();
                    m.CustomerQualityId = dt.Rows[i]["Customer_Quality_ID"].ToString();
                    m.Sales             = dt.Rows[i]["salesName"].ToString();
                    m.SalesGroup        = dt.Rows[i]["Sales_Group"].ToString();
                    m.MillComments      = dt.Rows[i]["Mill_Comments"].ToString();
                    m.IsFirstOwner      = dt.Rows[i]["Is_First_Owner"].ToString();
                    m.CreateDate        = (DateTime)dt.Rows[i]["Create_Date"];
                    m.Creator           = dt.Rows[i]["Creator"].ToString();
                    result.Add(m);
                }
            }
            return(result);
        }
        public QccustomerlibraryModelList GetModelList(QccustomerlibraryModel model)
        {
            QccustomerlibraryTable table = new QccustomerlibraryTable();
            QcmaininfoTable        main  = new QcmaininfoTable();
            SelectSqlSection       sql   = DataAccess.DefaultDB.Select(table, table.AllColumns(), main.Status);

            sql.Join(main, table.QualityCode == main.QualityCode);
            if (model.QualityCode != "")
            {
                sql.Where(table.QualityCode == model.QualityCode);
            }

            using (SafeDataReader sdr = new SafeDataReader(sql.ToDataReader()))
            {
                QccustomerlibraryModelList result = new QccustomerlibraryModelList();
                while (sdr.Read())
                {
                    QccustomerlibraryModel m = new QccustomerlibraryModel();
                    m.Status            = sdr.GetString(main.Status);
                    m.QualityCode       = sdr.GetString(table.QualityCode);
                    m.BuyerId           = sdr.GetString(table.BuyerId);
                    m.Brand             = sdr.GetString(table.Brand);
                    m.CustomerQualityId = sdr.GetString(table.CustomerQualityId);
                    m.Sales             = sdr.GetString(table.Sales);
                    m.SalesGroup        = sdr.GetString(table.SalesGroup);
                    m.MillComments      = sdr.GetString(table.MillComments);
                    m.IsFirstOwner      = sdr.GetString(table.IsFirstOwner);
                    m.CreateDate        = sdr.GetDateTime(table.CreateDate);
                    m.Creator           = sdr.GetString(table.Creator);
                    result.Add(m);
                }
                return(result);
            }
        }