//初始化页面产品数据
        private void InitProduct(string producId)
        {
            Products item = ProductsDAL.SelectProductByProductId(producId);

            if (item != null)
            {
                txtProductId.Text           = item.ProductId;
                txtProductName.Text         = item.ProductName;
                txtProductCategoryId.Text   = item.ProductCategoryId;
                txtProductCategoryName.Text = item.ProductCategoryName;
                txtProductCost.Text         = item.ProductCost.ToString();
                txtSalePrice.Text           = item.SalePrice.ToString();
                txtProductUnits.Text        = item.ProductUnits;
                txtCurrentstock.Text        = item.Currentstock.ToString();
                //是否库存提醒
                dwlStockNotifyStatus.Text = item.StockNotifyStatus.ToString();
                //是否发布

                txtRemarks.Text = item.Remarks;
                if (string.IsNullOrEmpty(item.ProductImgFile))
                {
                    imgProductImgFilebtn.AlternateText = "暂无图片";
                    this.imgdelbfbtn.Visible           = false;
                }
                else
                {
                    imgProductImgFilebtn.ImageUrl = "~/ProductImg/" + item.ProductId + "/" + item.ProductImgFile;
                    imgProductImgFilebtn.ToolTip  = item.ProductImgFile;
                }
            }
        }
        //将上传成功的产品图片名称更新至数据库
        private bool UpdateDbFilesName(string fileName)
        {
            string adminUserId = string.Empty;

            if (Session["LoginedAdmin"] != null)
            {
                AdUserInfo adminUserObj = (AdUserInfo)Session["LoginedAdmin"];
                adminUserId = adminUserObj.AdminUserId;
            }
            return(ProductsDAL.UpdateProductImgFiles(fileName, txtProductId.Text, adminUserId));
        }
示例#3
0
        //数据行绑定事件
        protected void gdvProduct_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //1) 文本:vnd.ms-excel.numberformat:@
            //2)日期:vnd.ms-excel.numberformat:yyyy/mm/dd
            //3)数字:vnd.ms-excel.numberformat:#,##0.00
            //4)货币:vnd.ms-excel.numberformat:¥#,##0.00
            //5)百分比:vnd.ms-excel.numberformat: #0.00%
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff';this.style.borderColor='black'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;this.style.borderColor='black'");


                e.Row.Cells[2].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
                e.Row.Cells[5].Attributes.Add("style", "vnd.ms-excel.numberformat:¥#,##0.000");
                e.Row.Cells[6].Attributes.Add("style", "vnd.ms-excel.numberformat:¥#,##0.000");
                if (e.Row.Cells[9].Text == "1")
                {
                    e.Row.Cells[9].Text      = "是";
                    e.Row.Cells[9].ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                    e.Row.Cells[9].Text      = "否 ";
                    e.Row.Cells[9].ForeColor = System.Drawing.Color.Red;
                }
                Products item = ProductsDAL.SelectProductByProductId(e.Row.Cells[2].Text);
                if (item != null)
                {
                    if (item.ProductImgFile != string.Empty)
                    {
                        LinkButton lkpimg = e.Row.FindControl("lkpimg") as LinkButton;
                        if (lkpimg != null)
                        {
                            lkpimg.Text    = "查看";
                            lkpimg.ToolTip = item.ProductImgFile;
                        }
                    }
                }
            }
        }
        //删除图片文件
        protected void imgdelbfbtn_Click(object sender, ImageClickEventArgs e)
        {
            uplblmsg.Text      = string.Empty;
            uplblmsg.ForeColor = System.Drawing.Color.Red;
            string adminUserId = string.Empty;

            if (Session["LoginedAdmin"] != null)
            {
                AdUserInfo adminUserObj = (AdUserInfo)Session["LoginedAdmin"];
                adminUserId = adminUserObj.AdminUserId;
            }
            if (ProductsDAL.UpdateProductImgFilesByDelete(txtProductId.Text, adminUserId))
            {
                uplblmsg.ForeColor = System.Drawing.Color.Green;
                uplblmsg.Text      = "删除产品图片成功!";
                //取得上传路径
                string upLoadFileOldPatch = Server.MapPath("~/ProductImg/" + txtProductId.Text);
                if (Directory.Exists(upLoadFileOldPatch))
                {
                    DirectoryInfo dir = new DirectoryInfo(upLoadFileOldPatch);
                    //删除目录及子目录和文件
                    try
                    {
                        dir.Delete(true);
                    }
                    catch (Exception)
                    {
                        uplblmsg.Text = "(删除产品图片文件失败!)";
                    }
                }
                HttpContext.Current.Response.Write("<script language='javascript'>alert('删除图片成功!');</script>");
            }
            else
            {
                lblmsg.Text = "删除产品图片失败!";
            }
        }
示例#5
0
 //查询产品分页数据方法
 protected void BindProRepeaterData()
 {
     this.RepeaterByProduct.DataSource = ProductsDAL.SelectProductByCondition(dwlProductCategory.SelectedItem.Value,
                                                                              this.AspNetPagerByProducts.PageSize, this.AspNetPagerByProducts.CurrentPageIndex);
     this.RepeaterByProduct.DataBind();
 }
示例#6
0
 //设置分页控件的总记录方法
 private void SetAspNetPagerRecordCountByPro()
 {
     this.AspNetPagerByProducts.RecordCount = ProductsDAL.SelectProductByConditionRowsCount(dwlProductCategory.SelectedItem.Value,
                                                                                            this.AspNetPagerByProducts.PageSize, this.AspNetPagerByProducts.CurrentPageIndex);
 }
        //修改
        protected void imgUpdatebtn_Click(object sender, ImageClickEventArgs e)
        {
            if (!string.IsNullOrEmpty(txtProductId.Text))
            {
                Products item = new Products();
                //修改条件  HttpContext.Current.Response.Write("<script language='javascript'>alert(' 请输入密码? ');</script>");
                item.ProductId   = txtProductId.Text;
                item.ProductName = txtProductName.Text;

                decimal result = 0;
                //成本价
                if (decimal.TryParse(txtProductCost.Text, out result))
                {
                    item.ProductCost = decimal.Parse(txtProductCost.Text);
                }
                else
                {
                    HttpContext.Current.Response.Write("<script language='javascript'>alert('产品成本价不符合要求!');</script>");
                }

                //销售价
                decimal result1 = 0;
                if (decimal.TryParse(txtSalePrice.Text, out result1))
                {
                    item.SalePrice = decimal.Parse(txtSalePrice.Text);
                }
                else
                {
                    HttpContext.Current.Response.Write("<script language='javascript'>alert('产品销售价不符合要求!');</script>");
                }

                //最低库存量
                decimal result2 = 0;
                if (decimal.TryParse(txtCurrentstock.Text, out result2))
                {
                    item.Currentstock = decimal.Parse(txtCurrentstock.Text);
                }
                else
                {
                    HttpContext.Current.Response.Write("<script language='javascript'>alert('最低库存量不符合要求!');</script>");
                }


                //是否要提醒
                item.StockNotifyStatus = int.Parse(dwlStockNotifyStatus.SelectedItem.Value);
                item.Remarks           = txtRemarks.Text;
                item.UpdateDate        = DateTime.Now;
                if (Session["LoginedAdmin"] != null)
                {
                    AdUserInfo adminUserObj = (AdUserInfo)Session["LoginedAdmin"];
                    item.Updater = adminUserObj.AdminUserId;
                }
                item.ProductUnits = txtProductUnits.Text;
                //更新产品信息
                if (ProductsDAL.UpdateProductInfo(item))
                {
                    InitProduct(item.ProductId);
                    HttpContext.Current.Response.Write("<script language='javascript'>alert('修改产品信息成功!');</script>");
                }
                else
                {
                    HttpContext.Current.Response.Write("<script language='javascript'>alert('修改产品信息失败!');</script>");
                }
            }
            else
            {
                HttpContext.Current.Response.Write("<script language='javascript'>alert('没有产品信息无法修改!');</script>");
            }
        }
示例#8
0
 //查询的方法
 private void SearchProductMethod()
 {
     this.gdvProduct.DataSource = ProductsDAL.SearchProductByCondition(this.dwlProductCategory.SelectedItem.Value);
     this.gdvProduct.DataBind();
 }