Exemplo n.º 1
0
    //更新操作
    protected void List_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int      itemId      = Convert.ToInt32(List.DataKeys[e.RowIndex].Value);
        string   itemName    = ((TextBox)List.Rows[e.RowIndex].FindControl("ItemNameBox")).Text.Trim();
        string   itemType    = ((DropDownList)List.Rows[e.RowIndex].FindControl("ItemTypeDropDown")).SelectedValue.ToString();
        string   itemPrice   = ((TextBox)List.Rows[e.RowIndex].FindControl("ItemPriceBox")).Text.Trim();
        DateTime itemBuyDate = Convert.ToDateTime(((TextBox)List.Rows[e.RowIndex].FindControl("ItemBuyDateBox")).Text.Trim() + " " + DateTime.Now.ToString("HH:mm:ss"));
        int      cardId      = Convert.ToInt32(((DropDownList)List.Rows[e.RowIndex].FindControl("CardDropDown")).SelectedValue);

        if (itemName == "")
        {
            Utility.Alert(this, "商品名称未填写!");
            return;
        }

        ItemInfo item = item_bll.GetItemByItemId(itemId);

        item.ItemID      = itemId;
        item.ItemType    = itemType;
        item.ItemName    = itemName;
        item.ItemPrice   = Convert.ToDecimal(itemPrice);
        item.ItemBuyDate = itemBuyDate;
        item.Synchronize = 1;
        item.ModifyDate  = DateTime.Now;
        item.CardID      = cardId;

        bool success = item_bll.UpdateItem(item);

        if (success)
        {
            Session["TodayDate"] = itemBuyDate.ToString("yyyy-MM-dd");

            List.EditIndex = -1;
            BindGrid();
        }
    }
Exemplo n.º 2
0
    //更新操作
    protected void ItemGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int      itemId      = Convert.ToInt32(ItemGrid.DataKeys[e.RowIndex].Value);
        string   itemName    = ((TextBox)ItemGrid.Rows[e.RowIndex].FindControl("ItemNameBox")).Text.Trim();
        string   itemType    = ((DropDownList)ItemGrid.Rows[e.RowIndex].FindControl("ItemTypeDropDown")).SelectedValue.ToString();
        int      catTypeId   = Convert.ToInt32(((DropDownList)ItemGrid.Rows[e.RowIndex].FindControl("CatTypeDropDown")).SelectedValue);
        string   itemPrice   = ((TextBox)ItemGrid.Rows[e.RowIndex].FindControl("ItemPriceBox")).Text.Trim();
        DateTime itemBuyDate = Convert.ToDateTime(((TextBox)ItemGrid.Rows[e.RowIndex].FindControl("ItemBuyDateBox")).Text.Trim() + " " + DateTime.Now.ToString("HH:mm:ss"));
        int      regionId    = Convert.ToInt32(((HiddenField)ItemGrid.Rows[e.RowIndex].FindControl("RegionIDHid")).Value);
        int      cardId      = Convert.ToInt32(((DropDownList)ItemGrid.Rows[e.RowIndex].FindControl("CardDropDown")).SelectedValue);
        int      ztId        = Convert.ToInt32(((DropDownList)ItemGrid.Rows[e.RowIndex].FindControl("ZhuanTiDropDown")).SelectedValue);
        byte     recommend   = Convert.ToByte(((CheckBox)ItemGrid.Rows[e.RowIndex].FindControl("RecommendBox")).Checked);
        int      itemAppId   = 0;

        if (itemName == "")
        {
            Utility.Alert(this, "商品名称未填写!");
            return;
        }

        ItemInfo item = bll.GetItemByItemId(itemId);

        item.ItemID         = itemId;
        item.ItemType       = itemType;
        item.ItemName       = itemName;
        item.CategoryTypeID = catTypeId;
        item.ItemPrice      = Convert.ToDecimal(itemPrice);
        item.ItemBuyDate    = itemBuyDate;
        item.Synchronize    = 1;
        item.CardID         = cardId;
        item.ZhuanTiID      = ztId;
        item.ModifyDate     = DateTime.Now;
        item.Recommend      = recommend;

        bool success = false;

        using (TransactionScope ts = new TransactionScope())
        {
            if (regionId > 0)
            {
                DataTable items = bll.GetItemListByRegionId(userId, regionId);
                foreach (DataRow dr in items.Rows)
                {
                    itemId      = Convert.ToInt32(dr["ItemID"]);
                    itemAppId   = Convert.ToInt32(dr["ItemAppID"]);
                    itemBuyDate = Convert.ToDateTime(dr["ItemBuyDate"]);
                    recommend   = Convert.ToByte(dr["Recommend"]);

                    item.ItemID      = itemId;
                    item.ItemAppID   = itemAppId;
                    item.ItemBuyDate = itemBuyDate;
                    item.Recommend   = recommend;

                    success = bll.UpdateItem(item);
                }
            }
            else
            {
                success = bll.UpdateItem(item);
            }

            ts.Complete();
        }

        if (success)
        {
            ItemGrid.EditIndex = -1;
            BindItemGrid();
        }
        else
        {
            Utility.Alert(this, "修改失败!");
        }
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string   itemName    = Request.Form["itemname"].ToString();
        int      itemAppId   = Convert.ToInt32(Request.Form["itemid"]);
        int      itemId      = Convert.ToInt32(Request.Form["itemwebid"]);
        int      catId       = Convert.ToInt32(Request.Form["catid"]);
        decimal  itemPrice   = Convert.ToDecimal(Request.Form["itemprice"]);
        DateTime itemBuyDate = Convert.ToDateTime(Request.Form["itembuydate"]);
        int      userId      = Convert.ToInt32(Request.Form["userid"]);
        byte     recommend   = Convert.ToByte(Request.Form["recommend"]);
        int      regionId    = Convert.ToInt32(Request.Form["regionid"]);
        string   regionType  = (regionId == 0 ? "" : Request.Form["regiontype"] ?? "m");
        string   itemType    = Request.Form["itemtype"].ToString();
        string   ztId        = Request.Form["ztid"] ?? "0";
        string   cardId      = Request.Form["cardid"] ?? "0";
        string   remark      = Request.Form["remark"] ?? "";

        ItemInfo item = useMsmq ? new ItemInfo() : bll.GetItemByItemAppId(userId, itemAppId);

        item.ItemType       = itemType;
        item.ItemName       = itemName;
        item.CategoryTypeID = catId;
        item.ItemPrice      = itemPrice;
        item.ItemBuyDate    = itemBuyDate;
        item.ItemAppID      = itemAppId;
        item.Recommend      = recommend;
        item.RegionID       = regionId;
        item.RegionType     = regionType;
        item.Synchronize    = 0;
        item.UserID         = userId;
        item.ZhuanTiID      = Convert.ToInt32(ztId);
        item.CardID         = Convert.ToInt32(cardId);
        item.ModifyDate     = DateTime.Now;
        item.Remark         = remark;

        //写日志
        log.Info(string.Format(" ItemInfo -> {0}", item.ToString()));

        bool success = false;

        if (useMsmq)
        {
            //string json = Newtonsoft.Json.JsonConvert.SerializeObject(item);
            success = MsmqHelper.SendMessage(item);
        }
        else
        {
            if (item.ItemID > 0)
            {
                success = bll.UpdateItemByItemAppId(item);
            }
            else if (itemId > 0)
            {
                item                = bll.GetItemByItemId(itemId);
                item.ItemType       = itemType;
                item.ItemName       = itemName;
                item.CategoryTypeID = catId;
                item.ItemPrice      = itemPrice;
                item.ItemBuyDate    = itemBuyDate;
                item.ItemAppID      = itemAppId;
                item.Recommend      = recommend;
                item.RegionID       = regionId;
                item.RegionType     = regionType;
                item.Synchronize    = 0;
                item.UserID         = userId;
                item.ZhuanTiID      = Convert.ToInt32(ztId);
                item.CardID         = Convert.ToInt32(cardId);
                item.ModifyDate     = DateTime.Now;
                item.Remark         = remark;

                if (item.ItemID > 0)
                {
                    success = bll.UpdateItemWithSync(item);
                }
                else
                {
                    success = bll.InsertItemWithSync(item);
                }
            }
            else
            {
                success = bll.InsertItemWithSync(item);
            }
        }

        string result = "{";

        if (success)
        {
            result += "\"result\":\"" + item.ItemID + "\"";
        }
        else
        {
            result += "\"result\":\"0\"";
        }
        result += "}";

        Response.Write(result);
        Response.End();
    }