Example #1
0
        /// <summary>
        /// 获取礼品信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public GiftInfo GetModel(string id)
        {
            GiftService.GiftService service = new QJVRMS.Business.GiftService.GiftService();
            DataTable dt = service.GetGiftModel(id);
            GiftInfo model = new GiftInfo();
            if (dt.Rows.Count > 0)
            {
                model.Id = id;
                model.Title = dt.Rows[0]["Title"].ToString();
                model.TypeId = dt.Rows[0]["TypeId"].ToString();
                if (dt.Rows[0]["Quantity"].ToString() != "")
                {
                    model.Quantity = int.Parse(dt.Rows[0]["Quantity"].ToString());
                }
                model.ImageId = dt.Rows[0]["ImageId"].ToString();
                if (dt.Rows[0]["Status"].ToString() != "")
                {
                    model.Status = int.Parse(dt.Rows[0]["Status"].ToString());
                }
                if (dt.Rows[0]["CreateTime"].ToString() != "")
                {

                    model.CreateTime = DateTime.Parse(dt.Rows[0]["CreateTime"].ToString());
                }
                model.Remark = dt.Rows[0]["Remark"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }
Example #2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //根节点
            TreeNode parentNode = catalogTree.RootNode;
            //获取checked的节点List
            ArrayList nodeList = new ArrayList();
            this.catalogTree.ArrCheckbox(nodeList, parentNode);
            

            ArrayList catalogIds = new ArrayList(nodeList.Count);
            foreach (TreeNode node in nodeList)
            {

                catalogIds.Add(new Guid(node.Value));
            }

            if (catalogIds.Count == 0)
            {
                this.ShowMessage(this, "没有选择分类,上传失败!");
                return;
            }

            GiftBiz biz = new GiftBiz();
            GiftInfo model = new GiftInfo();
            if (ViewState["Id"] != null)
            {
                model = biz.GetModel(ViewState["Id"].ToString());
            }
            else
            {
                model.Id = biz.GetNewId();
            }

            model.Title = txtTitle.Text.Trim();
            model.Quantity = int.Parse(txtQuantity.Text.Trim());
            model.Status = 1;
            model.Remark = txtRemark.Text.Trim();
            model.TypeId = ddlGiftType.SelectedValue;
            if (ViewState["Id"] == null)
            {
                //model.ImageId = UploadImage();
                model.ImageId = newUploadImage();
                if (model.ImageId == null)
                {
                    return;
                }
                biz.AddGift(model);
            }
            else
            {
                if (fuImage.FileName != string.Empty)
                {
                    model.ImageId = UploadImage();
                    if (model.ImageId == null)
                    {
                        return;
                    }
                }
                int i = biz.UpdateGift(model);
            }


            Resource objResource = new Resource();
            objResource.CreateRelationshipResourceAndCatalog(new Guid(model.ImageId), (Guid[])catalogIds.ToArray(typeof(Guid)));


            //ImageStorageClass imageClass = new ImageStorageClass();

            //imageClass.CreateRelationshipImageAndCatalog(new Guid(model.ImageId), (Guid[])catalogIds.ToArray(typeof(Guid)));

            this.ShowMessage(this, "保存成功!");
            Response.Redirect("Gift_List.aspx");
        }
Example #3
0
 /// <summary>
 /// 更新礼品信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdateGift(GiftInfo model)
 {
     GiftService.GiftService service = new QJVRMS.Business.GiftService.GiftService();
     return service.UpdateGift(model.Id, model.Title, model.TypeId, model.Quantity, model.ImageId, model.Status, model.Remark);
 }
Example #4
0
        /// <summary>
        /// 生成订单,并指定订单状态
        /// </summary>
        private string CreateOrder(int orderState)
        {           
            OrdersBiz biz = new OrdersBiz();
            OrderInfo orderModel = new OrderInfo();
            GiftBiz giftBiz = new GiftBiz();

            //添加订单信息
            orderModel.OrderId = biz.GetNewOrderId();
            orderModel.UserId = CurrentUser.UserId.ToString();
            orderModel.Operator = CurrentUser.OperatorId.ToString();
            orderModel.State = orderState;
            orderModel.Address = address.Text;
            orderModel.Contactor = Contactor.Text;
            orderModel.Tel = Tel.Text;
            orderModel.Email = Email.Text;

            Orders_DetailInfo[] details = new Orders_DetailInfo[gvShoppingCartList.Rows.Count];
            GiftInfo[] giftInfoList = new GiftInfo[gvShoppingCartList.Rows.Count];
            int i = 0;

            //添加订单明细,先检查数量是否足够
            foreach (GridViewRow row in gvShoppingCartList.Rows)
            {
                Label lblGiftId = row.FindControl("lblGiftId") as Label;
                TextBox txtCount = row.FindControl("txtCount") as TextBox;
                TextBox txtUsage = row.FindControl("txtUsage") as TextBox;

                Orders_DetailInfo detailModel = new Orders_DetailInfo();
                detailModel.OrderId = orderModel.OrderId;
                detailModel.GiftId = lblGiftId.Text;
                detailModel.GiftCount = int.Parse(txtCount.Text);
                detailModel.Usage = txtUsage.Text;

                GiftInfo giftModel = giftBiz.GetModel(detailModel.GiftId);

                if (giftModel.Quantity < detailModel.GiftCount)
                {
                    lErrorInfo.Text = "礼品【" + giftModel.Title + "】数量不足,剩余数量为:" + giftModel.Quantity.ToString() + "!";
                    return string.Empty;
                }

                giftInfoList[i] = giftModel;
                details[i] = detailModel;
                i++;
            }

            //遍历更新
            for (i = 0; i < details.Length; i++)
            {
                biz.AddOrders_Detail(details[i]);
                giftInfoList[i].Quantity -= details[i].GiftCount;
                giftBiz.UpdateGift(giftInfoList[i]);
            }
            biz.AddOrders(orderModel);

            //清除购物车
            HttpCookie cookie = Request.Cookies["ShoppingCart"];
            cookie.Expires = DateTime.Now.AddHours(-2);
            Response.Cookies.Add(cookie);
            return orderModel.OrderId;
        }