Exemplo n.º 1
0
 /// <summary>
 /// 修改菜品
 /// </summary>
 public void ModifyCookbook(CookbookInfo cbInfo)
 {
     StaticCookbookDAL.Update(cbInfo);
 }
Exemplo n.º 2
0
    private CookbookInfo getCookbookInfo(UserInfo loginedUser)
    {
        // 检查用户的输入情况
        if (string.IsNullOrEmpty(txtName.Text.Trim()))
        {
            lblError.Text = "请输入菜品名称!";
            return(null);
        }

        if (string.IsNullOrEmpty(txtPrice.Text.Trim()) || !ValidationUtility.IsDecimal(txtPrice.Text.Trim()))
        {
            lblError.Text = "请输入正确格式的价格数值!";
            return(null);
        }


        if (string.IsNullOrEmpty(txtSalePrice.Text.Trim()) || !ValidationUtility.IsDecimal(txtSalePrice.Text.Trim()))
        {
            lblError.Text = "请输入正确格式的优惠价格数值!";
            return(null);
        }

        if (string.IsNullOrEmpty(txtOrder.Text.Trim()) || !ValidationUtility.IsDecimal(txtOrder.Text.Trim()))
        {
            lblError.Text = "请输入正确格式的排序数值!";
            return(null);
        }

        var ret = new CookbookInfo
        {
            Id            = 0,
            CreatedByID   = loginedUser.ID,
            CreatedByName = loginedUser.Alias,
            CreatedDate   = DateTime.Now
        };

        // 如果是修改,则获取要修改的对象
        if (!string.IsNullOrEmpty(Request["id"]))
        {
            var cbInfo = _cookbookBLL.GetCookbook(Convert.ToInt32(Request["id"]));
            if (cbInfo == null)
            {
                return(null);
            }

            ret = cbInfo;
        }

        if (fileIcon.HasFile)
        {
            var fileExt = FileUtility.GetExtension(fileIcon.FileName);
            if (fileExt.ToLower() != ".jpg" && fileExt.ToLower() != ".png")
            {
                lblError.Text = "请输入jpg或png图片!";
                return(null);
            }

            var filePath     = FileUtility.GetNewFileName(Path.GetFileName(fileIcon.FileName));
            var filePathThum = FileUtility.GetNewFileName(filePath);

            FileUtility.FileSave(FileUtility.GetPhysicAbsoluteFullFileName(FileUtility.ConstCookbookImg, filePath),
                                 this.fileIcon.PostedFile, 60, 60,
                                 FileUtility.GetPhysicAbsoluteFullFileName(FileUtility.ConstCookbookImg, filePathThum));

            ret.Icon     = filePath;
            ret.IconThum = filePathThum;
        }

        ret.Name        = txtName.Text.Trim();
        ret.Description = txtDescription.Text.Trim();

        ret.Price     = decimal.Parse(txtPrice.Text.Trim());
        ret.SalePrice = decimal.Parse(txtSalePrice.Text.Trim());
        ret.RealPrice = ret.Price - ret.SalePrice;

        if (!loginedUser.IsSystem)
        {
            if (loginedUser.OrganizationId != null)
            {
                ret.OrganizationId = loginedUser.OrganizationId.Value;
            }
            ret.OrganizationName = loginedUser.OrganizationName;
        }

        ret.DisplayOrder = int.Parse(txtOrder.Text.Trim());

        ret.LastUpdByID   = loginedUser.ID;
        ret.LastUpdByName = loginedUser.Alias;
        ret.LastUpdDate   = DateTime.Now;

        return(ret);
    }
Exemplo n.º 3
0
 /// <summary>
 /// 添加菜品
 /// </summary>
 public void AddCookbook(CookbookInfo cbInfo)
 {
     StaticCookbookDAL.Insert(cbInfo);
 }