using System; using System.Collections; using System.Configuration; using System.Data; //using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; //using System.Xml.Linq; namespace Com.Jpsoft.Hospital.Web.Module.jp_druginfo { public partial class Insert : Com.Jpsoft.Hospital.Web.Common.BasePage//System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SetDDL(); } } //类别回调 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { SetDDLChild(DropDownList1.SelectedValue); } //添加 protected void btnAdd_Click(object sender, EventArgs e) { DateTime dt = DateTime.Now; string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + ".jpg"; try { if (FileUpload1.PostedFile.FileName != null && FileUpload1.PostedFile.FileName.ToString()!="") { this.UpFiles(filename); } //this.Add(); Response.Write(""); } catch { Response.Write(""); } } #region /// /// 添加数据 /// private void Add(string filename) { Com.Jpsoft.Hospital.BLL.jp_druginfo bll = new Com.Jpsoft.Hospital.BLL.jp_druginfo(); Com.Jpsoft.Hospital.Model.jp_druginfo mode = new Com.Jpsoft.Hospital.Model.jp_druginfo(); mode.drugname = txtdrugname.Value; mode.businessname = txtbusinessname.Value; mode.drugtype = int.Parse(DropDownList2.SelectedValue); mode.approvalnumber = txtapprovalnumber.Value; mode.standard = txtstandard.Value; mode.manufacturer = txtstandard.Value; mode.company = this.txtcompany.Value; mode.introduction = this.txtintroduction.Value; mode.goodinfo = this.txtgoodinfo.Value; mode.imgpath = filename; mode.ingredients = this.txtingredients.Value; mode.traits = this.txttraits.Value; mode.usedosage = this.txtusedosage.Value; mode.drugaffect = this.txtdrugaffect.Value; mode.functions = this.txtfunctions.Value; mode.badreaction = this.txtbadreaction.Value; mode.taboo = this.txttaboo.Value; mode.notice = this.txtnotice.Value; mode.validity = this.txtvalidity.Value; mode.py = this.txtpy.Value; bll.Add(mode); } /// /// 文件上传 /// /// 上传文件名称 private void UpFiles(string filename) { if (FileUpload1.PostedFile.FileName != null) { try { #region if (FileUpload1.PostedFile.ContentLength > 1024 * 1024 * 6) { Response.Write(""); } else { #region string filetype = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName).ToUpper(); if (filetype == ".JPG") { string m_SavePath = Server.MapPath("../../Upload/drugimg/") + filename; FileUpload1.PostedFile.SaveAs(m_SavePath); //Response.Write(""); this.Add(filename); } else { Response.Write(""); } #endregion } #endregion } catch (Exception m_Ex) { Response.Write(""); } } } /// /// 绑定父类别 /// private void SetDDL() { Jpsoft.Hospital.BLL.jp_drugtype bll = new Com.Jpsoft.Hospital.BLL.jp_drugtype(); DataTable dt = bll.GetList(" fatherid=0 ").Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { DropDownList1.Items.Add(new ListItem(dt.Rows[i]["typename"].ToString(), dt.Rows[i]["id"].ToString())); } DropDownList1.Items.Insert(0, new ListItem("--请选择一级类别--", "0")); } /// /// 绑定子类别 /// private void SetDDLChild(string id) { DropDownList2.Items.Clear(); if (DropDownList1.SelectedValue!="0") { Jpsoft.Hospital.BLL.jp_drugtype bll = new Com.Jpsoft.Hospital.BLL.jp_drugtype(); DataTable dt = bll.GetList(" fatherid='" + id + "' ").Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { DropDownList2.Items.Add(new ListItem(dt.Rows[i]["typename"].ToString(), dt.Rows[i]["id"].ToString())); } } DropDownList2.Items.Insert(0, new ListItem("--请选择一级类别--", "0")); } #endregion } }