博客园 首页 联系 订阅 管理

 <tr>
                                    <td height="30" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left"><span class="STYLE1">图片:<asp:Label ID="myimg" runat="server" Text="Label" Visible="false"></asp:Label></span></div>                                  </td>
                                    <td height="20" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                            <asp:FileUpload ID="FileUpload1" runat="server" />
                                            <asp:Image ID="Image1" runat="server" Width ="64" Height="64" ImageUrl="~/syco_admin/images/none.jpg" />
                                        </div> </td>
                                </tr>
                               
                                 
                                   <tr>
                                    <td height="30" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                            <span class="STYLE1">详细描述:</span></div> </td>
                                    <td height="20" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                          <FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" height="400px"
                                                width="900px"></FCKeditorV2:FCKeditor>
                                            </div></td>
                                </tr>
                                <tr>
                                    <td height="30" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                            <span class="STYLE1">功能详细描述:</span></div> </td>
                                    <td height="20" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                          <FCKeditorV2:FCKeditor ID="FCKeditor2" runat="server" height="400px"
                                                width="900px"></FCKeditorV2:FCKeditor>
                                            </div></td>
                                </tr>
                                 <tr>
                                    <td height="30" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left"><span class="STYLE1">第一张子图片:<asp:Label ID="Label2" runat="server" Text="Label" Visible="false"></asp:Label></span></div>                                  </td>
                                    <td height="20" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                            <asp:FileUpload ID="FileUpload2" runat="server" />
                                            <asp:Image ID="Image2" runat="server" Width ="64" Height="64" ImageUrl="~/syco_admin/images/none.jpg" />
                                        </div> </td>
                                </tr>
                                <tr>
                                    <td height="30" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left"><span class="STYLE1">第二张子图片:<asp:Label ID="Label3" runat="server" Text="Label" Visible="false"></asp:Label></span></div>                                  </td>
                                    <td height="20" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                            <asp:FileUpload ID="FileUpload3" runat="server" />
                                            <asp:Image ID="Image3" runat="server" Width ="64" Height="64" ImageUrl="~/syco_admin/images/none.jpg" />
                                        </div> </td>
                                </tr>
                                <tr>
                                    <td height="30" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left"><span class="STYLE1">第三张子图片:<asp:Label ID="Label4" runat="server" Text="Label" Visible="false"></asp:Label></span></div>                                  </td>
                                    <td height="20" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                            <asp:FileUpload ID="FileUpload4" runat="server" />
                                            <asp:Image ID="Image4" runat="server" Width ="64" Height="64" ImageUrl="~/syco_admin/images/none.jpg" />
                                        </div> </td>
                                </tr>
                                <tr>
                                    <td height="30" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left"><span class="STYLE1">第四张子图片:<asp:Label ID="Label5" runat="server" Text="Label" Visible="false"></asp:Label></span></div>                                  </td>
                                    <td height="20" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                            <asp:FileUpload ID="FileUpload5" runat="server" />
                                            <asp:Image ID="Image5" runat="server" Width ="64" Height="64" ImageUrl="~/syco_admin/images/none.jpg" />
                                        </div> </td>
                                </tr>
                                <tr>
                                    <td height="30" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left"><span class="STYLE1">第五张子图片:<asp:Label ID="Label6" runat="server" Text="Label" Visible="false"></asp:Label></span></div>                                  </td>
                                    <td height="20" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                            <asp:FileUpload ID="FileUpload6" runat="server" />
                                            <asp:Image ID="Image6" runat="server" Width ="64" Height="64" ImageUrl="~/syco_admin/images/none.jpg" />
                                        </div> </td>
                                </tr>
                                <tr>
                                    <td height="30" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left"><span class="STYLE1">第六张子图片:<asp:Label ID="Label7" runat="server" Text="Label" Visible="false"></asp:Label></span></div>                                  </td>
                                    <td height="20" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                            <asp:FileUpload ID="FileUpload7" runat="server" />
                                            <asp:Image ID="Image7" runat="server" Width ="64" Height="64" ImageUrl="~/syco_admin/images/none.jpg" />
                                        </div> </td>
                                </tr>
                                <tr>
                                    <td height="30" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left"><span class="STYLE1">第七张子图片:<asp:Label ID="Label8" runat="server" Text="Label" Visible="false"></asp:Label></span></div>                                  </td>
                                    <td height="20" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                            <asp:FileUpload ID="FileUpload8" runat="server" />
                                            <asp:Image ID="Image8" runat="server" Width ="64" Height="64" ImageUrl="~/syco_admin/images/none.jpg" />
                                        </div> </td>
                                </tr>
                                <tr>
                                    <td height="30" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left"><span class="STYLE1">第八张子图片:<asp:Label ID="Label9" runat="server" Text="Label" Visible="false"></asp:Label></span></div>                                  </td>
                                    <td height="20" bgcolor="#FFFFFF" style="padding-left:10px;">
                                        <div align="left">
                                            <asp:FileUpload ID="FileUpload9" runat="server" />
                                            <asp:Image ID="Image9" runat="server" Width ="64" Height="64" ImageUrl="~/syco_admin/images/none.jpg" />
                                        </div> </td>
                                </tr>

protected void 修改_Click(object sender, EventArgs e)
    {
       
        string newimg1 = "";
        string newname1 = "";
        string fileName1;
        fileName1 = this.FileUpload1.PostedFile.FileName.ToString().Trim();

        if (fileName1 != "")
        {
            Guid a = new Guid();
            string fileType1 = fileName1.Substring(fileName1.LastIndexOf(".") + 1).ToLower();
            newname1 = System.Guid.NewGuid().ToString() + "." + fileType1;
            newimg1 = "images/" + newname1;
            FileUpload1.SaveAs(Server.MapPath("../images/" + newname1));
            try
            {
                File.Delete(Server.MapPath(this.Image1.ImageUrl));
            }
            catch (Exception)
            {

            }
        }
        else
        {
            string yuanming1 = this.Image1.ImageUrl;
            newimg1 = yuanming1.Remove(0, 3);

        }
        string newimg2 = "";
        string newname2 = "";
        string fileName2;
        fileName2 = this.FileUpload2.PostedFile.FileName.ToString().Trim();

        if (fileName2 != "")
        {
            Guid a = new Guid();
            string fileType2 = fileName2.Substring(fileName2.LastIndexOf(".") + 1).ToLower();
            newname2 = System.Guid.NewGuid().ToString() + "." + fileType2;
            newimg2 = "images/" + newname2;
            FileUpload2.SaveAs(Server.MapPath("../images/" + newname2));
            try
            {
                File.Delete(Server.MapPath(this.Image2.ImageUrl));
            }
            catch (Exception)
            {

            }
        }
        else
        {
            string yuanming2 = this.Image2.ImageUrl;
            newimg2 = yuanming2.Remove(0, 3);

        }
        string newimg3 = "";
        string newname3 = "";
        string fileName3;
        fileName3 = this.FileUpload3.PostedFile.FileName.ToString().Trim();

        if (fileName3 != "")
        {
            string fileType3 = fileName3.Substring(fileName3.LastIndexOf(".") + 1).ToLower();
            newname3 = System.Guid.NewGuid().ToString() + "." + fileType3;
            newimg3 = "images/" + newname3;
            FileUpload3.SaveAs(Server.MapPath("../images/" + newname3));
            try
            {
                File.Delete(Server.MapPath(this.Image3.ImageUrl));
            }
            catch (Exception)
            {

            }
        }
        else
        {
            string yuanming3 = this.Image3.ImageUrl;
            newimg3 = yuanming3.Remove(0, 3);

        }
        string newimg4 = "";
        string newname4 = "";
        string fileName4;
        fileName4 = this.FileUpload4.PostedFile.FileName.ToString().Trim();

        if (fileName4 != "")
        {
            string fileType4 = fileName4.Substring(fileName4.LastIndexOf(".") + 1).ToLower();
            newname4 = System.Guid.NewGuid().ToString() + "." + fileType4;
            newimg4 = "images/" + newname4;
            FileUpload4.SaveAs(Server.MapPath("../images/" + newname4));
            try
            {
                File.Delete(Server.MapPath(this.Image4.ImageUrl));
            }
            catch (Exception)
            {

            }
        }
        else
        {
            string yuanming4 = this.Image4.ImageUrl;
            newimg4 = yuanming4.Remove(0, 3);

        }
        string newimg5 = "";
        string newname5 = "";
        string fileName5;
        fileName5 = this.FileUpload5.PostedFile.FileName.ToString().Trim();

        if (fileName5 != "")
        {
            string fileType5 = fileName5.Substring(fileName5.LastIndexOf(".") + 1).ToLower();
            newname5 = System.Guid.NewGuid().ToString() + "." + fileType5;
            newimg5 = "images/" + newname5;
            FileUpload5.SaveAs(Server.MapPath("../images/" + newname5));
            try
            {
                File.Delete(Server.MapPath(this.Image5.ImageUrl));
            }
            catch (Exception)
            {

            }
        }
        else
        {
            string yuanming5 = this.Image5.ImageUrl;
            newimg5 = yuanming5.Remove(0, 3);

        }
        string newimg6 = "";
        string newname6 = "";
        string fileName6;
        fileName6 = this.FileUpload6.PostedFile.FileName.ToString().Trim();

        if (fileName6 != "")
        {
            Guid kk = new Guid();
            string fileType6 = fileName6.Substring(fileName6.LastIndexOf(".") + 1).ToLower();
            newname6 = System.Guid.NewGuid().ToString() + "." + fileType6;
            newimg6 = "images/" + newname6;
            FileUpload6.SaveAs(Server.MapPath("../images/" + newname6));
            try
            {
                File.Delete(Server.MapPath(this.Image6.ImageUrl));
            }
            catch (Exception)
            {

            }
        }
        else
        {
            string yuanming6 = this.Image6.ImageUrl;
            newimg6 = yuanming6.Remove(0, 3);

        }
        string newimg7 = "";
        string newname7 = "";
        string fileName7;
        fileName7 = this.FileUpload7.PostedFile.FileName.ToString().Trim();

        if (fileName7 != "")
        {
            string fileType7 = fileName7.Substring(fileName7.LastIndexOf(".") + 1).ToLower();
            newname7 = System.Guid.NewGuid().ToString() + "." + fileType7;
            newimg7 = "images/" + newname7;
            FileUpload7.SaveAs(Server.MapPath("../images/" + newname7));
            try
            {
                File.Delete(Server.MapPath(this.Image7.ImageUrl));
            }
            catch (Exception)
            {

            }
        }
        else
        {
            string yuanming7 = this.Image7.ImageUrl;
            newimg7 = yuanming7.Remove(0, 3);

        }
        string newimg8 = "";
        string newname8 = "";
        string fileName8;
        fileName8 = this.FileUpload8.PostedFile.FileName.ToString().Trim();

        if (fileName8 != "")
        {
            string fileType8 = fileName8.Substring(fileName8.LastIndexOf(".") + 1).ToLower();
            newname8 = System.Guid.NewGuid().ToString() + "." + fileType8;
            newimg8 = "images/" + newname8;
            FileUpload8.SaveAs(Server.MapPath("../images/" + newname8));
            try
            {
                File.Delete(Server.MapPath(this.Image8.ImageUrl));
            }
            catch (Exception)
            {

            }
        }
        else
        {
            string yuanming8 = this.Image8.ImageUrl;
            newimg8 = yuanming8.Remove(0, 3);

        }
        string newimg9 = "";
        string newname9 = "";
        string fileName9;
        fileName9 = this.FileUpload9.PostedFile.FileName.ToString().Trim();

        if (fileName9 != "")
        {
            string fileType9 = fileName9.Substring(fileName9.LastIndexOf(".") + 1).ToLower();
            newname9 = System.Guid.NewGuid().ToString() + "." + fileType9;
            newimg9 = "images/" + newname9;
            FileUpload9.SaveAs(Server.MapPath("../images/" + newname9));
            try
            {
                File.Delete(Server.MapPath(this.Image9.ImageUrl));
            }
            catch (Exception)
            {

            }
        }
        else
        {
            string yuanming9 = this.Image9.ImageUrl;
            newimg9 = yuanming9.Remove(0, 3);

        }

 


        if (this.ctitle.Text != "")
        {
            try
            {
                string ss = myids.Text;
                int id = Convert.ToInt32(ss);
                ProductDataContext dc = new ProductDataContext();
                product pt = dc.product.First(n => n.id == id);
                pt.ptype = int.Parse(this.DropDownList1.SelectedValue);
                pt.ptypeTwo = int.Parse(this.DropDownList2.SelectedValue);
                pt.langtype = int.Parse(this.DropDownList3.SelectedValue);
                pt.tuijian = int.Parse(this.RadioButtonList1.SelectedValue);

                pt.ptitle = this.ctitle.Text;
                pt.pmiao = this.FCKeditor1.Value;
                pt.pfeat = this.FCKeditor2.Value;
                pt.psrc = newimg1;
                pt.pimga = newimg2;
                pt.pimgb = newimg3;
                pt.pimgc = newimg4;
                pt.pimgd = newimg5;
                pt.pimge = newimg6;
                pt.pimgf = newimg7;
                pt.pimgg = newimg8;
                pt.pimgh = newimg9;

                dc.SubmitChanges();
                Response.Write("<script>alert('修改成功!')</script>");
                Response.Flush();
                show();
                this.Image1.ImageUrl = "~/syco_admin/images/none.jpg";
                this.Image2.ImageUrl = "~/syco_admin/images/none.jpg";
                this.Image3.ImageUrl = "~/syco_admin/images/none.jpg";
                this.Image4.ImageUrl = "~/syco_admin/images/none.jpg";
                this.Image5.ImageUrl = "~/syco_admin/images/none.jpg";
                this.Image6.ImageUrl = "~/syco_admin/images/none.jpg";
                this.Image7.ImageUrl = "~/syco_admin/images/none.jpg";
                this.Image8.ImageUrl = "~/syco_admin/images/none.jpg";
                this.Image9.ImageUrl = "~/syco_admin/images/none.jpg";

              
            }
            catch (Exception b)
            {
                Console.WriteLine(b.Message.ToString());
            }
        }
        else
        {
            Response.Write("<script>alert('对不起,请先添加分类再添加产品')</script>");
        }

    }

 

posted on 2011-11-29 09:03  $蔷  阅读(3044)  评论(0编辑  收藏  举报