123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- 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 Update : Com.Jpsoft.Hospital.Web.Common.BasePage//System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- SetDDL();
-
- if (Request.Params["id"] != null || Request.Params["id"].Trim() != "")
- {
- string id = Request.Params["id"];
- ShowInfo(int.Parse(id));
- }
- }
- }
- 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);
- }
- if (Request.Params["id"] != null || Request.Params["id"].Trim() != "")
- {
- string id = Request.Params["id"];
- UpData(int.Parse(id), filename);
- }
- //this.Add();
- Response.Write("<script>alert('更新成功!');window.navigate('List.aspx')</script>");
- }
- catch
- {
- Response.Write("<script>alert('数据更新失败!');</script>");
- }
- }
- #region
- /// <summary>
- /// 显示药品详情
- /// </summary>
- /// <param name="id"></param>
- private void ShowInfo(int id)
- {
- Com.Jpsoft.Hospital.BLL.jp_druginfo bll = new Com.Jpsoft.Hospital.BLL.jp_druginfo();
- Com.Jpsoft.Hospital.Model.jp_druginfo model = bll.GetModel(id);
- this.txtdrugname.Value = model.drugname;
- this.txtbusinessname.Value = model.businessname;
-
- Com.Jpsoft.Hospital.BLL.jp_drugtype tpbll = new Com.Jpsoft.Hospital.BLL.jp_drugtype();
- Com.Jpsoft.Hospital.Model.jp_drugtype tpmode = tpbll.GetModel(model.drugtype);
- DropDownList1.SelectedValue = tpmode.fatherid.ToString();
- SetDDLChild(tpmode.fatherid.ToString());
- this.DropDownList2.SelectedValue = model.drugtype.ToString();
- this.txtapprovalnumber.Value = model.approvalnumber;
- this.txtstandard.Value = model.standard;
- this.txtmanufacturer.Value = model.manufacturer;
- this.txtcompany.Value = model.company;
- this.txtintroduction.Value = model.introduction;
- this.txtgoodinfo.Value = model.goodinfo;
- //this.txtimgpath.Value = model.imgpath;
- this.txtingredients.Value = model.ingredients;
- this.txttraits.Value = model.traits;
- this.txtusedosage.Value = model.usedosage;
- this.txtdrugaffect.Value = model.drugaffect;
- this.txtfunctions.Value = model.functions;
- this.txtbadreaction.Value = model.badreaction;
- this.txttaboo.Value = model.taboo;
- this.txtnotice.Value = model.notice;
- this.txtvalidity.Value = model.validity;
- this.txtpy.Value = model.py;
- }
- private void UpData(int id,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 = this.FileUpload1.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;
- mode.id = id;
- if (FileUpload1.PostedFile.FileName != null && FileUpload1.PostedFile.FileName.ToString() != "")
- {
- mode.imgpath = filename;
- }
- else
- {
- Com.Jpsoft.Hospital.Model.jp_druginfo model = bll.GetModel(id);
- mode.imgpath = model.imgpath;
- }
- bll.Update(mode);
- }
- /// <summary>
- /// 文件上传
- /// </summary>
- /// <param name="path">上传文件名称</param>
- private void UpFiles(string filename)
- {
-
- if (FileUpload1.PostedFile.FileName != null)
- {
- try
- {
- #region
- if (FileUpload1.PostedFile.ContentLength > 1024 * 1024 * 6)
- {
- Response.Write("<script>alert('文件不能超过规定大小!');</script>");
- }
- 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("<script>alert('文件保存成功!');</script>");
- }
- else
- {
- Response.Write("<script>alert('文件格式不正确,请选择JPG文件!');</script>");
- }
- #endregion
- }
- #endregion
- }
- catch (Exception m_Ex)
- {
- Response.Write("<script>alert('文件上传失败!');</script>");
- }
- }
- }
- /// <summary>
- /// 绑定父类别
- /// </summary>
- 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"));
- }
- /// <summary>
- /// 绑定子类别
- /// </summary>
- private void SetDDLChild(string id)
- {
- string where = string.Empty;
- if (id != "" )
- {
- where = " fatherid='" + 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(where).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
-
-
- }
- }
|