/// <summary> /// 根据传递的ID获取医疗机构详细信息 /// </summary> public void BindModel() { try { if (Request.QueryString["ID"] != null) { string connectionString = ConfigurationManager.ConnectionStrings["YZConnString"].ConnectionString; var dbFactory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider); using (var db = dbFactory.Open()) { string hid = Request.QueryString["ID"].ToString(); YZ_Hospital hModel = db.SingleById <YZ_Hospital>(hid); txtHCode.Text = hModel.HCode; txtHName.Text = hModel.HName; ddlProvince.SelectedValue = hModel.Data03; ddlUrban.SelectedValue = hModel.Data04; } if (Request.QueryString["IsEdit"] != null && Request.QueryString["IsEdit"] == "2") { } if (Request.QueryString["IsEdit"] != null && Request.QueryString["IsEdit"] == "3") { txtHCode.Enabled = false; txtHName.Enabled = false; ddlProvince.Enabled = false; ddlUrban.Enabled = false; btnSave.Visible = false; } } } catch (Exception ex) { Logger.Log.Error("编辑医疗机构:" + ex.Message, ex); } }
protected void lbtnDel_Command(object sender, CommandEventArgs e) { try { string connectionString = ConfigurationManager.ConnectionStrings["YZConnString"].ConnectionString; var dbFactory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider); using (var db = dbFactory.Open()) { YZ_Hospital faq = db.SingleById <YZ_Hospital>(e.CommandName); if (faq != null) { faq.IsEnable = false; db.Update(faq); BindRepeater(); RemoveAllCache("_LoginInit"); } } } catch (Exception ex) { Logger.Log.Error(ex.Message, ex); } }
/// <summary> /// 保存,编辑医疗机构 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { string connectionString = ConfigurationManager.ConnectionStrings["YZConnString"].ConnectionString; var dbFactory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider); using (var db = dbFactory.Open()) { if (Request.QueryString["ID"] == null) //添加医疗机构 { YZ_Hospital hModel = new YZ_Hospital(); if (ddlProvince.SelectedValue != "0") { if (ddlUrban.SelectedValue != "0") { hModel.HID = Guid.NewGuid().ToString("N"); hModel.HCode = txtHCode.Text; hModel.HName = txtHName.Text; hModel.Data03 = ddlProvince.SelectedValue; hModel.Data04 = ddlUrban.SelectedValue; hModel.HCreated = DateTime.Now; hModel.IsEnable = true; db.Insert(hModel); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>ClosePage(1);</script>"); } else { ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>alert('请选择“省”!')</script>"); return; } } else { ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>alert('请选择“省”!')</script>"); return; } } else //编辑医疗机构 { string hid = Request.QueryString["ID"].ToString(); YZ_Hospital hModel = db.SingleById <YZ_Hospital>(hid); if (hModel != null) { if (ddlProvince.SelectedValue != "0") { if (ddlUrban.SelectedValue != "0") { hModel.HCode = txtHCode.Text; hModel.HName = txtHName.Text; hModel.Data03 = ddlProvince.SelectedValue; hModel.Data04 = ddlUrban.SelectedValue; db.Update(hModel); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>ClosePage(2);</script>"); } else { ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>alert('请选择“省”!')</script>"); return; } } else { ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>alert('请选择“省”!')</script>"); return; } } } } } catch (Exception ex) { Logger.Log.Error("医疗机构管理:" + ex.Message, ex); } }