/// <summary>
        /// 根据ID查询不同价格
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public DataTable GetPriceByID(string ID)
        {
            string sql = "SELECT * FROM dbo.Price WHERE ID='" + ID + "'";

            BLL.DbBase db = new BLL.DbBase();
            return(db.ExecuteTable(sql));
        }
        public DataTable GetRegion(int ParentId)
        {
            string sql = string.Format("select ID,Name from Region where ParentId={0}", ParentId);

            BLL.DbBase db = new BLL.DbBase();
            db.ChangeDBShop();
            return(db.ExecuteTable(sql));
        }
        public DataTable GetRegionAll()
        {
            string sql = "SELECT * FROM dbo.Region";

            BLL.DbBase db = new BLL.DbBase();
            db.ChangeDBShop();
            return(db.ExecuteTable(sql));
        }
        /// <summary>
        /// 设置价格加点
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="Plus"></param>
        public void SetPricePlus(string ID, decimal Plus, string CateGory)
        {
            string sql = string.Format("UPDATE dbo.Price SET Price_Plus={0} WHERE ID='{1}' AND CateGory='{2}'", Plus, ID, CateGory);

            BLL.DbBase db = new BLL.DbBase();
            db.ExecuteNonQuery(sql);
            //价格立即生效
            Price price = new Price();

            price.Update(ID, CateGory);
        }
        public string GetImageUrl(int goodsId, int goodsPackageId)
        {
            BLL.DbBase db = new BLL.DbBase();
            db.ChangeDBShop();
            string url = db.ExecuteScalar("SELECT dbo.[GetImagePathOriginal](" + goodsId.ToString() + "," + goodsPackageId.ToString() + ")") as string;

            if (string.IsNullOrEmpty(url))
            {
                url = "images/nopic1.jpg";
            }
            return("http://image.101yao.com//" + url);
        }
Beispiel #6
0
        public static void CreateTable(DataSet ds, string TableName, string DataBase)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("CREATE TABLE [" + TableName + "](");
            foreach (System.Data.DataRow item in ds.Tables[0].Rows)
            {
                sb.Append(string.Format("[{0}] [{1}] {2} {3},", item["ColName"], item["ColTypeName"], GetLen(item["ColTypeName"].ToString(), int.Parse(item["length"].ToString())), int.Parse(item["AllowNull"].ToString()) == 1 ? "NULL" : "NOT NULL"));
            }
            sb.Remove(sb.Length - 1, 1);
            sb.Append(")");
            DbBase db = new DbBase();

            db.ChangeDB(DataBase).ExecuteNonQuery(sb.ToString());
        }
        public string Login(string name, string pwd)
        {
            BLL.DbBase bll = new BLL.DbBase();
            bll.ChangeDBShop();
            int c = (int)bll.ExecuteScalar(string.Format("SELECT COUNT(*) FROM yxs_administrators  WHERE NAME='{0}' AND PASSWORD='******'", Library.Lang.Input.Filter(name), Library.Lang.Input.MD5(pwd, false)));

            if (c == 1)
            {
                Memcached.ClientLibrary.MemcachedClient mc = new Memcached.ClientLibrary.MemcachedClient();
                mc.PoolName = "Price_Cache";
                string authKey = MongoDB.Oid.NewOid().ToString();
                mc.Set(authKey, name, DateTime.Now.AddHours(12));
                return(authKey);
            }
            return(null);
        }
        public int Add(TableSyn ts, byte[] data, string key)
        {
            if (dkey.Equals(key))
            {
                string ekey = string.Format("{0}_{1}", ts.TableName, ts.EnterpriseID);
                if (get(ekey) != null)
                {
                    if ((DateTime.Now - (DateTime)get(ekey)).TotalMinutes <= 5)
                    {
                        return(0);
                    }
                    set(ekey, DateTime.Now);
                }
                else
                {
                    set(ekey, DateTime.Now);
                }


                BLL.Data_Centre.Product_Centre logBll = new BLL.Data_Centre.Product_Centre();
                BLL.DbBase db = new BLL.DbBase();
                db.ChangeDBData_Centre();
                DateTime now  = DateTime.Now;
                int      iden = 0; int.TryParse(ts.EnterpriseID, out iden);//公司来源

                #region 开始同步并检查数据
                BLL.Data_Centre.Product_Centre.AddLog("请求数据同步,企业编号:" + iden, 1);
                DSWebService.BLL.ServiceState sstate = new BLL.ServiceState();
                sstate.iden       = iden.ToString();
                sstate.UpdateTime = DateTime.Now;
                sstate.insert();

                var ds = BLL.Utils.GetDataSetByZipBytes(data);//数据来源
                if (iden <= 0 || ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    return(0);
                }
                DataColumnCollection sourceColumns = ds.Tables[0].Columns;
                #endregion
                DateTime now1 = DateTime.Now;//计时
                try
                {
                    switch (ts.TableName)
                    {
                    case "商品数据":
                    {
                        foreach (DataColumn item in ds.Tables[0].Columns)
                        {
                            switch (item.ColumnName)
                            {
                            case "商品编号":
                            {
                                item.ColumnName = "ID";
                                continue;
                            }

                            case "批准文号":
                            {
                                item.ColumnName = "DrugsBase_ApprovalNumber";
                                continue;
                            }

                            case "厂家":
                            {
                                item.ColumnName = "DrugsBase_Manufacturer";
                                continue;
                            }

                            case "通用名":
                            {
                                item.ColumnName = "DrugsBase_DrugName";
                                continue;
                            }

                            case "规格":
                            {
                                item.ColumnName = "DrugsBase_Specification";
                                continue;
                            }

                            case "剂型":
                            {
                                item.ColumnName = "DrugsBase_Formulation";
                                continue;
                            }

                            case "包装单位":
                            {
                                item.ColumnName = "Goods_Unit";
                                continue;
                            }

                            case "转换比":
                            {
                                item.ColumnName = "Goods_ConveRatio";
                                continue;
                            }

                            case "件装":
                            {
                                item.ColumnName = "Goods_Pcs";
                                continue;
                            }

                            case "中包装":
                            {
                                item.ColumnName = "Goods_Pcs_Small";
                                continue;
                            }

                            case "生产日期":
                            {
                                item.ColumnName = "PDate";
                                continue;
                            }

                            case "产地":
                            {
                                item.ColumnName = "ProductionAddress";
                                continue;
                            }

                            case "类别":
                            {
                                item.ColumnName = "ProductionClassName";
                                continue;
                            }

                            case "片型":
                            {
                                item.ColumnName = "DrugsBase_Formulation1";
                                continue;
                            }

                            case "等级":
                            {
                                item.ColumnName = "ProductionLevelName";
                                continue;
                            }

                            case "品牌":
                            {
                                item.ColumnName = "ProductionBrandName";
                                continue;
                            }

                            case "制法":
                            {
                                item.ColumnName = "ProductionMethodName";
                                continue;
                            }

                            case "条码":
                            {
                                item.ColumnName = "Barcode";
                                continue;
                            }

                            case "经营范围":
                            {
                                item.ColumnName = "BusinessScope";
                                continue;
                            }
                            }
                        }
                        db.ExecuteNonQuery("TRUNCATE TABLE Product");
                        db.BulkToDB(ds.Tables[0], "Product");
                        BLL.Log.AddLog("Product 新增加了" + ds.Tables[0].Rows.Count + "条数据,共执行" + (int)((DateTime.Now - now1).TotalMilliseconds) + "毫秒!", 2);
                        break;
                    }

                    case "商品价格":
                    {
                        foreach (DataColumn item in ds.Tables[0].Columns)
                        {
                            switch (item.ColumnName)
                            {
                            case "商品编号":
                            {
                                item.ColumnName = "ID";
                                continue;
                            }

                            case "价格类型":
                            {
                                item.ColumnName = "category";
                                continue;
                            }

                            case "商品价格":
                            {
                                item.ColumnName = "price";
                                continue;
                            }
                            }
                        }
                        db.ExecuteNonQuery("TRUNCATE TABLE Price_TEMP");
                        db.BulkToDB(ds.Tables[0], "Price_TEMP");
                        BLL.Log.AddLog("Price_TEMP 新增加了" + ds.Tables[0].Rows.Count + "条数据,共执行" + (int)((DateTime.Now - now1).TotalMilliseconds) + "毫秒!", 2);
                        break;
                    }

                    case "商品库存":
                    {
                        foreach (DataColumn item in ds.Tables[0].Columns)
                        {
                            switch (item.ColumnName)
                            {
                            case "商品编号":
                            {
                                item.ColumnName = "id";
                                continue;
                            }

                            case "商品库存":
                            {
                                item.ColumnName = "Stock";
                                continue;
                            }

                            case "批号":
                            {
                                item.ColumnName = "pihao";
                                continue;
                            }

                            case "效期":
                            {
                                item.ColumnName = "sxrq";
                                continue;
                            }
                            }
                        }
                        db.ExecuteNonQuery("TRUNCATE TABLE View_Stock1");
                        db.BulkToDB(ds.Tables[0], "View_Stock1");
                        BLL.Log.AddLog("View_Stock1 新增加了" + ds.Tables[0].Rows.Count + "条数据,共执行" + (int)((DateTime.Now - now1).TotalMilliseconds) + "毫秒!", 2);
                        break;
                    }
                    }
                }
                catch (Exception ex)
                {
                    BLL.Log.AddLog("请求数据同步,企业编号:" + iden + "," + ex.Message.ToString() + ex.StackTrace.ToString(), 0);
                }

                return(1);
            }
            return(0);
        }