using System; using System.Collections.Generic; //using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; // using System.Text; using System.Data; using System.Web.UI.HtmlControls; namespace Com.Jpsoft.Hospital.Web.Module.ExamineInfo.jp_examine_record { public partial class Insert : Com.Jpsoft.Hospital.Web.Common.BasePage { Com.Jpsoft.Hospital.BLL.jp_examine_record record = new Com.Jpsoft.Hospital.BLL.jp_examine_record(); Com.Jpsoft.Hospital.Model.jp_examine_record recordmodel = new Com.Jpsoft.Hospital.Model.jp_examine_record(); Com.Jpsoft.Hospital.BLL.jp_examine_detailinfo detail = new Com.Jpsoft.Hospital.BLL.jp_examine_detailinfo(); Com.Jpsoft.Hospital.Model.jp_examine_detailinfo detailmodel = new Com.Jpsoft.Hospital.Model.jp_examine_detailinfo(); Com.Jpsoft.Hospital.BLL.jp_examine_depart depart = new Com.Jpsoft.Hospital.BLL.jp_examine_depart(); Com.Jpsoft.Hospital.Model.jp_examine_depart departmodel = new Com.Jpsoft.Hospital.Model.jp_examine_depart(); Com.Jpsoft.Hospital.BLL.jp_examine_obj obj = new Com.Jpsoft.Hospital.BLL.jp_examine_obj(); Com.Jpsoft.Hospital.Model.jp_examine_obj objmodel = new Com.Jpsoft.Hospital.Model.jp_examine_obj(); Com.Jpsoft.Hospital.BLL.jp_examine_type type = new Com.Jpsoft.Hospital.BLL.jp_examine_type(); Com.Jpsoft.Hospital.Model.jp_examine_type typemodel = new Com.Jpsoft.Hospital.Model.jp_examine_type(); Com.Jpsoft.Hospital.BLL.jp_examine_detailinfo dtlinfo = new Com.Jpsoft.Hospital.BLL.jp_examine_detailinfo(); Com.Jpsoft.Hospital.Model.jp_examine_detailinfo dtlmodel = new Com.Jpsoft.Hospital.Model.jp_examine_detailinfo(); Com.Jpsoft.Hospital.Model.jp_sys_user usermodel = new Com.Jpsoft.Hospital.Model.jp_sys_user(); Com.Jpsoft.Hospital.BLL.jp_sys_user user = new Com.Jpsoft.Hospital.BLL.jp_sys_user(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(Session["UID"].ToString())) { DataTable dt = user.GetList(" user_id=" + int.Parse(Session["UID"].ToString())).Tables[0]; if (dt.Rows.Count > 0) { int recorder = int.Parse(dt.Rows[0]["user_recorder"].ToString()); if (recorder != 0) { departmodel = depart.GetModel(recorder); if (departmodel != null) { //bool isrecorder = bool.Parse(departmodel.depart_isrecorder.ToString()); //if (isrecorder == true) //{ this.lab.Text = departmodel.depart_name.ToString(); this.lblHid.Text = departmodel.depart_id.ToString(); //BindPageData(); ShowDepart(departmodel.depart_recorded.ToString()); //} } } else { Response.Write(""); } } } } } /// /// 显示所有的课室项目信息 /// private void ShowDepart(string part) { //循环所有的科室,找出科室ID string[] departid = part.Split(','); for (int dep = 0; dep < departid.Length; dep++) { int depart_id = int.Parse(departid[dep].ToString()); //int depart_id = int.Parse(this.depart_id.SelectedValue.ToString()); if (depart_id != 0) { DataTable dt = type.GetList(" type_departid=" + depart_id).Tables[0]; if (dt.Rows.Count > 0) { //i循环找出项目数据 for (int i = 0; i < dt.Rows.Count + 1; i++) { //外循环添加一行 HtmlTableRow htr = new HtmlTableRow(); //查找是否有子部门 DataTable child = depart.GetList(" depart_parentid=" + depart_id).Tables[0]; #region if (child.Rows.Count > 0) { //ii循环找出子部门 for (int ii = 0; ii < child.Rows.Count + 1; ii++) { //内循环添加一列 HtmlTableCell htc = new HtmlTableCell(); if (ii == 0) { if (i == 0) {//第一行第一列 if (i < dt.Rows.Count + 1) { htc.Style.Value = "Font-Size:15px;Font-Weight:bold;text-align:center;"; htc.InnerHtml = new Com.Jpsoft.Hospital.BLL.jp_examine_departEx().GetName(depart_id) + "(调查项目)"; htc.Height = "50"; htc.Width = "300"; } else { htc.Style.Value = "Font-Size:15px;Font-Weight:bold;text-align:center;"; htc.InnerText = "意见和建议"; htc.Height = "150"; htc.Width = "300"; } } else {//第一列不是第一行 htc.InnerText = GetObjName(dt.Rows[i - 1]["type_objid"].ToString()); htc.Align = "Left"; } } else { if (i == 0) {//不是第一列第一行,添加子部门 htc.Style.Value = "Font-Size:15px;Font-Weight:bold;text-align:center;"; htc.InnerText = child.Rows[ii - 1]["depart_name"].ToString(); htc.Height = "50"; } else {//不是第一列也不是第一行,添加评价 if (i < dt.Rows.Count + 1) { string str = " 满意    不满意 
"; htc.Align = "Left"; htc.InnerHtml = str; } else { string str = ""; htc.Align = "Left"; htc.InnerHtml = str; } } } htr.Controls.Add(htc); } tab.Controls.Add(htr); } #endregion #region //说明没有子部门,则只显示评价 else { for (int iii = 0; iii < 2; iii++) { HtmlTableCell htc = new HtmlTableCell(); if (i == 0) { //第一行,第一列 if (iii == 0) { htc.Style.Value = "Font-Size:15px;Font-Weight:bold;text-align:center;"; htc.InnerText = new Com.Jpsoft.Hospital.BLL.jp_examine_departEx().GetName(depart_id) + "(调查项目)"; htc.Height = "50"; htc.Width = "300"; } //第一行,非第一列 else { htc.Style.Value = "Font-Size:15px;Font-Weight:bold;text-align:center;"; htc.InnerText = "评价"; htc.Height = "50"; } } else { if (iii == 0) { htc.InnerText = GetObjName(dt.Rows[i - 1]["type_objid"].ToString()); htc.Align = "Left"; } else { string str = " 满意    不满意 
"; htc.Align = "Left"; htc.InnerHtml = str; } } htr.Controls.Add(htc); } } #endregion tab.Controls.Add(htr); } HtmlTableRow trYJ = new HtmlTableRow(); HtmlTableCell tdYJ1 = new HtmlTableCell(); HtmlTableCell tdYJ2 = new HtmlTableCell(); tdYJ1.InnerText = "意见和建议"; tdYJ2.InnerHtml = ""; trYJ.Controls.Add(tdYJ1); trYJ.Controls.Add(tdYJ2); tab.Controls.Add(trYJ); } } } } /// /// 绑定下拉框数据 /// //private void BindPageData() //{ //获得父科室名称 // string strWhere = " depart_parentid=0"; // DataTable dt = depart.GetList(strWhere).Tables[0]; // if (dt.Rows.Count > 0) // { // for (int i = 0; i < dt.Rows.Count; i++) // { // this.depart_id.Items.Add(new ListItem(dt.Rows[i]["depart_name"].ToString(), dt.Rows[i]["depart_id"].ToString())); // } // this.depart_id.Items.Insert(0, new ListItem("==请选择被调查的科室==", "0")); // } //} //显示评价信息 //protected void depart_id_SelectedIndexChanged(object sender, EventArgs e) //{ //} /// /// 提交数据 /// /// /// protected void btnOK_Click(object sender, EventArgs e) { string did = this.lblHid.Text.Trim(); DateTime time = Convert.ToDateTime(this.record_time.Text); Com.Jpsoft.Hospital.BLL.jp_examine_recordEx bll = new BLL.jp_examine_recordEx(); DataTable dttemp = bll.GetList(" record_pjdepartname='" + did + "' and record_time>='" + time.ToString("yyyy-MM-01") + "' and record_time<'" + time.AddMonths(1).ToString("yyyy-MM-01") + "' ").Tables[0]; if (dttemp.Rows.Count > 0) { Response.Write(""); return; } //提交调查记录信息 if (!string.IsNullOrEmpty(Session["UID"].ToString())) { DataTable dt = user.GetList(" user_id=" + int.Parse(Session["UID"].ToString())).Tables[0]; if (dt.Rows.Count > 0) { int isrecorder = int.Parse(dt.Rows[0]["user_recorder"].ToString()); if (isrecorder != 0) { departmodel = depart.GetModel(isrecorder); if (departmodel != null) { string recored = departmodel.depart_recorded.ToString(); string[] part = recored.Split(','); for (int dep = 0; dep < part.Length; dep++) { int depart_id = int.Parse(part[dep].ToString()); string recordtime = this.record_time.Text; if (depart_id != 0) { DataTable isparent = depart.GetList(" depart_parentid=" + depart_id).Tables[0]; if (isparent.Rows.Count > 0) { for (int i = 0; i < isparent.Rows.Count; i++) { recordmodel.record_departid = int.Parse(isparent.Rows[i]["depart_id"].ToString()); recordmodel.record_time = DateTime.Parse(recordtime).ToString("yyyy-MM-dd HH:mm:ss"); recordmodel.record_createtime = System.DateTime.Now; recordmodel.record_comments = this.record_comments.Text; recordmodel.record_people = dt.Rows[0]["user_name"].ToString(); recordmodel.record_pjdepartname = Convert.ToInt32(dt.Rows[0]["user_recorder"]); recordmodel.record_type = 1; record.Add(recordmodel); //提交调查所有信息 //获得record_id int record_id = GetRecordID(int.Parse(isparent.Rows[i]["depart_id"].ToString()), DateTime.Parse(recordtime).ToString("yyyy-MM-dd HH:mm:ss"), new Com.Jpsoft.Hospital.BLL.jp_sys_userEx().getusername(int.Parse(Session["uid"].ToString())), this.record_comments.Text); foreach (string key in Request.Form.Keys) { if (key.IndexOf("YLFUYJ_") == 0) { //部门ID int departid = int.Parse(key.Split('_')[1].ToString()); //项目ID int objid = int.Parse(key.Split('_')[2].ToString()); //评价ID int view = int.Parse(Request.Form[key].ToString()); if (departid == recordmodel.record_departid) { dtlmodel.detailinfo_objid = objid; dtlmodel.detailinfo_recordid = record_id; dtlmodel.detailinfo_view = view; dtlinfo.Add(dtlmodel); } } } } } else { recordmodel.record_departid = depart_id; recordmodel.record_time = DateTime.Parse(recordtime).ToString("yyyy-MM-dd HH:mm:ss"); recordmodel.record_createtime = System.DateTime.Now; foreach (string key in Request.Form.Keys) { if (key == "PJ_comments_" + depart_id.ToString()) { recordmodel.record_comments = Request.Form[key].ToString(); } } //recordmodel.record_comments = this.record_comments.Text; recordmodel.record_people = new Com.Jpsoft.Hospital.BLL.jp_sys_userEx().getusername(int.Parse(Session["uid"].ToString())); //recordmodel.record_people = dt.Rows[0]["user_name"].ToString(); recordmodel.record_pjdepartname = Convert.ToInt32(dt.Rows[0]["user_recorder"]); recordmodel.record_type = 1; int record_id = record.Add(recordmodel); //提交调查所有信息 //获得record_id //int record_id = GetRecordID(depart_id, DateTime.Parse(recordtime).ToString("yyyy-MM-dd HH:mm:ss"), new Com.Jpsoft.Hospital.BLL.jp_sys_userEx().getusername(int.Parse(Session["uid"].ToString())), this.record_comments.Text); foreach (string key in Request.Form.Keys) { if (key.IndexOf("YLFUYJ_") == 0) { // 部门ID int departid = int.Parse(key.Split('_')[1].ToString()); // 项目ID int objid = int.Parse(key.Split('_')[2].ToString()); //评价 int view = int.Parse(Request.Form[key].ToString()); if (departid == depart_id) { dtlmodel.detailinfo_view = view; dtlmodel.detailinfo_recordid = record_id; dtlmodel.detailinfo_objid = objid; dtlinfo.Add(dtlmodel); } } } } } } Response.Write(""); } } } } } public string GetDepartmentName(int id) { Com.Jpsoft.Hospital.Model.jp_examine_depart model = new Com.Jpsoft.Hospital.Model.jp_examine_depart(); Com.Jpsoft.Hospital.BLL.jp_examine_departEx bll = new Com.Jpsoft.Hospital.BLL.jp_examine_departEx(); model = bll.GetModel(id); if (model != null) { return model.depart_name; } return ""; } /// /// 获得项目名称 /// /// /// public string GetObjName(string obj_id) { if (string.IsNullOrEmpty(obj_id)) { } else { int objid = 0; if (int.TryParse(obj_id, out objid)) { objmodel = obj.GetModel(objid); if (objmodel != null) { if (objmodel.obj_id > 0) { return objmodel.obj_name.ToString(); } } } } return ""; } /// /// 获得record_id /// /// public int GetRecordID(int depart_id, string name, string username, string comments) { StringBuilder strWhere = new StringBuilder(); strWhere.Append(" record_departid=" + depart_id); strWhere.Append(" and record_time='" + name + "'"); strWhere.Append(" and record_people='" + username + "'"); strWhere.Append(" and record_comments='" + comments + "'"); DataTable table = record.GetList(strWhere.ToString()).Tables[0]; if (table.Rows.Count > 0) { return int.Parse(table.Rows[0]["record_id"].ToString()); } else return 0; } /// /// 返回 /// /// /// protected void btnBack_Click(object sender, EventArgs e) { Response.Redirect("List.aspx"); } protected void btnGoOn_Click(object sender, EventArgs e) { //提交调查记录信息 if (!string.IsNullOrEmpty(Session["UID"].ToString())) { DataTable dt = user.GetList(" user_id=" + int.Parse(Session["UID"].ToString())).Tables[0]; if (dt.Rows.Count > 0) { int isrecorder = int.Parse(dt.Rows[0]["user_recorder"].ToString()); if (isrecorder != 0) { departmodel = depart.GetModel(isrecorder); if (departmodel != null) { string recored = departmodel.depart_recorded.ToString(); string[] part = recored.Split(','); for (int dep = 0; dep < part.Length; dep++) { int depart_id = int.Parse(part[dep].ToString()); string recordtime = this.record_time.Text; if (depart_id != 0) { DataTable isparent = depart.GetList(" depart_parentid=" + depart_id).Tables[0]; if (isparent.Rows.Count > 0) { for (int i = 0; i < isparent.Rows.Count; i++) { recordmodel.record_departid = int.Parse(isparent.Rows[i]["depart_id"].ToString()); recordmodel.record_time = DateTime.Parse(recordtime).ToString("yyyy-MM-dd HH:mm:ss"); recordmodel.record_createtime = System.DateTime.Now; recordmodel.record_comments = this.record_comments.Text; recordmodel.record_type = 1; record.Add(recordmodel); //提交调查所有信息 //获得record_id int record_id = GetRecordID(int.Parse(isparent.Rows[i]["depart_id"].ToString()), DateTime.Parse(recordtime).ToString("yyyy-MM-dd HH:mm:ss"), new Com.Jpsoft.Hospital.BLL.jp_sys_userEx().getusername(int.Parse(Session["uid"].ToString())), this.record_comments.Text); foreach (string key in Request.Form.Keys) { if (key.IndexOf("YLFUYJ_") == 0) { //部门ID int departid = int.Parse(key.Split('_')[1].ToString()); //项目ID int objid = int.Parse(key.Split('_')[2].ToString()); //评价ID int view = int.Parse(Request.Form[key].ToString()); if (departid == recordmodel.record_departid) { dtlmodel.detailinfo_objid = objid; dtlmodel.detailinfo_recordid = record_id; dtlmodel.detailinfo_view = view; dtlinfo.Add(dtlmodel); } } } } } else { recordmodel.record_departid = depart_id; recordmodel.record_time = DateTime.Parse(recordtime).ToString("yyyy-MM-dd HH:mm:ss"); recordmodel.record_createtime = System.DateTime.Now; recordmodel.record_comments = this.record_comments.Text; recordmodel.record_type = 1; recordmodel.record_people = new Com.Jpsoft.Hospital.BLL.jp_sys_userEx().getusername(int.Parse(Session["uid"].ToString())); record.Add(recordmodel); //提交调查所有信息 //获得record_id int record_id = GetRecordID(depart_id, DateTime.Parse(recordtime).ToString("yyyy-MM-dd HH:mm:ss"), new Com.Jpsoft.Hospital.BLL.jp_sys_userEx().getusername(int.Parse(Session["uid"].ToString())), this.record_comments.Text); foreach (string key in Request.Form.Keys) { if (key.IndexOf("YLFUYJ_") == 0) { // 部门ID int departid = int.Parse(key.Split('_')[1].ToString()); // 项目ID int objid = int.Parse(key.Split('_')[2].ToString()); //评价 int view = int.Parse(Request.Form[key].ToString()); if (departid == depart_id) { dtlmodel.detailinfo_view = view; dtlmodel.detailinfo_recordid = record_id; dtlmodel.detailinfo_objid = objid; dtlinfo.Add(dtlmodel); } } } } } } Response.Write(""); } } } } } } }