123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540 |
- 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("<script>alert('该部门不是参评部门!');window.location.href='List.aspx';</script>");
- }
- }
- }
- }
- }
- /// <summary>
- /// 显示所有的课室项目信息
- /// </summary>
- 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 = "<input id='rb1' type='radio' name='" + "YLFUYJ_" + child.Rows[ii - 1]["depart_id"].ToString() + "_" + dt.Rows[i - 2]["type_objid"].ToString() + "' value='1' checked='checked'> 满意 </input> <input id='rb2' type='radio' name='" + "YLFUYJ_" + child.Rows[ii - 1]["depart_id"].ToString() + "_" + dt.Rows[i - 2]["type_objid"].ToString() + "' value='2'> 不满意 </input><br/>";
- htc.Align = "Left";
- htc.InnerHtml = str;
- }
- else
- {
- string str = "<input id='txt1' type='text' name='" + "YLFUYJ_" + child.Rows[ii - 1]["depart_id"].ToString() + "_" + dt.Rows[i - 2]["type_objid"].ToString() + "' />";
- 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 = "<input id='rb1' type='radio' name='" + "YLFUYJ_" + depart_id.ToString() + "_" + dt.Rows[i - 1]["type_objid"].ToString() + "' value='1' checked='checked'> 满意 </input> <input id='rb2' type='radio' name='" + "YLFUYJ_" + depart_id.ToString() + "_" + dt.Rows[i - 1]["type_objid"].ToString() + "' value='2'> 不满意 </input><br/>";
- 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 = "<textarea name='PJ_comments_" + depart_id.ToString() + "' rows='2' cols='20' id='record_comments' style='height:100px;width:500px;'></textarea>";
- trYJ.Controls.Add(tdYJ1);
- trYJ.Controls.Add(tdYJ2);
- tab.Controls.Add(trYJ);
- }
- }
- }
- }
- /// <summary>
- /// 绑定下拉框数据
- /// </summary>
- //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)
- //{
- //}
- /// <summary>
- /// 提交数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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("<script>alert('您这个月已经评价过了!')</script>");
- 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("<script>alert('添加成功!');location.href='List.aspx';</script>");
- }
- }
- }
- }
- }
- 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 "";
- }
- /// <summary>
- /// 获得项目名称
- /// </summary>
- /// <param name="obj_id"></param>
- /// <returns></returns>
- 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 "";
- }
- /// <summary>
- /// 获得record_id
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 返回
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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("<script>alert('添加成功!');</script>");
- }
- }
- }
- }
- }
- }
- }
|