private void ShowInfo(string Id) { Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); Maticsoft.Model.Product model = bll.GetModel(Id); Session["Product"] = model; this.lblProductId.Text = model.ProductId.ToString(); this.txtName.Text = model.Name; txtDescn.Text = model.Descn; txtPrice.Text = model.Price.ToString(); txtvipPrice.Text = model.VipPrice.ToString(); for (int i = 0; i < this.dropCategory.Items.Count; i++) { if (this.dropCategory.Items[i].Value == model.CategoryId) { this.dropCategory.Items[i].Selected = true; } } if (model.Cheapness == 1) { radbtn_Cheap.Checked = true; } else { radbtn_CheapNo.Checked = true; } //for (int i = 0; i < this.dropBrand.Items.Count; i++) //{ // if (this.dropBrand.Items[i].Value == model.BrandId) // { // this.dropBrand.Items[i].Selected = true; // } //} }
/// <summary> /// 显示产品图片 /// </summary> private void ShowProImg() { Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); DataSet ds = bll.GetListByCategoryID(15, ""); PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = ds.Tables[0].DefaultView; objPds.AllowPaging = true; objPds.PageSize = 4; objPds.CurrentPageIndex = 0; DataList2.DataSource = objPds; DataList2.DataBind(); StringBuilder strImg = new StringBuilder(); if (ds.Tables.Count > 0) { int rowcout = ds.Tables[0].Rows.Count; if (rowcout > 0) { for (int n = 0; n < rowcout; n++) { string Name = ds.Tables[0].Rows[n]["Name"].ToString(); string Image = ds.Tables[0].Rows[n]["Image"].ToString(); strImg.Append("<IMG height=130 alt=\"" + Name + "\" src=\"ProductImages/" + Image + "\" width=150 border=0 /> "); } } } strImglist = strImg.ToString(); }
/// <summary> /// ��ʾ��ƷͼƬ /// </summary> private void ShowProImg() { Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); DataSet ds = bll.GetListByCategoryID(15,""); PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = ds.Tables[0].DefaultView; objPds.AllowPaging = true; objPds.PageSize = 4; objPds.CurrentPageIndex = 0; DataList2.DataSource = objPds; DataList2.DataBind(); StringBuilder strImg = new StringBuilder(); if (ds.Tables.Count > 0) { int rowcout=ds.Tables[0].Rows.Count; if (rowcout > 0) { for (int n = 0; n < rowcout; n++) { string Name=ds.Tables[0].Rows[n]["Name"].ToString(); string Image = ds.Tables[0].Rows[n]["Image"].ToString(); strImg.Append("<IMG height=130 alt=\"" + Name + "\" src=\"ProductImages/" + Image + "\" width=150 border=0 /> "); } } } strImglist = strImg.ToString(); }
private void ShowInfo(string Id) { Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); Maticsoft.Model.Product model = bll.GetModel(Id); //Maticsoft.BLL.Products.Brand bllb = new Maticsoft.BLL.Products.Brand(); Maticsoft.BLL.Products.Category bllc = new Maticsoft.BLL.Products.Category(); this.lblProductId.Text = model.ProductId.ToString(); this.lblName.Text = model.Name; lblDescn.Text = model.Descn; lblPrice.Text = model.Price.ToString(); lblvipprice.Text = model.VipPrice.ToString(); lblImage.Text = model.Image; //lblBrandId.Text = bllb.GetName(model.BrandId); lblCategoryId.Text = bllc.GetName(model.CategoryId); if (model.Cheapness == 1) { Label1.Text = "ÊÇ"; } else { Label1.Text = "·ñ"; } }
protected void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { //if (gridView.Rows.Count <= 1) //{ // e.Cancel = true; //} string ProductId = gridView.DataKeys[e.RowIndex].Value.ToString(); Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); bll.Delete(ProductId); BindData(); }
private void ShowNews(string productID)//显示新闻 { Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); Maticsoft.Model.Product model = bll.GetModelByCache(productID); this.lblProductId.Text = model.ProductId.ToString(); this.lblName.Text = model.Name; lblDescn.Text = model.Descn; lblPrice.Text = model.Price.ToString(); lblvipprice.Text = model.VipPrice.ToString(); Image1.ImageUrl = "ProductImages/" + model.Image; Maticsoft.BLL.Products.Category bllc = new Maticsoft.BLL.Products.Category(); lblCategoryId.Text = bllc.GetName(model.CategoryId); if (model.Cheapness == 1) { Label1.Text = "是"; } else { Label1.Text = "否"; } }
//��ʾ���� private void ShowNews(string productID) { Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); Maticsoft.Model.Product model = bll.GetModelByCache(productID); this.lblProductId.Text = model.ProductId.ToString(); this.lblName.Text = model.Name; lblDescn.Text = model.Descn; lblPrice.Text = model.Price.ToString(); lblvipprice.Text = model.VipPrice.ToString(); Image1.ImageUrl = "ProductImages/" + model.Image; Maticsoft.BLL.Products.Category bllc = new Maticsoft.BLL.Products.Category(); lblCategoryId.Text = bllc.GetName(model.CategoryId); if (model.Cheapness == 1) { Label1.Text = "��"; } else { Label1.Text = "��"; } }
protected void btnAdd_Click(object sender, EventArgs e) { Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); string ProductId = this.lblProductId.Text; string BrandId = this.dropBrand.SelectedValue; string CategoryId = this.dropCategory.SelectedValue; string Name = this.txtName.Text; string Descn = this.txtDescn.Text; string Price = this.txtPrice.Text; string vipPrice = this.txtvipPrice.Text; Maticsoft.Model.Product model = (Maticsoft.Model.Product)Session["Product"]; model.ProductId = ProductId; model.BrandId = BrandId; model.CategoryId = CategoryId; model.Name = Name; model.Descn = Descn; if (Price != "") { model.Price = decimal.Parse(Price); } if (vipPrice != "") { model.VipPrice = decimal.Parse(vipPrice); } if (radbtn_Cheap.Checked) { model.Cheapness = 1; } #region �ϴ�����ͼ�ļ� //if (this.FileUpSmall.PostedFile != null) //{ // string strErr = ""; // int size = this.FileUpSmall.PostedFile.ContentLength;//��С // if (size >1) // { // if (size > 1024000) // { // strErr += "�Բ����ļ���С���ܴ���1M��\\n"; // } // if (strErr != "") // { // LTP.Common.MessageBox.Show(this, strErr); // return; // } // string UploadFileType1 = this.FileUpSmall.PostedFile.ContentType; // string UploadFilePath1 = this.FileUpSmall.PostedFile.FileName; // int start1 = UploadFilePath1.LastIndexOf("\\"); // string filename1 = UploadFilePath1.Substring(start1 + 1); // filename1 = DateTime.Now.ToString("yyyyMMddHHmmss") + "Small" + filename1; // model.ImageSmall = filename1; // Stream StreamObject1 = this.FileUpSmall.PostedFile.InputStream;//�������������� // switch (UploadFileType1) // { // case "image/gif": // case "image/bmp": // case "image/pjpeg": // { // System.Drawing.Image myImage = System.Drawing.Image.FromStream(StreamObject1); // int w = myImage.Width; // int h = myImage.Height; // } // break; // case "application/x-shockwave-flash": // break; // case "video/x-ms-wmv": // case "video/mpeg": // case "video/x-ms-asf": // case "video/avi": // case "audio/mpeg": // case "audio/mid": // case "audio/wav": // case "audio/x-ms-wma": // break; // default: // strErr += "�Բ��𣬲�������ļ���ʽ�ϴ���\\n"; // break; // } // string path1 = ProductImageFolder + filename1; // path1 = Server.MapPath(path1); // try // { // this.FileUpSmall.PostedFile.SaveAs(path1); //��������ע��UploadFileĿ¼�ķ���Ȩ�� // } // catch (System.Exception ex) // { // Response.Write("��ȷ��" + ProductImageFolder + "Ŀ¼����д��Ȩ�ޡ�" + ex.Message); // return; // } // } //} #endregion #region �ϴ�ͼƬ�ļ� if (this.FileUp.PostedFile != null) { string strErr = ""; int size1 = this.FileUp.PostedFile.ContentLength;//��С if (size1 > 1) { if (size1 > 1024000) { strErr += "�Բ����ļ���С���ܴ���1M��\\n"; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } string UploadFileType = this.FileUp.PostedFile.ContentType; string UploadFilePath = this.FileUp.PostedFile.FileName; int start = UploadFilePath.LastIndexOf("\\"); string filename = UploadFilePath.Substring(start + 1); filename = DateTime.Now.ToString("yyyyMMddHHmmss") + filename; model.Image = filename; Stream StreamObject = this.FileUp.PostedFile.InputStream;//�������������� switch (UploadFileType) { case "image/gif": case "image/bmp": case "image/pjpeg": { System.Drawing.Image myImage = System.Drawing.Image.FromStream(StreamObject); int w = myImage.Width; int h = myImage.Height; } break; case "application/x-shockwave-flash": break; case "video/x-ms-wmv": case "video/mpeg": case "video/x-ms-asf": case "video/avi": case "audio/mpeg": case "audio/mid": case "audio/wav": case "audio/x-ms-wma": break; default: strErr += "�Բ��𣬲�������ļ���ʽ�ϴ���\\n"; break; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } string path = ProductImageFolder + filename; path = Server.MapPath(path); try { this.FileUp.PostedFile.SaveAs(path); //��������ע��UploadFileĿ¼�ķ���Ȩ�� } catch //(System.Exception ex) { Response.Write("��ȷ��" + ProductImageFolder + "Ŀ¼����д��Ȩ�ޡ�"); return; } } } #endregion bll.Update(model); Response.Redirect("index.aspx"); }
//所有商品 public void BindData(string BrandId, string CategoryId, string Page) { Maticsoft.BLL.Products.Product bllp = new Maticsoft.BLL.Products.Product(); DataSet ds = new DataSet(); if ((CategoryId != "") || (BrandId != "")) { ds = bllp.GetListByCategoryID(9, CategoryId, BrandId); } else { ds = bllp.GetAllList(); } PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = ds.Tables[0].DefaultView; int record_Count = ds.Tables[0].Rows.Count; int page_Size = 9; int totalPages = int.Parse(Math.Ceiling((double)record_Count / page_Size).ToString()); int CurPage; if (Page != "") { CurPage = Convert.ToInt32(Page); } else { CurPage = 1; } objPds.AllowPaging = true; objPds.PageSize = page_Size; objPds.CurrentPageIndex = CurPage - 1; if (!objPds.IsFirstPage) { this.lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=1"; lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + Convert.ToString(CurPage - 1); } if (!objPds.IsLastPage) { lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + Convert.ToString(CurPage + 1); this.lnkLast.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + totalPages.ToString(); } MyList.DataSource = objPds; MyList.DataBind(); //显示数量 if (objPds.CurrentPageIndex == 0) { lnkFirst.Enabled = false; lnkPrev.Enabled = false; if (totalPages == 1) { lnkLast.Enabled = false; lnkNext.Enabled = false; } } else if (objPds.CurrentPageIndex == totalPages - 1) { lnkLast.Enabled = false; lnkNext.Enabled = false; } this.lblpagesum.Text = totalPages.ToString(); this.lblCurrentPage.Text = CurPage.ToString(); this.lblrowscount.Text = record_Count.ToString(); }
//������Ʒ public void BindData(string BrandId, string CategoryId, string Page) { Maticsoft.BLL.Products.Product bllp = new Maticsoft.BLL.Products.Product(); DataSet ds = new DataSet(); if ((CategoryId != "") || (BrandId!="")) { ds = bllp.GetListByCategoryID(9,CategoryId, BrandId); } else { ds = bllp.GetAllList(); } PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = ds.Tables[0].DefaultView; int record_Count = ds.Tables[0].Rows.Count; int page_Size = 9; int totalPages = int.Parse(Math.Ceiling((double)record_Count / page_Size).ToString()); int CurPage; if (Page != "") CurPage = Convert.ToInt32(Page); else CurPage = 1; objPds.AllowPaging = true; objPds.PageSize = page_Size; objPds.CurrentPageIndex = CurPage - 1; if (!objPds.IsFirstPage) { this.lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=1"; lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + Convert.ToString(CurPage - 1); } if (!objPds.IsLastPage) { lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + Convert.ToString(CurPage + 1); this.lnkLast.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + totalPages.ToString(); } MyList.DataSource = objPds; MyList.DataBind(); //��ʾ���� if (objPds.CurrentPageIndex == 0) { lnkFirst.Enabled = false; lnkPrev.Enabled = false; if (totalPages == 1) { lnkLast.Enabled = false; lnkNext.Enabled = false; } } else if (objPds.CurrentPageIndex == totalPages - 1) { lnkLast.Enabled = false; lnkNext.Enabled = false; } this.lblpagesum.Text = totalPages.ToString(); this.lblCurrentPage.Text = CurPage.ToString(); this.lblrowscount.Text = record_Count.ToString(); }
protected void btnAdd_Click(object sender, EventArgs e) { Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); string ProductId = this.txtProductId.Text; string BrandId = this.dropBrand.SelectedValue; string CategoryId = this.dropCategory.SelectedValue; string Name = this.txtName.Text; string Descn = this.txtDescn.Text; string Price = this.txtPrice.Text; string vipPrice = this.txtvipPrice.Text; if (bll.Exists(ProductId)) { lblMsg.Visible = true; lblMsg.Text = "编号已经存在!"; return; } Maticsoft.Model.Product model = new Maticsoft.Model.Product(); model.ProductId = ProductId; model.BrandId = BrandId; model.CategoryId = CategoryId; model.Name = Name; model.Descn = Descn; if (Price != "") { model.Price = decimal.Parse(Price); } if (vipPrice != "") { model.VipPrice = decimal.Parse(vipPrice); } if (radbtn_Cheap.Checked) { model.Cheapness = 1; } #region 缩略图文件 //if (this.FileUpSmall.PostedFile != null) //{ // string strErr = ""; // int size = this.FileUpSmall.PostedFile.ContentLength;//大小 // if (size >1) // { // if (size > 1024000) // { // strErr += "对不起,文件大小不能大于1M!\\n"; // } // if (strErr != "") // { // LTP.Common.MessageBox.Show(this, strErr); // return; // } // string UploadFileType1 = this.FileUpSmall.PostedFile.ContentType; // string UploadFilePath1 = this.FileUpSmall.PostedFile.FileName; // int start1 = UploadFilePath1.LastIndexOf("\\"); // string filename1 = UploadFilePath1.Substring(start1 + 1); // filename1 = DateTime.Now.ToString("yyyyMMddHHmmss") + "Small" + filename1; // model.ImageSmall = filename1; // Stream StreamObject1 = this.FileUpSmall.PostedFile.InputStream;//建立数据流对像 // switch (UploadFileType1) // { // case "image/gif": // case "image/bmp": // case "image/pjpeg": // { // System.Drawing.Image myImage = System.Drawing.Image.FromStream(StreamObject1); // int w = myImage.Width; // int h = myImage.Height; // } // break; // case "application/x-shockwave-flash": // break; // case "video/x-ms-wmv": // case "video/mpeg": // case "video/x-ms-asf": // case "video/avi": // case "audio/mpeg": // case "audio/mid": // case "audio/wav": // case "audio/x-ms-wma": // break; // default: // strErr += "对不起,不允许该文件格式上传!\\n"; // break; // } // string path1 = ProductImageFolder + filename1; // path1 = Server.MapPath(path1); // try // { // this.FileUpSmall.PostedFile.SaveAs(path1); //如果抱错,注意UploadFile目录的访问权限 // } // catch (System.Exception ex) // { // Response.Write("请确保" + ProductImageFolder + "目录具有写的权限。" + ex.Message); // return; // } // } //} #endregion #region 图片文件 if (this.FileUp.PostedFile != null) { string strErr = ""; int size1 = this.FileUp.PostedFile.ContentLength;//大小 if (size1 > 1) { if (size1 > 1024000) { strErr += "对不起,文件大小不能大于1M!\\n"; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } string UploadFileType = this.FileUp.PostedFile.ContentType; string UploadFilePath = this.FileUp.PostedFile.FileName; int start = UploadFilePath.LastIndexOf("\\"); string filename = UploadFilePath.Substring(start + 1); filename = DateTime.Now.ToString("yyyyMMddHHmmss") + filename; model.Image = filename; Stream StreamObject = this.FileUp.PostedFile.InputStream;//建立数据流对像 switch (UploadFileType) { case "image/gif": case "image/bmp": case "image/pjpeg": { System.Drawing.Image myImage = System.Drawing.Image.FromStream(StreamObject); int w = myImage.Width; int h = myImage.Height; } break; case "application/x-shockwave-flash": break; case "video/x-ms-wmv": case "video/mpeg": case "video/x-ms-asf": case "video/avi": case "audio/mpeg": case "audio/mid": case "audio/wav": case "audio/x-ms-wma": break; default: strErr += "对不起,不允许该文件格式上传!\\n"; break; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } string path = ProductImageFolder + filename; path = Server.MapPath(path); try { this.FileUp.PostedFile.SaveAs(path); //如果抱错,注意UploadFile目录的访问权限 } catch //(System.Exception ex) { Response.Write("请确保" + ProductImageFolder + "目录具有写的权限。"); return; } } } #endregion bll.Add(model); if (chkAddContinue.Checked) { Response.Redirect("Add.aspx"); } else { Response.Redirect("index.aspx"); } }
private void BindData() { #region 权限检查 if (!Context.User.Identity.IsAuthenticated) { return; } AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name); if (user.HasPermissionID(PermId_Modify)) { gridView.Columns[5].Visible = true; } if (user.HasPermissionID(PermId_Delete)) { gridView.Columns[6].Visible = true; } #endregion Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); string strWhere = ""; if (Session["strWhereProduct"] != null && Session["strWhereProduct"].ToString() != "") { strWhere += Session["strWhereProduct"].ToString(); } DataSet ds = new DataSet(); ds = bll.GetList(strWhere); DataView dv = ds.Tables[0].DefaultView; gridView.DataSource = dv; gridView.DataBind(); //分页 int rows_Count = ds.Tables[0].Rows.Count; int page_Size = gridView.PageSize; int page_Count = gridView.PageCount; int page_Current = gridView.PageIndex + 1; lblRowsCount.Text = rows_Count.ToString(); lblPageCount.Text = page_Count.ToString(); lblCurrentPage.Text = page_Current.ToString(); #region 显示页导航 btnFirst.Enabled = true; btnPrev.Enabled = true; btnNext.Enabled = true; btnLast.Enabled = true; if (gridView.PageIndex == 0) { btnFirst.Enabled = false; btnPrev.Enabled = false; if (gridView.PageCount == 1) { btnLast.Enabled = false; btnNext.Enabled = false; } } else if (gridView.PageIndex == gridView.PageCount - 1) { btnLast.Enabled = false; btnNext.Enabled = false; } #endregion }
protected void btnAdd_Click(object sender, EventArgs e) { Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); string ProductId = this.txtProductId.Text; string BrandId = this.dropBrand.SelectedValue; string CategoryId = this.dropCategory.SelectedValue; string Name = this.txtName.Text; string Descn = this.txtDescn.Text; string Price = this.txtPrice.Text; string vipPrice = this.txtvipPrice.Text; if (bll.Exists(ProductId)) { lblMsg.Visible = true; lblMsg.Text = "编号已经存在!"; return; } Maticsoft.Model.Product model = new Maticsoft.Model.Product(); model.ProductId = ProductId; model.BrandId = BrandId; model.CategoryId = CategoryId; model.Name = Name; model.Descn = Descn; if (Price != "") { model.Price = decimal.Parse(Price); } if (vipPrice != "") { model.VipPrice = decimal.Parse(vipPrice); } if (radbtn_Cheap.Checked) { model.Cheapness = 1; } #region 上传缩略图文件 //if (this.FileUpSmall.PostedFile != null) //{ // string strErr = ""; // int size = this.FileUpSmall.PostedFile.ContentLength;//大小 // if (size >1) // { // if (size > 1024000) // { // strErr += "对不起,文件大小不能大于1M!\\n"; // } // if (strErr != "") // { // LTP.Common.MessageBox.Show(this, strErr); // return; // } // string UploadFileType1 = this.FileUpSmall.PostedFile.ContentType; // string UploadFilePath1 = this.FileUpSmall.PostedFile.FileName; // int start1 = UploadFilePath1.LastIndexOf("\\"); // string filename1 = UploadFilePath1.Substring(start1 + 1); // filename1 = DateTime.Now.ToString("yyyyMMddHHmmss") + "Small" + filename1; // model.ImageSmall = filename1; // Stream StreamObject1 = this.FileUpSmall.PostedFile.InputStream;//建立数据流对像 // switch (UploadFileType1) // { // case "image/gif": // case "image/bmp": // case "image/pjpeg": // { // System.Drawing.Image myImage = System.Drawing.Image.FromStream(StreamObject1); // int w = myImage.Width; // int h = myImage.Height; // } // break; // case "application/x-shockwave-flash": // break; // case "video/x-ms-wmv": // case "video/mpeg": // case "video/x-ms-asf": // case "video/avi": // case "audio/mpeg": // case "audio/mid": // case "audio/wav": // case "audio/x-ms-wma": // break; // default: // strErr += "对不起,不允许该文件格式上传!\\n"; // break; // } // string path1 = ProductImageFolder + filename1; // path1 = Server.MapPath(path1); // try // { // this.FileUpSmall.PostedFile.SaveAs(path1); //如果抱错,注意UploadFile目录的访问权限 // } // catch (System.Exception ex) // { // Response.Write("请确保" + ProductImageFolder + "目录具有写的权限。" + ex.Message); // return; // } // } //} #endregion #region 上传图片文件 if (this.FileUp.PostedFile != null) { string strErr = ""; int size1 = this.FileUp.PostedFile.ContentLength;//大小 if (size1 > 1) { if (size1 > 1024000) { strErr += "对不起,文件大小不能大于1M!\\n"; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } string UploadFileType = this.FileUp.PostedFile.ContentType; string UploadFilePath = this.FileUp.PostedFile.FileName; int start = UploadFilePath.LastIndexOf("\\"); string filename = UploadFilePath.Substring(start + 1); filename = DateTime.Now.ToString("yyyyMMddHHmmss") + filename; model.Image = filename; Stream StreamObject = this.FileUp.PostedFile.InputStream;//建立数据流对像 switch (UploadFileType) { case "image/gif": case "image/bmp": case "image/pjpeg": { System.Drawing.Image myImage = System.Drawing.Image.FromStream(StreamObject); int w = myImage.Width; int h = myImage.Height; } break; case "application/x-shockwave-flash": break; case "video/x-ms-wmv": case "video/mpeg": case "video/x-ms-asf": case "video/avi": case "audio/mpeg": case "audio/mid": case "audio/wav": case "audio/x-ms-wma": break; default: strErr += "对不起,不允许该文件格式上传!\\n"; break; } if (strErr != "") { LTP.Common.MessageBox.Show(this, strErr); return; } string path = ProductImageFolder + filename; path = Server.MapPath(path); try { this.FileUp.PostedFile.SaveAs(path); //如果抱错,注意UploadFile目录的访问权限 } catch //(System.Exception ex) { Response.Write("请确保" + ProductImageFolder + "目录具有写的权限。"); return; } } } #endregion bll.Add(model); if (chkAddContinue.Checked) { Response.Redirect("Add.aspx"); } else { Response.Redirect("index.aspx"); } }
private void BindData() { #region Ȩ��� if (!Context.User.Identity.IsAuthenticated) { return; } AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name); if (user.HasPermissionID(PermId_Modify)) { gridView.Columns[5].Visible = true; } if (user.HasPermissionID(PermId_Delete)) { gridView.Columns[6].Visible = true; } #endregion Maticsoft.BLL.Products.Product bll = new Maticsoft.BLL.Products.Product(); string strWhere = ""; if (Session["strWhereProduct"] != null && Session["strWhereProduct"].ToString() != "") { strWhere += Session["strWhereProduct"].ToString(); } DataSet ds = new DataSet(); ds = bll.GetList(strWhere); DataView dv = ds.Tables[0].DefaultView; gridView.DataSource = dv; gridView.DataBind(); //��ҳ int rows_Count = ds.Tables[0].Rows.Count; int page_Size = gridView.PageSize; int page_Count = gridView.PageCount; int page_Current = gridView.PageIndex + 1; lblRowsCount.Text = rows_Count.ToString(); lblPageCount.Text = page_Count.ToString(); lblCurrentPage.Text = page_Current.ToString(); #region ��ʾҳ���� btnFirst.Enabled = true; btnPrev.Enabled = true; btnNext.Enabled = true; btnLast.Enabled = true; if (gridView.PageIndex == 0) { btnFirst.Enabled = false; btnPrev.Enabled = false; if (gridView.PageCount == 1) { btnLast.Enabled = false; btnNext.Enabled = false; } } else if (gridView.PageIndex == gridView.PageCount - 1) { btnLast.Enabled = false; btnNext.Enabled = false; } #endregion }