62,046
社区成员
发帖
与我相关
我的任务
分享
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
try
{
if (FileUpload1.FileName != "")
{
switch (FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf(".") + 1).ToLower())
{
case "jpg":
break;
case "gif":
break;
case "png":
break;
default:
ScriptManager.RegisterStartupScript(Page, this.GetType(), "script", "alert('请上传gif或者jpg的图片')", true);
return;
}
if (FileUpload1.PostedFile.ContentLength > 100 * 1024 )
{
ScriptManager.RegisterStartupScript(Page, this.GetType(), "script", "alert('文件最大100K')", true);
return;
}
CS.BLL.LMShenQingShenHe bll = new CS.BLL.LMShenQingShenHe();
bool bl = bll.Existss(nickname);
if (bl)
{
string folder = System.Web.HttpContext.Current.Server.MapPath("/") + "/images/LmImg".Replace("/", "\\") + "\\";
//string path = Server.MapPath("~/images/LmImg/");
//string folder = "images\\LmImg\\";
string filename = FileUpload1.FileName;
FileUpload1.SaveAs(folder + filename);
//string path = Server.MapPath("~/images/LmImg/");
//string filename = FileUpload1.FileName;
//FileUpload1.SaveAs(path + filename);
CS.Model.LMShenQingShenHe model = new CS.Model.LMShenQingShenHe();
CS.Model.LMShenQingShenHe lmModel = bll.GetModels(nickname);
model.id= lmModel.id;
model.NickName = nickname;
model.userID = userID;
model.ShenQingLeiXing = 3;
model.Zname = Zname.Value;
model.telephone = DianHua.Value;
model.phone = ShouJi.Value;
if (TxQQ.Value != "" && TxQQ.Value != null)
{
model.QQ = TxQQ.Value;
}
model.MSN = MSN.Value;
model.WzBkName = WZName.Value;
model.WzBkDiZhi = WZdiZhi.Value;
model.ShenQingTime = DateTime.Now;
if (QiTa.Value == "" || QiTa.Value == null)
{
model.SchoolName = area2.Value;
}
else
{
model.SchoolName = QiTa.Value;
}
model.SchoolShenFen = area1.Value;
model.SchoolXiaoQu = XueXiaoDiQu.Value;
model.SchoolEnglish = XueXiaoEnglish.Value;
model.ZhiYe = size_1.Value;
model.NianJi = NianJi.Value;
model.BiYeTime = BiYeTime.Value;
model.ZhuanYe = ZhuanYe.Value;
model.SchoolZhiWu = ZhiWu.Value;
model.NameID = nameID.Value;
model.SchoolDiZhi = XueXiaoDiZhi.Value;
model.YouBian = YouBian.Value;
model.TuPian = filename;
model.ShenQingJieGuo = 1;
bll.Update(model);
Page.ClientScript.RegisterStartupScript(typeof(Page), "2", "alert('申请成功,请等待审核结果');window.location.href='account.aspx'", true);
}
else
{
string folder = System.Web.HttpContext.Current.Server.MapPath("/") + "/images/LmImg".Replace("/", "\\") + "\\";
//string path = Server.MapPath("~/images/LmImg/");
//string folder = "images\\LmImg\\";
string filename = FileUpload1.FileName;
FileUpload1.SaveAs(folder + filename);
CS.Model.LMShenQingShenHe model = new CS.Model.LMShenQingShenHe();
model.NickName = nickname;
model.userID = userID;
model.Zname = Zname.Value;
model.telephone = DianHua.Value;
model.phone = ShouJi.Value;
if (TxQQ.Value != "" && TxQQ.Value != null)
{
model.QQ = TxQQ.Value;
}
model.MSN = MSN.Value;
model.ShenQingLeiXing = 3;
model.WzBkName = WZName.Value;
model.WzBkDiZhi = WZdiZhi.Value;
model.ShenQingTime = DateTime.Now;
if (QiTa.Value == "" || QiTa.Value == null)
{
model.SchoolName = area2.Value;
}
else
{
model.SchoolName = QiTa.Value;
}
model.SchoolShenFen = area1.Value;
model.SchoolXiaoQu = XueXiaoDiQu.Value;
model.SchoolEnglish = XueXiaoEnglish.Value;
model.ZhiYe = size_1.Value;
model.NianJi = NianJi.Value;
model.BiYeTime = BiYeTime.Value;
model.ZhuanYe = ZhuanYe.Value;
model.SchoolZhiWu = ZhiWu.Value;
model.NameID = nameID.Value;
model.SchoolDiZhi = XueXiaoDiZhi.Value;
model.YouBian = YouBian.Value;
model.ShenQingJieGuo = 1;
model.TuPian = filename;
bll.Add(model);
Page.ClientScript.RegisterStartupScript(typeof(Page), "2", "alert('申请成功,请等待审核结果');window.location.href='account.aspx'", true);
}
}
else
{
ScriptManager.RegisterStartupScript(Page, this.GetType(), "script", "alert('请选择您要上传的图片');", true);
}
}
catch (Exception ex)
{
Response.Write("<script>alert('失败!" + ex.Message + "');</script>");
return;
throw;
}
}
string path = Server.MapPath("~/images/LmImg/");
string filename = FileUpload1.FileName;
FileUpload1.SaveAs(path + filename);