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

📄 cusadd.aspx.cs

📁 大中型酒店管理系统
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
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;

public partial class cusadd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SqlConnection conn = db.createconn();
            conn.Open();
            SqlCommand cmd = new SqlCommand("select * from shopmaster", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            this.DropDownList1.DataSource = dr;
            this.DropDownList1.DataTextField = "s_lei";
            this.DropDownList1.DataValueField = "s_id";
            this.DropDownList1.DataBind();
            dr.Close();
        }
    }
    protected void btntijiao_Click(object sender, EventArgs e)
    { 
        SqlConnection conn = db.createconn();
        conn.Open();
        string cname = txtCm.Text;
        string cq = DropDownList1.SelectedValue;
        string cjie = txtCjie.Text;
        string pjie = txtPjie.Text;
        string ren = txtRen.Text;
        string ctel = txtCtel.Text;
        string cfax = txtCfax.Text;
        string cpho = txtCphone.Text;
        string cmail = txtCmail.Text;
        string curl = txtCurl.Text;
        if (cname == "")
        {
            Response.Write("<script>alert('厂家名不能为空!');history.go(-1);</script>");
        }
        else
        {
            string fullFileName = this.File2.PostedFile.FileName;
            string fileName = fullFileName.Substring(fullFileName.LastIndexOf("\\") + 1);
            string type = fullFileName.Substring(fullFileName.LastIndexOf(".") + 1);

            if (fileName == "")
            {
                SqlCommand cmd = new SqlCommand("insert into custom(s_id,name,introduce,product,ren,phone,tel,fax,email,url)" + "values('" + cq + "','" + cname + "','" + cjie + "','" + pjie + "','" + ren + "','" + ctel + "','" + cfax + "','" + cfax + "','" + cmail + "','" + curl + "')", conn);
                cmd.ExecuteNonQuery();
                Response.Redirect("default.aspx");
            }
            else
            {
                if (type == "jpg" || type == "bmp" || type == "gif")
                {
                    this.File2.PostedFile.SaveAs(Server.MapPath("logo") + "\\" + fileName);



                    SqlCommand cmd = new SqlCommand("insert into custom(s_id,name,pic,introduce,product,ren,phone,tel,fax,email,url)" + "values('" + cq + "','" + cname + "','" + fileName + "','" + cjie + "','" + pjie + "','" + ren + "','" + ctel + "','" + cfax + "','" + cfax + "','" + cmail + "','" + curl + "')", conn);



                    cmd.ExecuteNonQuery();

                    Response.Redirect("default.aspx");
                }
                else
                {
                    Response.Write("<script language='javascript'>alert('图片格式不对');</script>");
                }
            }
        }
    }
}

⌨️ 快捷键说明

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