-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert.aspx.cs
161 lines (146 loc) · 6.1 KB
/
insert.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Windows.Input;
using System.Threading;
using BLL;
public partial class insert : System.Web.UI.Page
{
PD s = new PD();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if(Session["xg"]!=null)
{
TextBox1.Text = Session["xgname"].ToString();//name赋值
Session["imgname"] = Session["picxg"];
int IndexofA = Session["picxg"].ToString().LastIndexOf("/");
int IndexofB = Session["picxg"].ToString().LastIndexOf(".");
Label3.Text = Session["picxg"].ToString().Substring(IndexofA + 1, IndexofB - IndexofA + 3);//pic路径赋值
Label1.Visible = false;
Label2.Visible = false;
for (int i = 1; i <= 10; i++)
{
if (Session["xg"].ToString() == "xg"+i)
{
string video= Session["videolj" + i].ToString();
Session["videoname"] = Session["videolj" + i];
int cs1 = video.LastIndexOf("/");
int cs2 = video.LastIndexOf(".");
Label4.Text = video.Substring(cs1 + 1, cs2 - cs1 + 3);//video路径赋值
break;
}
}
if (Session["dmlxpd"].ToString() == "gm") DropDownList1.SelectedIndex = 0;
else if (Session["dmlxpd"].ToString() == "rm") DropDownList1.SelectedIndex = 1;
else if (Session["dmlxpd"].ToString() == "zh") DropDownList1.SelectedIndex = 2;//下拉列表赋值
Button1.Text = "修改";
Page page = (Page)HttpContext.Current.Handler;
page.ClientScript.RegisterStartupScript(page.GetType(), "js", "<script>document.getElementById('body').style=\"background-image:url('fm/xgbj.jpg');background-size:cover;color:white;\"</script>");
}
xl();
}
}
public void xl()
{
DropDownList1.DataSource =s.chalx();
DropDownList1.DataTextField = "lx";
DropDownList1.DataValueField = "id";
DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
String fliname1 = FileUpload1.FileName.ToString();
int flisize1 = FileUpload1.PostedFile.ContentLength / 1024;
if(fliname1=="") Label3.Text = "请选择文件";
else if (fliname1.EndsWith(".jpg") || fliname1.EndsWith(".png") || fliname1.EndsWith(".gif"))
{
if (flisize1 < 3000)
{
String path = Server.MapPath("~\\fm\\" + fliname1);
FileUpload1.SaveAs(path);
Label3.Text = "上传成功";
int IndexofA = path.LastIndexOf("\\");
int IndexofB = path.LastIndexOf(".");
Session["imgname"] ="fm/"+path.Substring(IndexofA + 1, IndexofB - IndexofA + 3);
Label1.Visible = false;
if (Button1.Text == "修改")
{
Page page = (Page)HttpContext.Current.Handler;
page.ClientScript.RegisterStartupScript(page.GetType(), "js", "<script>document.getElementById('body').style=\"background-image:url('fm/xgbj.jpg');background-size:cover;color:white;\"</script>");
}
}
else
{
Response.Write("<script>alert('文件过大')</script>");
}
}
else
{
Label3.Text = "文件类型不正确";
}
}
protected void Button3_Click(object sender, EventArgs e)
{
String fliname2 = FileUpload2.FileName.ToString();
if (fliname2 == "") Label4.Text = "请选择文件";
else if (fliname2.EndsWith(".mp4") || fliname2.EndsWith(".avi") || fliname2.EndsWith(".wmv"))
{
String path = Server.MapPath("~\\video\\" + fliname2);
FileUpload2.SaveAs(path);
Label4.Text = "上传成功";
int IndexofA = path.LastIndexOf("\\");
int IndexofB = path.LastIndexOf(".");
Session["videoname"] = "video/" + path.Substring(IndexofA + 1, IndexofB - IndexofA + 3);
Label2.Visible = false;
if (Button1.Text == "修改")
{
Page page = (Page)HttpContext.Current.Handler;
page.ClientScript.RegisterStartupScript(page.GetType(), "js", "<script>document.getElementById('body').style=\"background-image:url('fm/xgbj.jpg');background-size:cover;color:white;\"</script>");
}
}
else
{
Label4.Text = "文件类型不正确";
}
String tp = FileUpload1.FileName.ToString();
}
protected void Button1_Click1(object sender, EventArgs e)
{
string name;
if (TextBox1.Text.Length != 0)
{
name = TextBox1.Text;
}
else name = "";
int lx = int.Parse(DropDownList1.SelectedValue);
string picname = Session["imgname"].ToString();
string videoname = Session["videoname"].ToString();
if (Button1.Text != "修改")
{
if (s.zeng(name, lx, picname, videoname,"正在审核"))
{
Response.Write("<script>alert('新增成功')</script>");
Response.Redirect("Main.aspx");
}
}
else if (Button1.Text == "修改")
{
string id = Session["idpd"].ToString();
if (s.gai(id, name, lx, picname, videoname))
{
Response.Write("<script>alert('修改成功')</script>");
Response.Redirect("Main.aspx");
}
}
}
protected void Button4_Click(object sender, EventArgs e)
{
Response.Redirect("Main.aspx");
}
}