📄 particular.aspx.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.Data.SqlClient;
using background;
public partial class Manage_particular : System.Web.UI.Page
{
static String id;
uppic up = new uppic();
modify mo = new modify();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["TZroomConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
}
protected void modify1btn_Click(object sender, EventArgs e)
{
if (this.myFile.PostedFile != null)
{
string photoName1 = myFile.PostedFile.FileName; //获取初始文件名
int i = photoName1.LastIndexOf("."); //取得文件名中最后一个"."的索引
string newext = photoName1.Substring(i); //获取文件扩展名
if (newext != ".gif" && newext != ".jpg" && newext != ".jpeg" && newext != ".bmp" && newext != ".png")
{
Response.Write("<script>alert('文件格式不正确');</script>");
Response.End();
}
DateTime now = DateTime.Now; //获取系统时间
string photoName2 = now.Millisecond.ToString() + "_" + myFile.PostedFile.ContentLength.ToString() + newext; //重新为文件命名,时间毫秒部分+文件大小+扩展名
myFile.PostedFile.SaveAs(Server.MapPath("..\\Image\\" + photoName2)); // 保存文件到路径,用Server.MapPath()取当前文件的绝对目录.在asp.net里"\"必须用"\\"代替
bool yes = up.uppicFile(id, photoName2, "linklogo");
if (yes)
{
Response.Write("<script>alert('文件上传成功');</script>");
Session.Remove("linklogo");
}
else
{
Response.Write("<script>alert('文件上传失败');</script>");
}
}
}
protected void modify2btn_Click(object sender, EventArgs e)
{
if (this.myFile1.PostedFile != null)
{
string photoName1 = myFile1.PostedFile.FileName; //获取初始文件名
int i = photoName1.LastIndexOf("."); //取得文件名中最后一个"."的索引
string newext = photoName1.Substring(i); //获取文件扩展名
if (newext != ".gif" && newext != ".jpg" && newext != ".jpeg" && newext != ".bmp" && newext != ".png")
{
Response.Write("<script>alert('文件格式不正确');</script>");
Response.End();
}
DateTime now = DateTime.Now; //获取系统时间
string photoName2 = now.Millisecond.ToString() + "_" + myFile.PostedFile.ContentLength.ToString() + newext; //重新为文件命名,时间毫秒部分+文件大小+扩展名
myFile1.PostedFile.SaveAs(Server.MapPath("..\\Image\\" + photoName2)); // 保存文件到路径,用Server.MapPath()取当前文件的绝对目录.在asp.net里"\"必须用"\\"代替
bool yes = up.uppicFile(id, photoName2, "Brand");
if (yes)
{
Response.Write("<script>alert('文件上传成功');</script>");
Session.Remove("linklogo");
}
else
{
Response.Write("<script>alert('文件上传失败');</script>");
}
}
}
protected void modify3btn_Click(object sender, EventArgs e)
{
if (this.myFile2.PostedFile != null)
{
string photoName1 = myFile2.PostedFile.FileName; //获取初始文件名
int i = photoName1.LastIndexOf("."); //取得文件名中最后一个"."的索引
string newext = photoName1.Substring(i); //获取文件扩展名
if (newext != ".gif" && newext != ".jpg" && newext != ".jpeg" && newext != ".bmp" && newext != ".png")
{
Response.Write("<script>alert('文件格式不正确');</script>");
Response.End();
}
DateTime now = DateTime.Now; //获取系统时间
string photoName2 = now.Millisecond.ToString() + "_" + myFile.PostedFile.ContentLength.ToString() + newext; //重新为文件命名,时间毫秒部分+文件大小+扩展名
myFile2.PostedFile.SaveAs(Server.MapPath("..\\Image\\" + photoName2)); // 保存文件到路径,用Server.MapPath()取当前文件的绝对目录.在asp.net里"\"必须用"\\"代替
bool yes = up.uppicFile(id, photoName2, "Pic");
if (yes)
{
Response.Write("<script>alert('文件上传成功');</script>");
Session.Remove("linklogo");
}
else
{
Response.Write("<script>alert('文件上传失败');</script>");
}
}
}
protected void Page_Init(object sender, EventArgs e)
{
Binder();
}
public void Binder() {
id = Request.QueryString["id"];
String sql = "select * from tb_GoodsInfo where GoodsID=" + id + "";
SqlCommand cmd = new SqlCommand(sql, conn);
try
{
conn.Open();
SqlDataReader MyReader = cmd.ExecuteReader();
if (MyReader.Read()) {
pidtxt.Text = System.Convert.ToString(MyReader.GetInt32(0));
pnametxt.Text = MyReader.GetString(2);
pzltxt.Text = System.Convert.ToString(MyReader.GetDouble(6));
scjgtxt.Text = System.Convert.ToString(MyReader.GetDouble(9));
hyjgtxt.Text = System.Convert.ToString(MyReader.GetDouble(10));
pbytxt.Text = MyReader.GetString(8);
mstxt.Text = MyReader.GetString(7);
Image1.ImageUrl = "../Image/" + MyReader.GetString(3);
Image2.ImageUrl = "../Image/" + MyReader.GetString(4);
Image3.ImageUrl = "../Image/" + MyReader.GetString(5);
}
}
catch (Exception ex)
{
throw (ex);
}
finally {
conn.Close();
}
}
protected void modifybtn_Click(object sender, EventArgs e)
{
pnametxt.Enabled=true;
pzltxt.Enabled=true;
scjgtxt.Enabled=true;
hyjgtxt.Enabled=true;
pbytxt.Enabled=true;
mstxt.Enabled = true;
modify1btn.Enabled = true;
modify2btn.Enabled = true;
modify3btn.Enabled = true;
}
protected void savebtn_Click(object sender, EventArgs e)
{
if (pnametxt.Text.Length == 0) {
Response.Write("<script>alert('不能为空');</script>");
pnametxt.Focus();
}
else if (pzltxt.Text.Length == 0) {
Response.Write("<script>alert('不能为空');</script>");
pzltxt.Focus();
}
else if (scjgtxt.Text.Length == 0)
{
Response.Write("<script>alert('不能为空');</script>");
scjgtxt.Focus();
}
else if (hyjgtxt.Text.Length == 0)
{
Response.Write("<script>alert('不能为空');</script>");
hyjgtxt.Focus();
}
else if (pbytxt.Text.Length == 0)
{
Response.Write("<script>alert('不能为空');</script>");
pbytxt.Focus();
}
else if (mstxt.Text.Length == 0)
{
Response.Write("<script>alert('不能为空');</script>");
mstxt.Focus();
}
else {
bool yes = mo.modifyPro(id, pnametxt.Text, pbytxt.Text, System.Convert.ToDouble(scjgtxt.Text), System.Convert.ToDouble(hyjgtxt.Text), mstxt.Text, System.Convert.ToDouble(pzltxt.Text));
if (yes)
{
Response.Write("<script>alert('更新成功');location='ProductInfoManager.aspx'</script>");
}
else {
Response.Write("<script>alert('更新失败');</script>");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -