⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deckadd.aspx.cs

📁 主要是一个图片展示效果
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.IO;
using System.Drawing;
using System.Drawing.Drawing2D;

public partial class DeckAdd : System.Web.UI.Page
{
    DeckClass dc = new DeckClass();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataSet ds = dc.GetDeckClassSum();
            if (ds.Tables[0].Rows.Count > 0)
            {
                drdlstDeckClass.DataSource = ds;
                drdlstDeckClass.DataTextField = "DClassName";
                drdlstDeckClass.DataValueField = "DClassId";
                drdlstDeckClass.DataBind();
            }
            else
            { 
                drdlstDeckClass.Text = "暂无数据!";
            }
        }
    }

    protected void lbtnAddDeck_Click(object sender, EventArgs e)
    {        
        HttpPostedFile hpf = FileUpload1.PostedFile;
        string extension = Path.GetExtension(hpf.FileName).ToLower();
        if (extension == ".jpg" || extension == ".jpeg" || extension == ".jpe" || extension == ".gif" || extension == ".png" || extension == ".bmp")
        {
            if (txtPhone.Text != "" || txtFax.Text != "" || txtPostBoy.Text != "" || txtEmail.Text != "")
            {
                dc.DeckName = txtDeckName.Text.Trim();
                if (ViewState["DClassId"] == null)
                {
                    dc.DClassId = int.Parse(drdlstDeckClass.Text.Trim());
                }
                else
                {
                    dc.DClassId = int.Parse(ViewState["DClassId"].ToString());
                }
                //dc.BrokerId = int.Parse(Session["BrokerId"].ToString());
                dc.BrokerId =9;
                dc.Stylist = txtStylist.Text.Trim();
                dc.DetailInfo = txtDetailInfo.Text.Trim();
                dc.Address = txtAddress.Text.Trim();
                dc.Phone = txtPhone.Text.Trim();
                dc.Fax = txtFax.Text.Trim();
                dc.PostBoy = int.Parse(txtPostBoy.Text.Trim());
                dc.Email = txtEmail.Text.Trim();
                dc.FirmDetail = txtFirmDetail.Text.Trim();
                string fileName = Path.GetFileName(hpf.FileName);
                dc.ImgUrl = fileName;
                hpf.SaveAs(Server.MapPath("../Img") + "\\" + fileName);

                int result = dc.AddDeck(dc);
                if (result > 0)
                    Response.Redirect("../Result.aspx?Result=24");
                else
                    Response.Redirect("../Result.aspx?Result=25");
            }
            else
                Response.Redirect("../Result.aspx?Result=26");
        }
        else
        {
            Response.Redirect("../Result.aspx?Result=27");
        }
    }

    protected void drdlstDeckClass_SelectedIndexChanged(object sender, EventArgs e)
    {
        ViewState["DClassId"] = drdlstDeckClass.SelectedValue;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -