Exemplo n.º 1
0
        public void Import()
        {
            if ( !AppConfig.IsImportable)
                throw new BizException("Is Importable is false");

            /*  do not  use the following code after Data Pour in */
            string sql = " select top 1 * from wishlist ";
            DataSet ds = SqlHelper.ExecuteDataSet(sql);
            if ( Util.HasMoreRow(ds) )
                throw new BizException("the table wishlist is not empty");

            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                string sql1 = @"select
                                1 as sysno, wl.webusersysno as customersysno, con_product.newsysno as productsysno, null as createtime
                            from
                                ipp2003..myfavorite wl, ippconvert..productbasic con_product
                            where
                                wl.productsysno = con_product.oldsysno";
                DataSet ds1 = SqlHelper.ExecuteDataSet(sql1);
                foreach(DataRow dr1 in ds1.Tables[0].Rows)
                {
                    WishListInfo oWishList = new WishListInfo();
                    map(oWishList,dr1);
                    new WishListDac().Insert(oWishList);
                }

            scope.Complete();
            }
        }
Exemplo n.º 2
0
        public int Insert(WishListInfo oParam)
        {
            string sql = @"INSERT INTO WishList
                            (
                            CustomerSysNo, ProductSysNo, CreateTime
                            )
                            VALUES (
                            @CustomerSysNo, @ProductSysNo, @CreateTime
                            );set @SysNo = SCOPE_IDENTITY();";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSysNo = new SqlParameter("@SysNo", SqlDbType.Int,4);
            SqlParameter paramCustomerSysNo = new SqlParameter("@CustomerSysNo", SqlDbType.Int,4);
            SqlParameter paramProductSysNo = new SqlParameter("@ProductSysNo", SqlDbType.Int,4);
            SqlParameter paramCreateTime = new SqlParameter("@CreateTime", SqlDbType.DateTime);

            paramSysNo.Direction = ParameterDirection.Output;

            if ( oParam.CustomerSysNo != AppConst.IntNull)
                paramCustomerSysNo.Value = oParam.CustomerSysNo;
            else
                paramCustomerSysNo.Value = System.DBNull.Value;
            if ( oParam.ProductSysNo != AppConst.IntNull)
                paramProductSysNo.Value = oParam.ProductSysNo;
            else
                paramProductSysNo.Value = System.DBNull.Value;
            if ( oParam.CreateTime != AppConst.DateTimeNull)
                paramCreateTime.Value = oParam.CreateTime;
            else
                paramCreateTime.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSysNo);
            cmd.Parameters.Add(paramCustomerSysNo);
            cmd.Parameters.Add(paramProductSysNo);
            cmd.Parameters.Add(paramCreateTime);

            return SqlHelper.ExecuteNonQuery(cmd, out oParam.SysNo);
        }
Exemplo n.º 3
0
 private void map(WishListInfo oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.CustomerSysNo = Util.TrimIntNull(tempdr["CustomerSysNo"]);
     oParam.ProductSysNo = Util.TrimIntNull(tempdr["ProductSysNo"]);
     oParam.CreateTime = Util.TrimDateNull(tempdr["CreateTime"]);
 }
Exemplo n.º 4
0
 public void Insert(WishListInfo oParam)
 {
     //����Ѿ����ڣ��Ͳ������
     string sql = "select * from wishlist where customersysno=" + oParam.CustomerSysNo + " and productSysNo=" + oParam.ProductSysNo;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     if ( Util.HasMoreRow(ds))
         return;
     new WishListDac().Insert(oParam);
 }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IcsonSessionInfo oSessionInfo = CommonUtility.GetUserSession(Context);

            CustomerInfo cInfo = oSessionInfo.sCustomer;
            int cSysNo = cInfo.SysNo;

            bool result = false;
            string msg = String.Empty;

            try
            {
                switch (Cmd)
                {
                    //添加商品到收藏
                    case "add":
                        {
                            WishListInfo wInfo = new WishListInfo();
                            wInfo.CustomerSysNo = cSysNo;
                            wInfo.ProductSysNo = productSysNo;
                            WishListManager.GetInstance().Insert(wInfo);
                            result = true;
                            msg = "成功添加";
                            Response.Write(JsonContentTransfomer<object>.GetJsonContent(new { IsSuccess = result, Msg = msg }));
                            break;
                        }
                    //删除单个收藏商品
                    case "delete":
                        {
                            foreach (string pid in productSysNos)
                            {
                                WishListManager.GetInstance().Delete(cSysNo, int.Parse(pid));
                            }
                            msg = "删除成功";
                            Response.Write(JsonContentTransfomer<object>.GetJsonContent(new { IsSuccess = result, Msg = msg }));
                            break;
                        }
                    //清空收藏商品
                    case "empty":
                        {
                            WishListManager.GetInstance().Clear(cSysNo);
                            msg = "清空收藏夹成功";
                            Response.Write(JsonContentTransfomer<object>.GetJsonContent(new { IsSuccess = result, Msg = msg }));
                            break;
                        }
                    //获得分页的收藏列表
                    default:
                        {
                            Response.Write(CustomerHelper.GetCustomerWishListProducts(cSysNo, StartIndex));
                            break;
                        }
                }
            }
            catch
            {
                msg = "用户请求的操作失败";
                Response.Write(JsonContentTransfomer<object>.GetJsonContent(new { IsSuccess = result, Msg = msg }));
            }
        }