public static List <InsightSupplierMerchandising> GetSupplierAuthorizationBySupplierId(int supplierId)
        {
            List <InsightSupplierMerchandising> list = new List <InsightSupplierMerchandising>();

            Database  db         = DatabaseFactory.CreateDatabase("SPARInsightManagement");
            string    sqlCommand = "GetSupplierAuthorizationBySupplierId";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@SupplierId", DbType.Int32, supplierId);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    InsightSupplierMerchandising insightSupplierMerchandising = new InsightSupplierMerchandising();
                    insightSupplierMerchandising.SupplierId    = Convert.ToInt32(dataReader["SupplierID"]);
                    insightSupplierMerchandising.MerchId       = Convert.ToInt32(dataReader["MerchId"]);
                    insightSupplierMerchandising.ProductClause = dataReader["ProductClause"].ToString();
                    insightSupplierMerchandising.StoreClause   = dataReader["StoreClause"].ToString();
                    insightSupplierMerchandising.SupplierName  = dataReader["Name"].ToString();
                    insightSupplierMerchandising.Discontinued  = Convert.ToBoolean(dataReader["Discontinued"]);
                    insightSupplierMerchandising.Merchandising = dataReader["Merchandising"].ToString();
                    list.Add(insightSupplierMerchandising);
                }
            }
            return(list);
        }
        public static List <InsightSupplierMerchandising> GetSupplierMerchandisingListCustom(int insightSupplierId)
        {
            List <InsightSupplierMerchandising> list = new List <InsightSupplierMerchandising>();

            Database  db         = DatabaseFactory.CreateDatabase("SPARInsightManagement");
            string    sqlCommand = "GetSupplierMerchandisingListCustom";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@InsightSupplierId", DbType.Int32, insightSupplierId);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    InsightSupplierMerchandising insightSupplierMerchandising = new InsightSupplierMerchandising();
                    insightSupplierMerchandising.InsightSupplierMerchandisingId = Convert.ToInt32(dataReader["InsightSupplierMerchandisingId"]);
                    insightSupplierMerchandising.SupplierId = Convert.ToInt32(dataReader["SupplierID"]);
                    //insightSupplierMerchandising.CustomSupplierId = dataReader["CustomSupplierId"].ToString();
                    insightSupplierMerchandising.SupplierName       = dataReader["Name"].ToString();
                    insightSupplierMerchandising.Discontinued       = Convert.ToBoolean(dataReader["Discontinued"]);
                    insightSupplierMerchandising.GroupId            = Convert.ToInt32(dataReader["GroupId"]);
                    insightSupplierMerchandising.MerchandisingGroup = dataReader["Merchandising_Group"].ToString();
                    insightSupplierMerchandising.MerchId            = Convert.ToInt32(dataReader["MerchId"]);
                    insightSupplierMerchandising.Merchandising      = dataReader["Merchandising"].ToString();
                    insightSupplierMerchandising.IsIncluded         = Convert.ToInt32(dataReader["IsIncluded"]);
                    insightSupplierMerchandising.CustomSupplierId   = dataReader["CustomSupplierId"].ToString();
                    list.Add(insightSupplierMerchandising);
                }
            }
            return(list);
        }
        public static InsightSupplierMerchandising GetCustomSupplierByInsightSupplierId(int insightSupplierId)
        {
            Database  db         = DatabaseFactory.CreateDatabase("SPARInsightManagement");
            string    sqlCommand = "GetCustomSupplierByInsightSupplierId";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@InsightSupplierId", DbType.Int32, insightSupplierId);
            db.AddOutParameter(dbCommand, "@CustomSupplierId", DbType.String, 50);
            db.ExecuteNonQuery(dbCommand);
            InsightSupplierMerchandising insightSupplierMerchandising = new InsightSupplierMerchandising();

            insightSupplierMerchandising.InsightSupplierId = insightSupplierId;
            insightSupplierMerchandising.CustomSupplierId  = db.GetParameterValue(dbCommand, "CustomSupplierId").ToString();
            return(insightSupplierMerchandising);
        }
        public static InsightSupplierMerchandising GetInsightSupplierMerchandisingBySupplierId(int supplierId, int insightSupplierId)
        {
            Database  db         = DatabaseFactory.CreateDatabase("SPARInsightManagement");
            string    sqlCommand = "GetInsightSupplierMerchandisingBySupplierId";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@SupplierId", DbType.Int32, supplierId);
            db.AddInParameter(dbCommand, "@InsightSupplierId", DbType.Int32, insightSupplierId);
            db.AddOutParameter(dbCommand, "@IsIncluded", DbType.Int32, 4);
            db.ExecuteNonQuery(dbCommand);
            InsightSupplierMerchandising insightSupplierMerchandising = new InsightSupplierMerchandising();

            insightSupplierMerchandising.InsightSupplierId = insightSupplierId;
            insightSupplierMerchandising.IsIncluded        = Convert.ToInt32(db.GetParameterValue(dbCommand, "IsIncluded"));
            return(insightSupplierMerchandising);
        }
        public static List <InsightSupplierMerchandising> GetSupplierParentList()
        {
            List <InsightSupplierMerchandising> list = new List <InsightSupplierMerchandising>();

            Database  db         = DatabaseFactory.CreateDatabase("SPARInsightManagement");
            string    sqlCommand = "GetSupplierParentList";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    InsightSupplierMerchandising insightSupplierMerchandising = new InsightSupplierMerchandising();
                    insightSupplierMerchandising.SupplierParentId = Convert.ToInt32(dataReader["SupplierParentId"]);
                    insightSupplierMerchandising.SupplierParent   = dataReader["SupplierParent"].ToString();
                    list.Add(insightSupplierMerchandising);
                }
            }
            return(list);
        }