예제 #1
0
 /// <summary>
 /// 查詢商品對照是否存在(組合)
 /// </summary>
 /// <param name="p">一條商品信息</param>
 /// <returns></returns>
 public int Comb_Exist(ProductItemMapCustom p)
 {
     p.Replace4MySQL();
     tempStr = string.Format("select count(rid) from product_item_map where channel_id={0} and  product_id={1} and group_item_id='{2}'", p.channel_id, p.product_id, p.group_item_id);
     if (p.channel_detail_id != "" && p.channel_detail_id != null)
     {
         tempStr += string.Format(" and channel_detail_id='{0}' ", p.channel_detail_id);
     }
     return int.Parse(_accessMySql.getDataTable(tempStr).Rows[0][0].ToString());
 }
예제 #2
0
        public void Save_Comb(ProductItemMapCustom p)
        {
            p.Replace4MySQL();
            MySqlCommand Mycmd = new MySqlCommand(string.Format("insert into product_item_map (`channel_id`, `channel_detail_id`, `group_item_id`, `product_name`, `product_cost`, `product_price`,product_id ,price_master_id) values ({0},'{1}','{2}','{3}',{4},{5},{6},{7});select @@identity;", p.channel_id, p.channel_detail_id, p.group_item_id, p.product_name, p.product_cost, p.product_price, p.product_id, p.price_master_id), Mycon);
            Mycon.Open();
            int rid = int.Parse(Mycmd.ExecuteScalar().ToString());
            Mycon.Close();

            if (p.MapChild.Count > 0)       //手動添加
            {
                for (int i = 0, j = p.MapChild.Count; i < j; i++)
                {
                    tempStr = string.Format("insert into product_map_set(map_rid,item_id,set_num)values({0},{1},{2})", rid, p.MapChild[i].item_id, p.MapChild[i].set_num);
                    _accessMySql.execCommand(tempStr);
                }
            }
            else        //匯入對照
            {
                for (int i = 0; i < p.group_item_id.Split(',').Length; i++)
                {
                    if (p.set_num == 0)
                    {
                        p.set_num = uint.Parse(_accessMySql.getDataTable(string.Format("select s_must_buy from product_combo where parent_id={0} and child_id =(select product_id from product_item where item_id={1})", p.product_id, p.group_item_id.Split(',')[i])).Rows[0][0].ToString());

                    }
                    tempStr = string.Format("insert into product_map_set(map_rid,item_id,set_num)values({0},{1},{2})", rid, uint.Parse(p.group_item_id.Split(',')[i]), p.set_num);
                    _accessMySql.execCommand(tempStr);
                }
            }

        }