protected void Button1_Click(object sender, EventArgs e) { DBLL.clsProduct clProduct = new DBLL.clsProduct(); DBLL.OptionSysDBLL option = new DBLL.OptionSysDBLL(); //bool _Result = clProduct.update_tb_ProductBynProductID(int.Parse(hfID.Value), ddlProductCateTreelist21.nSelectProductCategoryID, cbbHot.Checked, "", txtsProductNameCN.Text, txtsProductNameEN.Text, CKEditorControl3.Text, CKEditorControl4.Text, CKEditorControl1.Text, CKEditorControl2.Text, Session["user"].ToString(), DateTime.Now, true, int.Parse(txtnSorting.Text), "", txtsEnsitivityCN.Text, txtsEnsitivityEN.Text, txtsChannelBalanceCN.Text, txtsChannelBalanceEN.Text, txtsImpedanceCN.Text, txtsImpedanceEN.Text, txtsFrequencyCN.Text, txtsFrequencyEN.Text, txtsRatedPowerCN.Text, txtsRatedPowerEN.Text, txtsMaximumPowerCN.Text, txtsMaximumPowerEN.Text, txtsBrandNameCN.Text, txtsBrandNameEN.Text); bool _Result = clProduct.update_tb_ProductBynProductID(int.Parse(hfID.Value), ddlProductCateTreelist21.nSelectProductCategoryID, cbbHot.Checked, "", txtsProductNameCN.Text, txtsProductNameEN.Text, CKEditorControl3.Text, CKEditorControl4.Text, CKEditorControl1.Text, CKEditorControl2.Text, Session["user"].ToString(), DateTime.Now, true, int.Parse(txtnSorting.Text), "", "", "", "", "", "", "", "", "", "", "", "", "", txtsBrandNameCN.Text, txtsBrandNameEN.Text); if (_Result) { string sSaveFolderFullPath = Server.MapPath(Image3.ImageUrl); if (File.Exists(sSaveFolderFullPath)) { //如果存在则删除 File.Delete(sSaveFolderFullPath); System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(sSaveFolderFullPath.Substring(0, sSaveFolderFullPath.LastIndexOf("\\")).ToString()); System.IO.FileInfo[] dirs = dir.GetFiles(); if (dirs.Length > 0) { //有子文件夹 } else { Directory.Delete(sSaveFolderFullPath.Substring(0, sSaveFolderFullPath.LastIndexOf("\\")).ToString()); } } lblsImagePath.Visible = true; MutileUploaderUserControl31.Visible = true; Label2.Visible = false; Button1.Visible = false; Image3.Visible = false; Image3.ImageUrl = ""; Image4.ImageUrl = ""; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { OnSetLanguage(); DBLL.OptionSysDBLL sys = new DBLL.OptionSysDBLL(); DBLL.DBcommon dbcom = new DBLL.DBcommon(); DBLL.clsProduct clspro = new DBLL.clsProduct(); DataTable dtProduct = clspro.Select_tb_ProductBybHot(true); DataList1.DataSource = dtProduct; DataList1.DataBind(); if (Session["languageGlobal"] == "en") { DataTable dtNews = dbcom.GetDataTable("select top 5 * from tb_News where bEnable=1 and nLangType=1 order by nSorting desc,dCreatedTime desc"); GridView1.DataSource = dtNews; GridView1.DataBind(); } else { DataTable dtNews = dbcom.GetDataTable("select top 5 * from tb_News where bEnable=1 and nLangType=0 order by nSorting desc,dCreatedTime desc"); GridView1.DataSource = dtNews; GridView1.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int nID = 0; if (Request.QueryString["nID"] != null && int.TryParse(Request.QueryString["nID"].ToString(), out nID) && nID > 0) { lblBigtitle.Text = "编辑数据"; BtnAdd.Visible = false; btnUpdate.Visible = false; DBLL.clsProduct clsp = new DBLL.clsProduct(); DataTable dt = clsp.Select_tb_ProductBynProductID(nID); if (dt != null && dt.Rows.Count > 0) { hfID.Value = dt.Rows[0]["nProductID"].ToString(); txtsGroupName.Text = dt.Rows[0]["nProductID"].ToString(); //绑定数据 } } else { lblBigtitle.Text = "添加数据"; btnUpdate.Visible = false; BtnAdd.Visible = true; } } }
protected void btnSearch_Click(object sender, EventArgs e) { string sSearch = txtSearch.Text; DBLL.clsProduct clspdc = new DBLL.clsProduct(); DataTable dtpdc = new DataTable(); if (ddlProductCateTreelist1.nSelectProductCategoryID > 0) { dtpdc = clspdc.Select_tb_ProductBynParentCategoryID(ddlProductCateTreelist1.nSelectProductCategoryID); } else dtpdc = clspdc.sp_selectNormalTableOfAllByProduct(false); if (dtpdc != null && dtpdc.Rows.Count > 0) { Model.dsProduct.tb_ProductDataTable dtSearchpdc = new Model.dsProduct.tb_ProductDataTable(); string cmd = "sProductNameCN like '%" + sSearch + "%' "; cmd += " or "; cmd += "sProductNameEN like '%" + sSearch + "%' "; cmd += " or "; cmd += "sSummaryCN like '%" + sSearch + "%' "; cmd += " or "; cmd += "sSummaryEN like '%" + sSearch + "%' "; DataRow[] rows = dtpdc.Select(cmd); foreach (DataRow row in rows) { Model.dsProduct.tb_ProductRow Searchrow = dtSearchpdc.Newtb_ProductRow(); foreach (DataColumn col in dtpdc.Columns) { Searchrow[col.ColumnName] = row[col.ColumnName]; } dtSearchpdc.Rows.Add(Searchrow); } ProductList = new Model.dsProduct.tb_ProductDataTable(); ProductList.Merge(dtSearchpdc); lvProductList.DataSource = dtSearchpdc; lvProductList.DataBind(); } //////old //DBLL.clsProduct clspdc = new DBLL.clsProduct(); //DataTable dtpdc = new DataTable(); //if (ddlProductCateTreelist1.nSelectProductCategoryID > 0) //{ // dtpdc = clspdc.Select_tb_ProductBynProductCategoryID(ddlProductCateTreelist1.nSelectProductCategoryID); // if (dtpdc != null) // { // ProductList.Clear(); // ProductList.Merge(dtpdc); // lvProductList.DataSource = ProductList; // lvProductList.DataBind(); // } // else // { // lvProductList.DataSource = null; // lvProductList.DataBind(); // } //} }
protected void btnSearch_Click(object sender, EventArgs e) { string sSearch = txtSearch.Text; DBLL.clsProduct clspdc = new DBLL.clsProduct(); DBLL.DBcommon DBc = new DBLL.DBcommon(); DataTable dtpdc = new DataTable(); if (ddlProductCateTreelist21.nSelectProductCategoryID > 0) { dtpdc = clspdc.Select_tb_ProductBynParentCategoryID(ddlProductCateTreelist21.nSelectProductCategoryID); } else { dtpdc = DBc.selectNormalTableofAll(false, "tb_Product"); } if (dtpdc != null && dtpdc.Rows.Count > 0) { DataTable dtSearchpdc = new DataTable(); string cmd = "sProductNameCN like '%" + sSearch + "%' "; cmd += " or "; cmd += "sProductNameEN like '%" + sSearch + "%' "; //cmd += "sSummaryCN like '%" + sSearch + "%' "; //cmd += " or "; //cmd += "sSummaryEN like '%" + sSearch + "%' "; DataRow[] rows = dtpdc.Select(cmd); foreach (DataColumn col in dtpdc.Columns) { dtSearchpdc.Columns.Add(col.ColumnName.ToString()); } foreach (DataRow row in rows) { dtSearchpdc.Rows.Add(row.ItemArray); } //ProductList = new Model.dsProduct.tb_ProductDataTable(); //ProductList.Merge(dtSearchpdc); lvProduct.DataSource = dtSearchpdc; lvProduct.DataBind(); } //else //{ //dtpdc = DBc.selectNormalTableofAll(false, "tb_Product"); //if (dtpdc != null && dtpdc.Rows.Count > 0) //{ //lvProduct.DataSource = null; //lvProduct.DataBind(); //} //} }
public void Bind(int nProductID) { DBLL.clsProduct clspro = new DBLL.clsProduct(); DBLL.clsProductCategory clsprocate = new DBLL.clsProductCategory(); DataTable dtpro = clspro.Select_tb_ProductBynProductID(nProductID); if (dtpro != null && dtpro.Rows.Count > 0) { Panel1.Visible = false; Panel2.Visible = true; DataRow dtprorow = dtpro.Rows[0]; DataTable dtprocate = clsprocate.Select_tb_ProductCategoryBynProductCategoryID(int.Parse(dtprorow["nProductCategoryID"].ToString())); if (Session["languageGlobal"] == "en") { lblProductName.Text = dtprorow["sProductNameEN"].ToString(); lblProductCate.Text = dtprocate.Rows[0]["sProductCategoryNameEN"].ToString(); lblsBrandName.Text = dtprorow["sBrandNameEN"].ToString(); divProductInfo.InnerHtml = dtprorow["sIntroEN"].ToString(); divProductCate.InnerHtml = dtprorow["sSummaryEN"].ToString(); IMGbig.ImageUrl = dtprorow["sPImagePath"].ToString(); //lblSensitivity.Text = dtprorow["sEnsitivityCN"].ToString(); //lblchannelbalance.Text = dtprorow["sChannelBalanceCN"].ToString(); //lblimpedance.Text = dtprorow["sImpedanceCN"].ToString(); //lblfrequencyrange.Text = dtprorow["sFrequencyCN"].ToString(); //lblratedpower.Text = dtprorow["sRatedPowerCN"].ToString(); //lblmaximumpower.Text = dtprorow["sMaximumPowerCN"].ToString(); } else { lblProductName.Text = dtprorow["sProductNameCN"].ToString(); lblProductCate.Text = dtprocate.Rows[0]["sProductCategoryNameCN"].ToString(); lblsBrandName.Text = dtprorow["sBrandNameCN"].ToString(); divProductInfo.InnerHtml = dtprorow["sIntroCN"].ToString(); divProductCate.InnerHtml = dtprorow["sSummaryCN"].ToString(); IMGbig.ImageUrl = dtprorow["sPImagePath"].ToString(); //lblSensitivity.Text = dtprorow["sEnsitivityEN"].ToString(); //lblchannelbalance.Text = dtprorow["sChannelBalanceEN"].ToString(); //lblimpedance.Text = dtprorow["sImpedanceEN"].ToString(); //lblfrequencyrange.Text = dtprorow["sFrequencyEN"].ToString(); //lblratedpower.Text = dtprorow["sRatedPowerEN"].ToString(); //lblmaximumpower.Text = dtprorow["sMaximumPowerEN"].ToString(); } } }
//protected void lvContactList_ItemDeleting(object sender, ListViewDeleteEventArgs e) //{ // DBLL.DBcommon dbcom = new DBLL.DBcommon(); // Label lblnID = (Label)lvContactList.Items[e.ItemIndex].FindControl("lblnLinkID"); // int _nID = 0; // if (int.TryParse(lblnID.Text.Trim(), out _nID) && _nID > 0) // { // hfContactUpdateID.Value = _nID.ToString(); // } // dbcom.sp_DeleteNormalTableByID(int.Parse(hfContactUpdateID.Value), "tb_Link"); // ReBindPageList(); //} protected void lvInquiryList_SelectedIndexChanging(object sender, ListViewSelectEventArgs e) { Label lblnID = (Label)lvInquiryList.Items[e.NewSelectedIndex].FindControl("lblnInquiryID"); int _nID = 0; DBLL.clsInquiry Inquiry = new DBLL.clsInquiry(); DBLL.clsProduct Product = new DBLL.clsProduct(); //ArrayList ProductList = new ArrayList(); if (int.TryParse(lblnID.Text.Trim(), out _nID) && _nID > 0) { MultiView1.ActiveViewIndex = 1; DataTable dt = Inquiry.Select_tb_InquiryBynInquiryID(_nID); txtsFirstName.Text = dt.Rows[0]["sFirstName"].ToString(); if (dt.Rows[0]["nSex"].ToString() == "1") { txtnSex.Text = "男"; } else { txtnSex.Text = "女"; } txtsSubject.Text = dt.Rows[0]["sSubject"].ToString(); txtsEmail.Text = dt.Rows[0]["sEmail"].ToString(); txtsCountry.Text = dt.Rows[0]["sCountry"].ToString(); if (dt.Rows[0]["sProductIDList"].ToString() != "") { string ProductL = ""; string[] ProductList = dt.Rows[0]["sProductIDList"].ToString().Split(','); for (int i = 0; i < ProductList.Length; i++) { DataTable Productdt = Product.Select_tb_ProductBynProductID(int.Parse(ProductList[i].ToString())); if (Productdt.Rows.Count > 0) { ProductL = ProductL + Productdt.Rows[0]["sProductNameCN"].ToString() + ","; } } txtsProductIDList.Text = ProductL.Substring(0, ProductL.Length - 1); } hfInquiryUpdateID.Value = _nID.ToString(); } }
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) { //for (int i = 0; i < this.TreeView1.Nodes.Count; i++) //{//跌迭根节点 // if (this.TreeView1.SelectedNode.Parent == null) // { // if (this.TreeView1.SelectedValue == this.TreeView1.Nodes[i].Value) // {//如果选中的是根节点,就展开 // this.TreeView1.SelectedNode.Expanded = true; // } // else // {//如果选中的不是根节点 // this.TreeView1.Nodes[i].NavigateUrl = ""; // this.TreeView1.Nodes[i].Expanded = false; // } // } //} int _nProID = 0; if (int.TryParse(this.TreeView1.SelectedValue, out _nProID) && _nProID > 0) { Panel1.Visible = true; Panel2.Visible = false; DBLL.clsProduct pro = new DBLL.clsProduct(); DataTable dtProduct = pro.Select_tb_ProductBynParentCategoryID(_nProID); if (dtProduct != null) { DataTableProduct = dtProduct; } else { DataTableProduct = new DataTable(); } BindProductData(DataTableProduct); } // TreeView1.SelectedNode.NavigateUrl = "Product.aspx?nSelelctProductCateID=" + TreeView1.SelectedNode.Value; }
public void ReBindPageList() { DBLL.clsProduct Product = new DBLL.clsProduct(); DataTable dt = new DataTable(); dt = Product.sp_selectNormalTableOfAllByProduct(false); if (dt != null) { ProductList.Merge(dt); lvProductList.DataSource = ProductList; lvProductList.DataBind(); } else { lvProductList.DataSource = null; lvProductList.DataBind(); } DBLL.DBcommon dbcom = new DBLL.DBcommon(); Model.dsProduct.tb_ProductCategoryDataTable ProductCategoryList = new Model.dsProduct.tb_ProductCategoryDataTable(); ProductCategoryList.Merge(dbcom.selectNormalTableofAll(false, "tb_ProductCategory")); ddlProductCateTreelist1.ProductList = ProductCategoryList; }
protected void lvProduct_ItemDeleting(object sender, ListViewDeleteEventArgs e) { DBLL.DBcommon dbcom = new DBLL.DBcommon(); DBLL.clsPartners clPartners = new DBLL.clsPartners(); DBLL.clsProduct clProduct = new DBLL.clsProduct(); Label lblnID = (Label)lvProduct.Items[e.ItemIndex].FindControl("lblnProductID"); int _nID = 0; if (int.TryParse(lblnID.Text.Trim(), out _nID) && _nID > 0) { bool Result = dbcom.sp_DeleteNormalTableByID2(int.Parse(lblnID.Text), "tb_Product"); if (Result) { //判断文件是不是存在 DataTable dsPro = clProduct.Select_tb_ProductBynProductIDEnable(_nID); if (dsPro.Rows.Count > 0) { //Image ImsImagePath = (Image)lvProduct.Items[e.ItemIndex].FindControl("sPImagePath"); //string sSaveFolderFullPath = Server.MapPath(ImsImagePath.ImageUrl); string sSaveFolderFullPath = Server.MapPath(dsPro.Rows[0]["sPImagePath"].ToString()); if (File.Exists(sSaveFolderFullPath)) { //如果存在则删除 File.Delete(sSaveFolderFullPath); } //Image ImsImagePath2 = (Image)lvProduct.Items[e.ItemIndex].FindControl("sThumbPath"); //string sSaveFolderFullPath2 = Server.MapPath(ImsImagePath2.ImageUrl); string sSaveFolderFullPath2 = Server.MapPath(dsPro.Rows[0]["sThumbPath"].ToString()); if (File.Exists(sSaveFolderFullPath2)) { //如果存在则删除 File.Delete(sSaveFolderFullPath2); } } } ReBindPageList(); } }
protected void BtnAdd_Click(object sender, EventArgs e) { try { //判断session if (Session["User"] == null || Session["User"].ToString().Length < 1) { Response.Redirect(Request.RawUrl); } if (ValiAdd()) { DBLL.clsProduct Product = new DBLL.clsProduct(); DBLL.OptionSysDBLL option = new DBLL.OptionSysDBLL(); string sSavepath = ""; //生成缩略图 HttpFileCollection postedFiles = Request.Files; if (postedFiles.Count > 0) { if (postedFiles[0].ContentLength > 0) { System.Drawing.Image image, newimage; //定义image类的对象 string imagePath; //图片路径 string imageType; //图片类型 string imageName; //图片名称 //提供一个回调方法,用于确定Image对象在执行生成缩略图操作时何时提前取消执行 //如果此方法确定 GetThumbnailImage 方法应提前停止执行,则返回 true;否则返回 false System.Drawing.Image.GetThumbnailImageAbort callb = null; string basepath = "~/ProductsUpload" + "/temp/" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + "/"; string sSaveFolderFullPath = Server.MapPath(basepath); if (!System.IO.Directory.Exists(sSaveFolderFullPath)) { Directory.CreateDirectory(sSaveFolderFullPath); } string thbasepath = "~/ProductsUpload" + "/thumb/" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + "/"; string thsSaveFolderFullPath = Server.MapPath(thbasepath); if (!System.IO.Directory.Exists(thsSaveFolderFullPath)) { Directory.CreateDirectory(thsSaveFolderFullPath); } imagePath = postedFiles[0].FileName; //取得图片类型 imageType = imagePath.Substring(imagePath.LastIndexOf(".") + 1); //取得图片名称 imageName = imagePath.Substring(imagePath.LastIndexOf("\\") + 1); Stream imgStream = postedFiles[0].InputStream; //流文件,准备读取上载文件的内容 int imgLen = postedFiles[0].ContentLength; //上载文件大小 //string imgName = txtImageName.Text; //图片名称 //string imgnm = txtImageName.Text; byte[] imgBinaryData = new byte[imgLen];// int n = imgStream.Read(imgBinaryData, 0, imgLen); //保存到虚拟路径 postedFiles[0].SaveAs(sSaveFolderFullPath + "\\" + imageName); ////显示原图 //imageSource.ImageUrl = "upFile/" + imageName; //为上传的图片建立引用 image = System.Drawing.Image.FromFile(sSaveFolderFullPath + "\\" + imageName); //int smallW = 100;//小图片宽 //int smallH = smallW * image.Height / image.Width;//小图片高 int smallH = 100; int smallW = smallH * image.Width / image.Height; //生成缩略图 newimage = image.GetThumbnailImage(smallW, smallH, callb, new System.IntPtr()); //把缩略图保存到指定的虚拟路径 newimage.Save(thsSaveFolderFullPath + "\\" + imageName); //释放image对象占用的资源 image.Dispose(); //释放newimage对象的资源 newimage.Dispose(); sSavepath = thbasepath + imageName; } } MutileUploaderUserControl31.SavePath(); int _Result = 0; if (MutileUploaderUserControl31.filepathlist.Count > 0) { _Result = Product.insert_tb_Product(ddlProductCateTreelist21.nSelectProductCategoryID, cbbHot.Checked, MutileUploaderUserControl31.filepathlist[0].ToString(), txtsProductNameCN.Text, txtsProductNameEN.Text, CKEditorControl3.Text, CKEditorControl4.Text, CKEditorControl1.Text, CKEditorControl2.Text, Session["user"].ToString(), DateTime.Now, Session["user"].ToString(), DateTime.Now, true, int.Parse(txtnSorting.Text), sSavepath, "", "", "", "", "", "", "", "", "", "", "", "", txtsBrandNameCN.Text, txtsBrandNameEN.Text); } else { _Result = Product.insert_tb_Product(ddlProductCateTreelist21.nSelectProductCategoryID, cbbHot.Checked, "", txtsProductNameCN.Text, txtsProductNameEN.Text, CKEditorControl3.Text, CKEditorControl4.Text, CKEditorControl1.Text, CKEditorControl2.Text, Session["user"].ToString(), DateTime.Now, Session["user"].ToString(), DateTime.Now, true, int.Parse(txtnSorting.Text), "", "", "", "", "", "", "", "", "", "", "", "", "", txtsBrandNameCN.Text, txtsBrandNameEN.Text); } if (_Result > 0) { ShowMsg1.InnerContent = option.GetOptionValue("FormatSetting", "CommandControl", "InsertSuccess"); ShowMsg1.Show(); Clear(); } else { ShowMsg1.InnerContent = option.GetOptionValue("FormatSetting", "CommandControl", "InsertFail"); ShowMsg1.Show(); } } else { ShowMsg1.Show(); } } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int nID = 0; if (Request.QueryString["nID"] != null && int.TryParse(Request.QueryString["nID"].ToString(), out nID) && nID > 0) { lblBigtitle.Text = "编辑数据"; BtnAdd.Visible = false; btnUpdate.Visible = true; DBLL.DBcommon DBc = new DBLL.DBcommon(); DataTable dtProductCate = new DataTable(); dtProductCate = DBc.selectNormalTableofAll(false, "tb_ProductCategory"); if (dtProductCate != null) { //ddlnParentCategoryID.DataSource = dtProductCate; //ddlnParentCategoryID.DataValueField = "nProductCategoryID"; //ddlnParentCategoryID.DataTextField = "sProductCategoryNameCN"; //ddlnParentCategoryID.DataBind(); ddlProductCateTreelist21.ProductList = dtProductCate; } DBLL.clsProduct clProduct = new DBLL.clsProduct(); DataTable dt = clProduct.Select_tb_ProductBynProductID(nID); if (dt != null && dt.Rows.Count > 0) { hfID.Value = dt.Rows[0]["nProductID"].ToString(); cbbHot.Checked = bool.Parse(dt.Rows[0]["bHot"].ToString()); txtsProductNameCN.Text = dt.Rows[0]["sProductNameCN"].ToString(); txtsProductNameEN.Text = dt.Rows[0]["sProductNameEN"].ToString(); //txtsEnsitivityCN.Text = dt.Rows[0]["sEnsitivityCN"].ToString(); //txtsEnsitivityEN.Text = dt.Rows[0]["sEnsitivityEN"].ToString(); //txtsChannelBalanceCN.Text = dt.Rows[0]["sChannelBalanceCN"].ToString(); //txtsChannelBalanceEN.Text = dt.Rows[0]["sChannelBalanceEN"].ToString(); //txtsImpedanceCN.Text = dt.Rows[0]["sImpedanceCN"].ToString(); //txtsImpedanceEN.Text = dt.Rows[0]["sImpedanceEN"].ToString(); //txtsFrequencyCN.Text = dt.Rows[0]["sFrequencyCN"].ToString(); //txtsFrequencyEN.Text = dt.Rows[0]["sFrequencyEN"].ToString(); //txtsRatedPowerCN.Text = dt.Rows[0]["sRatedPowerCN"].ToString(); //txtsRatedPowerEN.Text = dt.Rows[0]["sRatedPowerEN"].ToString(); //txtsMaximumPowerCN.Text = dt.Rows[0]["sMaximumPowerCN"].ToString(); //txtsMaximumPowerEN.Text = dt.Rows[0]["sMaximumPowerEN"].ToString(); CKEditorControl3.Text = dt.Rows[0]["sSummaryCN"].ToString(); CKEditorControl4.Text = dt.Rows[0]["sSummaryEN"].ToString(); txtsBrandNameCN.Text = dt.Rows[0]["sBrandNameCN"].ToString(); txtsBrandNameEN.Text = dt.Rows[0]["sBrandNameEN"].ToString(); CKEditorControl1.Text = dt.Rows[0]["sIntroCN"].ToString(); CKEditorControl2.Text = dt.Rows[0]["sIntroEN"].ToString(); ddlProductCateTreelist21.setnSelectID(int.Parse(dt.Rows[0]["nProductCategoryID"].ToString())); Image3.ImageUrl = dt.Rows[0]["sPImagePath"].ToString(); //Imagestring.ImageUrl = ""; Image4.ImageUrl = dt.Rows[0]["sThumbPath"].ToString(); if (Image3.ImageUrl != "") { lblsImagePath.Visible = false; MutileUploaderUserControl31.Visible = false; Label2.Visible = true; Button1.Visible = true; Image3.Visible = true; } else { lblsImagePath.Visible = true; MutileUploaderUserControl31.Visible = true; Label2.Visible = false; Button1.Visible = false; Image3.Visible = false; } txtnSorting.Text = dt.Rows[0]["nSorting"].ToString(); //绑定数据 } } else { DBLL.OptionSysDBLL option = new DBLL.OptionSysDBLL(); CKEditorControl3.Text = option.GetOptionValue("cn", "SystemSetting", "ProductCateTemplate"); CKEditorControl4.Text = option.GetOptionValue("en", "SystemSetting", "ProductCateTemplate"); lblBigtitle.Text = "添加数据"; btnUpdate.Visible = false; BtnAdd.Visible = true; DBLL.DBcommon DBc = new DBLL.DBcommon(); DataTable dt = new DataTable(); dt = DBc.selectNormalTableofAll(false, "tb_ProductCategory"); if (dt != null) { //ddlnParentCategoryID.DataSource = dt; //ddlnParentCategoryID.DataValueField = "nProductCategoryID"; //ddlnParentCategoryID.DataTextField = "sProductCategoryNameCN"; //ddlnParentCategoryID.DataBind(); ddlProductCateTreelist21.ProductList = dt; } Label2.Visible = false; Button1.Visible = false; Image3.Visible = false; } } }
protected void lvProductList_SelectedIndexChanging(object sender, ListViewSelectEventArgs e) { Label lblnID = (Label)lvProductList.Items[e.NewSelectedIndex].FindControl("lblnProductID"); int _nID = 0; DBLL.clsProduct Product = new DBLL.clsProduct(); if (int.TryParse(lblnID.Text.Trim(), out _nID) && _nID > 0) { DBLL.DBcommon dbcom = new DBLL.DBcommon(); Model.dsProduct.tb_ProductCategoryDataTable ProductList = new Model.dsProduct.tb_ProductCategoryDataTable(); ProductList.Merge(dbcom.selectNormalTableofAll(false, "tb_ProductCategory")); ddlProductCateTreelist2.ProductList = ProductList; ddlProductCateTreelist2.Fresh(); MultiView1.ActiveViewIndex = 1; DataTable dt = Product.Select_tb_ProductBynProductID(_nID); cbbHot.Checked = bool.Parse(dt.Rows[0]["bHot"].ToString()); txtsProductNameCN.Text = dt.Rows[0]["sProductNameCN"].ToString(); txtsProductNameEN.Text = dt.Rows[0]["sProductNameEN"].ToString(); txtsSummaryCN.Text = dt.Rows[0]["sSummaryCN"].ToString(); txtsSummaryEN.Text = dt.Rows[0]["sSummaryEN"].ToString(); txtsPlaceoforiginCN.Text = dt.Rows[0]["sPlaceoforiginCN"].ToString(); txtsPlaceoforiginEN.Text = dt.Rows[0]["sPlaceoforiginEN"].ToString(); txtsModelNoCN.Text = dt.Rows[0]["sModelNoCN"].ToString(); txtsModelNoEN.Text = dt.Rows[0]["sModelNoEN"].ToString(); txtsPriceTermsCN.Text = dt.Rows[0]["sPriceTermsCN"].ToString(); txtsPriceTermsEN.Text = dt.Rows[0]["sPriceTermsEN"].ToString(); txtsPaymentTermsCN.Text = dt.Rows[0]["sPaymentTermsCN"].ToString(); txtsPaymentTermsEN.Text = dt.Rows[0]["sPaymentTermsEN"].ToString(); txtsPackageCN.Text = dt.Rows[0]["sPackageCN"].ToString(); txtsPackageEN.Text = dt.Rows[0]["sPackageEN"].ToString(); txtsMinimumOrderCN.Text = dt.Rows[0]["sMinimumOrderCN"].ToString(); txtsMinimumOrderEN.Text = dt.Rows[0]["sMinimumOrderEN"].ToString(); txtsDeliveryTimeCN.Text = dt.Rows[0]["sDeliveryTimeCN"].ToString(); txtsDeliveryTimeEN.Text = dt.Rows[0]["sDeliveryTimeEN"].ToString(); txtsBrandNameCN.Text = dt.Rows[0]["sBrandNameCN"].ToString(); txtsBrandNameEN.Text = dt.Rows[0]["sBrandNameEN"].ToString(); CKEditorControl1.Text = dt.Rows[0]["sIntroCN"].ToString(); CKEditorControl2.Text = dt.Rows[0]["sIntroEN"].ToString(); ddlnSorting.SelectedValue = dt.Rows[0]["nSorting"].ToString(); //ddlProductCateTreelist2.nSelectProductCategoryID = int.Parse(dt.Rows[0]["nProductCategoryID"].ToString()); ddlProductCateTreelist2.setnSelectID(int.Parse(dt.Rows[0]["nProductCategoryID"].ToString())); MutileUploaderUserControl1.Refresh(); DBLL.clsProductImage ProductImage = new DBLL.clsProductImage(); DataTable Imagedt = new DataTable(); Imagedt = ProductImage.Select_tb_ProductImageBynProductID(_nID); if (Imagedt != null) { ProductImageList.Clear(); ProductImageList.Merge(Imagedt); lvProductImageList.DataSource = ProductImageList; lvProductImageList.DataBind(); } else { ProductImageList.Clear(); lvProductImageList.DataSource = ProductImageList; lvProductImageList.DataBind(); } Button1.Text = "显示图片"; lvProductImageList.Visible = false; hfProductUpdateID.Value = _nID.ToString(); } }
protected void BtnUpdate_Click(object sender, EventArgs e) { //判断session if (Session["User"] == null || Session["User"].ToString().Length < 1) Response.Redirect(Request.RawUrl); try { if (ValiEdit()) { DBLL.clsProduct Product = new DBLL.clsProduct(); DBLL.OptionSysDBLL option = new DBLL.OptionSysDBLL(); string sSavepath = ""; //生成缩略图 HttpFileCollection postedFiles = Request.Files; if (postedFiles.Count > 0) { if (postedFiles[0].ContentLength > 0) { System.Drawing.Image image, newimage; //定义image类的对象 string imagePath; //图片路径 string imageType; //图片类型 string imageName; //图片名称 //提供一个回调方法,用于确定Image对象在执行生成缩略图操作时何时提前取消执行 //如果此方法确定 GetThumbnailImage 方法应提前停止执行,则返回 true;否则返回 false System.Drawing.Image.GetThumbnailImageAbort callb = null; string basepath = "~/ProductsUpload" + "/temp/" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + "/"; string sSaveFolderFullPath = Server.MapPath(basepath); if (!System.IO.Directory.Exists(sSaveFolderFullPath)) { Directory.CreateDirectory(sSaveFolderFullPath); } string thbasepath = "~/ProductsUpload" + "/thumb/" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + "/"; string thsSaveFolderFullPath = Server.MapPath(thbasepath); if (!System.IO.Directory.Exists(thsSaveFolderFullPath)) { Directory.CreateDirectory(thsSaveFolderFullPath); } imagePath = postedFiles[0].FileName; //取得图片类型 imageType = imagePath.Substring(imagePath.LastIndexOf(".") + 1); //取得图片名称 imageName = imagePath.Substring(imagePath.LastIndexOf("\\") + 1); Stream imgStream = postedFiles[0].InputStream;//流文件,准备读取上载文件的内容 int imgLen = postedFiles[0].ContentLength; //上载文件大小 //string imgName = txtImageName.Text; //图片名称 //string imgnm = txtImageName.Text; byte[] imgBinaryData = new byte[imgLen];// int n = imgStream.Read(imgBinaryData, 0, imgLen); //保存到虚拟路径 postedFiles[0].SaveAs(sSaveFolderFullPath + "\\" + imageName); ////显示原图 //imageSource.ImageUrl = "upFile/" + imageName; //为上传的图片建立引用 image = System.Drawing.Image.FromFile(sSaveFolderFullPath + "\\" + imageName); //int smallW = 100;//小图片宽 //int smallH = smallW * image.Height / image.Width;//小图片高 int smallH = 100; int smallW = smallH * image.Width / image.Height; //生成缩略图 newimage = image.GetThumbnailImage(smallW, smallH, callb, new System.IntPtr()); //把缩略图保存到指定的虚拟路径 newimage.Save(thsSaveFolderFullPath + "\\" + imageName); //释放image对象占用的资源 image.Dispose(); //释放newimage对象的资源 newimage.Dispose(); sSavepath = thbasepath + imageName; } } bool _Result = Product.update_tb_ProductBynProductID(int.Parse(hfProductUpdateID.Value), ddlProductCateTreelist2.nSelectProductCategoryID, cbbHot.Checked, sSavepath, txtsProductNameCN.Text, txtsProductNameEN.Text, txtsSummaryCN.Text, txtsSummaryEN.Text, txtsPlaceoforiginCN.Text, txtsPlaceoforiginEN.Text, txtsModelNoCN.Text, txtsModelNoEN.Text, txtsPriceTermsCN.Text, txtsPriceTermsEN.Text, txtsPaymentTermsCN.Text, txtsPaymentTermsEN.Text, txtsPackageCN.Text, txtsPackageEN.Text, txtsMinimumOrderCN.Text, txtsMinimumOrderEN.Text, txtsDeliveryTimeCN.Text, txtsDeliveryTimeEN.Text, txtsBrandNameCN.Text, txtsBrandNameEN.Text, CKEditorControl1.Text, CKEditorControl2.Text, Session["User"].ToString(), DateTime.Now, true, int.Parse(ddlnSorting.SelectedValue)); if (_Result == true) { int _ImageResult = 0; MutileUploaderUserControl1.sNewName = txtsProductNameCN.Text; MutileUploaderUserControl1.SavePath(); if (MutileUploaderUserControl1.filepathlist.Count > 0) { for (int i = 0; i < MutileUploaderUserControl1.filepathlist.Count; i++) { //Response.Write(MutileUploaderUserControl1.filepathlist[i]); DBLL.clsProductImage ProductImage = new DBLL.clsProductImage(); _ImageResult = ProductImage.insert_tb_ProductImage(int.Parse(hfProductUpdateID.Value), MutileUploaderUserControl1.filenamelist[i].ToString(), txtsProductNameEN.Text, MutileUploaderUserControl1.filepathlist[i].ToString(), Session["User"].ToString(), DateTime.Now, Session["User"].ToString(), DateTime.Now, true, 1); } } else { _ImageResult = 1; } if (_ImageResult > 0) { ShowMsg1.InnerContent = option.GetOptionValue("FormatSetting", "CommandControl", "InsertSuccess"); ShowMsg1.Show(); MultiView1.ActiveViewIndex = 0; ReBindPageList(); } else { ShowMsg1.InnerContent = option.GetOptionValue("FormatSetting", "CommandControl", "InsertFail"); ShowMsg1.Show(); } MultiView1.ActiveViewIndex = 0; ReBindPageList(); } else { //失败就一条 ShowMsg1.InnerContent = option.GetOptionValue("FormatSetting", "CommandControl", "UpdateFail"); ShowMsg1.Show(); } } } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DBLL.clsProduct productdt = new DBLL.clsProduct(); DBLL.clsProductImage proimage = new DBLL.clsProductImage(); DBLL.DBcommon DBcommon = new DBLL.DBcommon(); DataTable dtp = productdt.sp_selectNormalTableOfAllByProduct(false); DataTable dtpi = DBcommon.GetDataTable("select * from tb_ProductImage where bEnable=1 order by dCreatedTime desc"); for (int i = 0; i < dtp.Rows.Count; i++) { try { DataRow[] pirow = dtpi.Select("nProductID=" + dtp.Rows[i]["nProductID"].ToString()); string sSavepath = ""; if (pirow.Length > 0) { string yuanpath = pirow[0]["sPImagePath"].ToString(); System.Drawing.Image image, newimage; //定义image类的对象 string imagePath; //图片路径 string imageType; //图片类型 string imageName; //图片名称 //提供一个回调方法,用于确定Image对象在执行生成缩略图操作时何时提前取消执行 //如果此方法确定 GetThumbnailImage 方法应提前停止执行,则返回 true;否则返回 false System.Drawing.Image.GetThumbnailImageAbort callb = null; string thbasepath = "~/ProductsUpload" + "/thumb/" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + dtp.Rows[i]["nProductID"].ToString() + "/"; string thsSaveFolderFullPath = Server.MapPath(thbasepath); if (!System.IO.Directory.Exists(thsSaveFolderFullPath)) { Directory.CreateDirectory(thsSaveFolderFullPath); } StreamReader re = new StreamReader(Server.MapPath(yuanpath)); image = System.Drawing.Image.FromFile(Server.MapPath(yuanpath)); imagePath = yuanpath; //取得图片类型 imageType = imagePath.Substring(imagePath.LastIndexOf(".") + 1); //取得图片名称 imageName = imagePath.Substring(imagePath.LastIndexOf("/") + 1); ////显示原图 //imageSource.ImageUrl = "upFile/" + imageName; //为上传的图片建立引用 //int smallW = 100;//小图片宽 //int smallH = smallW * image.Height / image.Width;//小图片高 int smallH = 100; int smallW = smallH * image.Width / image.Height; //生成缩略图 newimage = image.GetThumbnailImage(smallW, smallH, callb, new System.IntPtr()); //把缩略图保存到指定的虚拟路径 newimage.Save(thsSaveFolderFullPath + "\\" + imageName); //释放image对象占用的资源 image.Dispose(); //释放newimage对象的资源 newimage.Dispose(); sSavepath = thbasepath + imageName; } DBcommon.Excute("update tb_Product set sThumbPath='" + sSavepath + "' where nProductID=" + dtp.Rows[i]["nProductID"].ToString()); } catch (Exception) { } } } }