-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddChannel.aspx.cs
70 lines (65 loc) · 2.58 KB
/
addChannel.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
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;
public partial class addChannel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
authentication();
if (!Page.IsPostBack)
{
}
}
private void authentication()
{
if ((Session["status"] == null) || (!Session["status"].Equals("true"))) Response.Redirect("logout.aspx");
if ((Session["type"] == null) || (!Session["type"].Equals("1"))) Response.Redirect("logout.aspx");
}
protected void addChannelBtn_Click(object sender, EventArgs e)
{
string filepath;
string filename="";
string serverpath;
string ChannelNameStr = ChannelNameTB.Text.Trim();
string ChannelMMSStr = ChannelMMSTB.Text.Trim();
int isMobileLiveInt = IsMobileLiveCB.Checked ? 1 : 0;
int isBroadCastInt = IsBroadCastCB.Checked ? 1 : 0;
int isRecordInt = IsRecordCB.Checked ? 1 : 0;
int statusInt = 0;
if (ChannelNameStr.Length < 1) { MessageBox.Show(this, "频道名称不能为空!"); return; }
if (ChannelMMSStr.Length < 1) { MessageBox.Show(this, "频道地址不能为空!"); return; }
try
{
if (imgFU.PostedFile.FileName == "")
{
MessageBox.Show(this, "请选择上传文件!");
}
else
{
filepath = imgFU.PostedFile.FileName;
filename = filepath.Substring(filepath.LastIndexOf("\\") + 1);
serverpath = Server.MapPath("~/poster/") + filename;
imgFU.PostedFile.SaveAs(serverpath);//将上传的文件另存为
}
}
catch (Exception ex)
{
MessageBox.Show(this,"上传发生错误!原因是:" + ex.ToString());
}
channelinfo channel = new channelinfo();
channel.ChannelName = ChannelNameStr;
channel.ChannelMMS = ChannelMMSStr;
channel.IsMobileLiveStream = isMobileLiveInt;
channel.IsBroadcast = isBroadCastInt;
channel.IsRecord = isRecordInt;
channel.ConnectStatus = statusInt;
channel.UserId=Convert.ToInt32(Session["UserId"]);
channel.PosterUrl = "poster/" + filename;
ChannelBLL channelBll = new ChannelBLL();
if (channelBll.Insert(channel)) MessageBox.Show(this, "添加成功!");
else MessageBox.Show(this, "添加失败!");
}
}