Exemplo n.º 1
0
    //快速添加消费
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        string   itemName    = this.ItemNameEmpIns.Text.Trim();
        string   itemType    = this.ItemTypeEmpIns.SelectedValue;
        int      catTypeId   = Convert.ToInt32(this.CatTypeEmpIns.SelectedValue);
        string   itemPrice   = this.ItemPriceEmpIns.Text.Trim();
        DateTime itemBuyDate = Convert.ToDateTime(this.ItemBuyDateEmpIns.Text.Trim() + " " + DateTime.Now.ToString("HH:mm:ss"));
        int      cardId      = Convert.ToInt32(this.CardEmpIns.SelectedValue);

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

        Response.Cookies["CatTypeID"].Value   = catTypeId.ToString();
        Response.Cookies["CatTypeID"].Expires = DateTime.MaxValue;

        Response.Cookies["CardID"].Value   = cardId.ToString();
        Response.Cookies["CardID"].Expires = DateTime.MaxValue;

        if (!ValidHelper.CheckDouble(itemPrice))
        {
            Utility.Alert(this, "商品价格填写错误!");
            return;
        }

        ItemInfo item = new ItemInfo();

        item.ItemType       = itemType;
        item.ItemName       = itemName;
        item.CategoryTypeID = catTypeId;
        item.ItemPrice      = Convert.ToDecimal(itemPrice);
        item.ItemBuyDate    = itemBuyDate;
        item.UserID         = userId;
        item.RegionID       = 0;
        item.RegionType     = "";
        item.Synchronize    = 1;
        item.ZhuanTiID      = ztId;
        item.ModifyDate     = DateTime.Now;
        item.CardID         = cardId;

        bool success = item_bll.InsertItem(item);

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

            List.EditIndex = -1;
            BindGrid();
        }
        else
        {
            Utility.Alert(this, "添加失败!");
            return;
        }
    }
Exemplo n.º 2
0
    //保存方法
    protected int SaveItem()
    {
        string   itemName    = this.ItemNameEmpIns.Text.Trim();
        string   itemType    = this.ItemTypeEmpIns.SelectedValue;
        int      catTypeId   = Convert.ToInt32(this.CatTypeEmpIns.SelectedValue);
        string   itemPrice   = this.ItemPriceEmpIns.Text.Trim();
        DateTime itemBuyDate = Convert.ToDateTime(today.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss"));
        int      cardId      = Convert.ToInt32(this.CardEmpIns.SelectedValue);

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

        if (!ValidHelper.CheckDouble(itemPrice))
        {
            Utility.Alert(this, "商品价格填写错误!");
            return(2);
        }

        Response.Cookies["CatTypeID"].Value   = catTypeId.ToString();
        Response.Cookies["CatTypeID"].Expires = DateTime.MaxValue;

        Response.Cookies["CardID"].Value   = cardId.ToString();
        Response.Cookies["CardID"].Expires = DateTime.MaxValue;

        ItemInfo item = new ItemInfo();

        item.ItemType       = itemType;
        item.ItemName       = itemName;
        item.CategoryTypeID = catTypeId;
        item.ItemPrice      = Convert.ToDecimal(itemPrice);
        item.ItemBuyDate    = itemBuyDate;
        item.UserID         = userId;
        item.ModifyDate     = DateTime.Now;
        item.Recommend      = 0;
        item.RegionID       = 0;
        item.RegionType     = "";
        item.Synchronize    = 1;
        item.CardID         = cardId;

        bool success = bll.InsertItem(item);

        if (success)
        {
            Session["TodayDate"] = itemBuyDate.ToString("yyyy-MM-dd");
            return(1);
        }
        else
        {
            return(0);
        }
    }
Exemplo n.º 3
0
        //保存方法
        private int SaveItem()
        {
            string   itemType    = this.ItemTypeHid.Value;
            int      catTypeId   = Convert.ToInt32(this.CategoryTypeDown.SelectedValue);
            string   itemName    = this.ItemName.Text.Trim();
            int      userId      = Convert.ToInt32(Session["UserID"]);
            string   itemPrice   = this.ItemPrice.Text.Trim();
            int      zhuanTiId   = Convert.ToInt32(this.ZhuanTiDown.SelectedValue);
            int      cardId      = Convert.ToInt32(this.CardDown.SelectedValue);
            int      regionId    = 0;
            string   regionType  = "";
            DateTime itemBuyDate = DateTime.Now;
            string   itemBuyTime = DateTime.Now.ToString("HH:mm:ss");
            string   remark      = this.Remark.Text.Trim();

            Response.Cookies["CatTypeID"].Value   = catTypeId.ToString();
            Response.Cookies["CatTypeID"].Expires = DateTime.MaxValue;

            Response.Cookies["CardID"].Value   = cardId.ToString();
            Response.Cookies["CardID"].Expires = DateTime.MaxValue;

            if (this.RegionID.Checked)
            {
                itemBuyDate = Convert.ToDateTime(this.ItemBuyDate1.Text.Trim() + " " + itemBuyTime);
            }
            else
            {
                itemBuyDate = Convert.ToDateTime(this.ItemBuyDateHid.Value + " " + itemBuyTime);
            }

            ItemInfo item = new ItemInfo();

            item.ItemType       = itemType;
            item.ItemName       = itemName;
            item.CategoryTypeID = catTypeId;
            item.ItemPrice      = Convert.ToDecimal(itemPrice);
            item.ItemBuyDate    = itemBuyDate;
            item.UserID         = userId;
            item.Recommend      = 0;
            item.ModifyDate     = DateTime.Now;
            item.RegionID       = regionId;
            item.RegionType     = regionType;
            item.Synchronize    = 1;
            item.ZhuanTiID      = zhuanTiId;
            item.CardID         = cardId;
            item.Remark         = remark;

            bool success = false;

            if (this.RegionID.Checked)
            {
                DateTime itemBuyDate1 = Convert.ToDateTime(this.ItemBuyDate1.Text.Trim() + " " + itemBuyTime);
                DateTime itemBuyDate2 = Convert.ToDateTime(this.ItemBuyDate2.Text.Trim() + " " + itemBuyTime);
                item.RegionType = this.RegionTypeHid.Value;

                try
                {
                    success = bll.InsertItem(item, itemBuyDate1, itemBuyDate2);
                }
                catch (Exception ex)
                {
                    Utility.Alert(this, ex.Message);
                    return(0);
                }
            }
            else
            {
                success = bll.InsertItem(item);
            }

            if (success)
            {
                Session["TodayDate"] = itemBuyDate.ToString("yyyy-MM-dd");
                return(1);
            }
            else
            {
                return(0);
            }
        }