protected void btnSave_Click(object sender, EventArgs e) { try { Dicttestitem item = new Dicttestitem(); Dicttestitem itemtest = new Dicttestitem();//修改前的信息 用作日志 //List<Dicttestitem> testitemList = BindTestItemAll();//所有单项的集合 List <Dicttestitem> dicttestitemList = new List <Dicttestitem>(); if (txtUniQueid.Text.Trim() == "") { MessageBoxShow("全国统一码不能为空!"); return; } if (txtEngName.Text.Trim() == "") { MessageBoxShow("英文缩写不能为空!"); return; } if (txtItemCode.Text.Trim() == "") { MessageBoxShow("项目代码不能为空!"); return; } if (txtEngLongName.Text.Trim() == "") { MessageBoxShow("英文全称不能为空!"); return; } if (txtTestName.Text.Trim() == "") { MessageBoxShow("项目名称不能为空!"); return; } if (txtPrintOrder.Text.Trim() == "") { MessageBoxShow("打印次序不能为空!"); return; } if (txtFastCode.Text.Trim() == "") { MessageBoxShow("助记符不能为空!"); return; } if (txtLabelNumber.Text.Trim() == "") { MessageBoxShow("标签份数不能为空!"); return; } if (txtStandardPrice.Text.Trim() == "") { MessageBoxShow("标准价格不能为空!"); return; } if (ddlforsex.SelectedValue == "-1") { MessageBoxShow("测试项性别不能为空!"); return; } if (ddlforsex.SelectedValue == "-1") { MessageBoxShow("测试项性别不能为空!"); return; } if (ddlResultType.SelectedValue == "-1") { MessageBoxShow("结果类型不能为空!"); return; } if (ddlReportTemplate.SelectedValue == "-1") { MessageBoxShow("报告模板不能为空!"); return; } if (ViewState["TestItemID"] != null) { double?id = Convert.ToDouble(ViewState["TestItemID"]); //item = (from Dicttestitem in testitemList where Dicttestitem.Dicttestitemid == id select Dicttestitem).ToList<Dicttestitem>()[0]; item = testitemservice.SelectDicttestitemByDicttestitemid(id); itemtest = item; Hashtable ht = new Hashtable(); ht.Add("Uniqueid", txtUniQueid.Text.Trim()); ht.Add("Dicttestitemid", id); dicttestitemList = new DicttestitemService().GetDicttestitemByCode(ht); } else { Hashtable ht = new Hashtable(); ht.Add("Uniqueid", txtUniQueid.Text.Trim()); dicttestitemList = new DicttestitemService().GetDicttestitemByCode(ht); } if (dicttestitemList.Count > 0) { MessageBoxShow("已存在相同的全国统一码!"); return; } item.Uniqueid = txtUniQueid.Text.Trim(); item.Engname = txtEngName.Text.Trim(); item.Testcode = txtItemCode.Text.Trim(); item.Englongname = txtEngLongName.Text.Trim(); item.Testname = txtTestName.Text.Trim(); item.Unit = txtUnit.Text.Trim(); item.Fastcode = txtFastCode.Text.Trim(); item.Dictcontainerid = Convert.ToDouble(ddlContainerType.SelectedValue); //试管类型 item.Dictreporttemplateid = Convert.ToDouble(ddlReportTemplate.SelectedValue); //报告模板 item.Dictspecimentypeid = Convert.ToDouble(ddlSpecimenType.SelectedValue); //标本类型 item.Dictlabdeptid = Convert.ToDouble(ddlPhysicalGourp.SelectedValue); //物理组 item.Tubegroup = ddlTubeGroup.SelectedValue.ToString(); //分管原则 item.Precision = txtPrecision.Text.Trim() == "" ? 0 : Convert.ToDouble(txtPrecision.Text.Trim()); item.Forsex = ddlforsex.SelectedValue; item.Resulttype = ddlResultType.SelectedValue; item.Defaultresult = txtDefaultResult.Text.Trim(); item.Refmethod = ddlRefmethod.SelectedValue; item.Price = Convert.ToDouble(txtStandardPrice.Text.Trim());//价格 item.Limithigh = txtLimitHight.Text == "" ? 0 : Convert.ToDouble(txtLimitHight.Text.Trim()); item.Limitlow = txtLimiLow.Text == "" ? 0 : Convert.ToDouble(txtLimiLow.Text.Trim()); item.Labelnumber = txtLabelNumber.Text == "" ? 0 : Convert.ToDouble(txtLabelNumber.Text.Trim()); item.Displayorder = txtPrintOrder.Text == "" ? 0 : Convert.ToDouble(txtPrintOrder.Text.Trim()); //打印排序 item.Testtype = "0"; //单项 item.Operationremark = txtOperationRemark.Text.Trim(); //操作指引说明 if (chbActive.Checked) { item.Active = "1"; } else { item.Active = "0"; } if (chbBillable.Checked) { item.Billable = "1"; } else { item.Billable = "0"; } if (chbReport.Checked) { item.Report = "1"; } else { item.Report = "0"; } if (chbImportanttest.Checked) { item.Isimportant = "1"; } else { item.Isimportant = "0"; } if (chbIsonlyForBill.Checked) { item.Isonlyforbill = "1"; } else { item.Isonlyforbill = "0"; } //if (item.Dicttestitemid != null) //{ // itemtest = (from Dicttestitem in testitemList where Dicttestitem.Dicttestitemid == item.Dicttestitemid select Dicttestitem).ToList<Dicttestitem>()[0]; //} double?f = testitemservice.SaveDictTestItem(item, itemtest); //新增、修改操作 if (f > 0) { item.Dicttestitemid = f; ViewState["TestItemID"] = f; CacheHelper.RemoveAllCache("daan.GetDicttestitem"); MessageBoxShow("新增项目成功!此项目在康源系统未做对照,需做完项目对照才可开单,请及时对照!"); BindSearchData(); //项目可选结果 //BindTestResult(item.Dicttestitemid); // AddTestItem();//清空 } else if (f == 0) { CacheHelper.RemoveAllCache("daan.GetDicttestitem"); Hashtable htPara = new Hashtable(); htPara.Add("olduniquecode", txtUniQueid.Text.Trim()); //htPara.Add("testname", txtTestName.Text.Trim()); if (new daan.service.ProjectControlService().GetProjectControlCountByUniquecode(htPara)) { MessageBoxShow("修改成功!"); } else { MessageBoxShow("修改成功!修改后的项目在康源系统未做对照,需做完项目对照才可开单,请及时对照!"); } BindSearchData(); //项目可选结果 //BindTestResult(item.Dicttestitemid); // AddTestItem();//清空 } else { MessageBoxShow("操作出错!"); } } catch (Exception ex) { MessageBoxShow(string.Format("保存数据出错,错误原因:{0}", ex.Message)); } }
//private void BindSearchData() //{ // List<Dicttestitem> testitemLst = GetGroupTestItemByC(); // gdGroupTestItem.DataSource = testitemLst; // gdGroupTestItem.DataBind(); //} //public List<Dicttestitem> GetGroupTestItemByC() //{ // List<Dicttestitem> testitemgoutpLst = BindTestGourp();//所有组合项目 // List<Dicttestitem> testitemLst = new List<Dicttestitem>(); // double? Dictlabdeptid = Convert.ToDouble(ddlgoupLibrary.SelectedValue); // if (Dictlabdeptid == -1) // { // testitemLst = testitemgoutpLst; // } // else // { // testitemLst = (from Dicttestitem in testitemgoutpLst where Dicttestitem.Dictlabdeptid == Dictlabdeptid select Dicttestitem).ToList<Dicttestitem>(); // } // string testitemStr = ttbSearch.Text; // List<Dicttestitem> newslist = new List<Dicttestitem>(); // foreach (Dicttestitem item in testitemLst) // { // if ((item.Fastcode != null && item.Fastcode.ToLower().Contains(testitemStr.ToLower())) || // (item.Engname != null && item.Engname.ToLower().Contains(testitemStr.ToLower())) || // (item.Testname != null && item.Testname.ToLower().Contains(testitemStr.ToLower())) || // (item.Testcode != null && item.Testcode.ToLower().Contains(testitemStr.ToLower())) || // (item.Uniqueid != null && item.Uniqueid.ToLower().Contains(testitemStr.ToLower())) || // (item.Englongname != null && item.Englongname.ToLower().Contains(testitemStr.ToLower())) // || testitemStr == "") // { // newslist.Add(item); // } // } // return newslist; //} #endregion #region 保存组合信息 protected void btnSave_Click(object sender, EventArgs e) { try { if (ddlPhysicalGourp.SelectedValue == "-1") { MessageBoxShow("请选择物理组!"); return; } if (ddlSpecimenType.SelectedValue == "-1") { MessageBoxShow("请选择标本类型!"); return; } if (ddlTubeGroup.SelectedValue == "-1") { MessageBoxShow("请选择分管原则!"); return; } if (txtGroupTestCode.Text.Trim() == "") { MessageBoxShow("请填写组合代码名称"); return; } if (txtGroupTestName.Text.Trim() == "") { MessageBoxShow("请填写组合名称"); return; } if (txtFastCode.Text.Trim() == "") { MessageBoxShow("请填写助记符名称"); return; } if (nbbStandardPrice.Text.Trim() == "") { MessageBoxShow("请填写标准价格"); return; } if (txtUniQueid.Text.Trim() == "") { MessageBoxShow("请填写全国统一码"); return; } Dicttestitem item = new Dicttestitem(); Dicttestitem testitem = new Dicttestitem();//日志操作,旧值 List <Dicttestitem> dicttestitemList = new List <Dicttestitem>(); //List<Dicttestitem> testitemgoutpLst = BindTestGourp();//所有组合项目 if (ViewState["TestItemID"] != null) { double?id = Convert.ToDouble(ViewState["TestItemID"]); //item = (from Dicttestitem in testitemgoutpLst where Dicttestitem.Dicttestitemid == id select Dicttestitem).ToList<Dicttestitem>()[0]; item = testitemservice.SelectDicttestitemByDicttestitemid(id); testitem = item; Hashtable ht = new Hashtable(); ht.Add("Uniqueid", txtUniQueid.Text.Trim()); ht.Add("Dicttestitemid", id); dicttestitemList = new DicttestitemService().GetDicttestitemByCode(ht); } else { Hashtable ht = new Hashtable(); ht.Add("Uniqueid", txtUniQueid.Text.Trim()); dicttestitemList = new DicttestitemService().GetDicttestitemByCode(ht); } if (dicttestitemList.Count > 0) { MessageBoxShow("已存在相同的全国统一码!"); return; } item.Fastcode = txtFastCode.Text.Trim(); item.Testcode = txtGroupTestCode.Text.Trim(); item.Testname = txtGroupTestName.Text.Trim(); item.Operationremark = txtOperationRemark.Text.Trim(); item.Price = Convert.ToDouble(nbbStandardPrice.Text.Trim()); item.Uniqueid = txtUniQueid.Text.Trim(); item.Dictlabdeptid = Convert.ToDouble(ddlPhysicalGourp.SelectedValue); item.Dictspecimentypeid = Convert.ToDouble(ddlSpecimenType.SelectedValue); item.Testtype = "1"; //1,组合 item.Tubegroup = ddlTubeGroup.SelectedValue; //分管原则 item.Displayorder = int.Parse(txtDisplayOrder.Text); if (chbActive.Checked) { item.Active = "1"; } else { item.Active = "0"; } if (chbIsonlyForBill.Checked) { item.Isonlyforbill = "1"; } else { item.Isonlyforbill = "0"; } //if (item.Dicttestitemid != null) //{ // testitem = (from Dicttestitem in testitemgoutpLst where Dicttestitem.Dicttestitemid == item.Dicttestitemid select Dicttestitem).ToList<Dicttestitem>()[0]; //} List <Dicttestitem> listIn = GridlistIn();//包含的项目 int num = 0; int flag = 0; StringBuilder type = new StringBuilder(); for (int i = 0; i < listIn.Count(); i++) { if (listIn[i].Tubegroup != "" && listIn[i].Dictlabdeptid.ToString() != "" && listIn[i].Dictspecimentypeid.ToString() != "") { //if (this.ddlTubeGroup.SelectedValue != listIn[i].Tubegroup || this.ddlPhysicalGourp.SelectedValue != listIn[i].Dictlabdeptid.ToString() || this.ddlSpecimenType.SelectedValue != listIn[i].Dictspecimentypeid.ToString()) if (ddlTubeGroup.SelectedValue != listIn[i].Tubegroup || ddlSpecimenType.SelectedValue != listIn[i].Dictspecimentypeid.ToString()) { num++; type.Append(listIn[i].Testname + ","); } } else { flag++; type.Append(listIn[i].Testname + ","); } } if (flag > 0) { MessageBoxShow(String.Format("{0}分管原则、所属科室、标本类型都不能为空,请重新维护!", type)); return; } if (num > 0) { //MessageBoxShow(String.Format("{0}必须与所选分管原则、所属科室、标本类型相同!", type)); MessageBoxShow(String.Format("{0}必须与所选分管原则、标本类型相同!", type)); return; } string strerr = string.Empty; double?f = testitemservice.SaveDictTestItem(item, listIn, testitem, ref strerr); if (f > 0) { item.Dicttestitemid = f; ViewState["TestItemID"] = f; CacheHelper.RemoveAllCache("daan.GetDicttestitem"); //删除项目缓存 CacheHelper.RemoveAllCache("daan.GetDicttestgroupdetail"); //删除项目结果缓存 BindSearchData(); //筛选下的项目 // AddTestGroup();//清空 MessageBoxShow("新增成功!"); } else if (f == 0) { CacheHelper.RemoveAllCache("daan.GetDicttestitem"); //删除项目缓存 CacheHelper.RemoveAllCache("daan.GetDicttestgroupdetail"); //删除项目结果缓存 BindSearchData(); //筛选下的项目 // AddTestGroup();//清空 MessageBoxShow("修改成功!"); } else { MessageBoxShow("操作出错:" + strerr); } } catch (Exception ex) { MessageBoxShow(ex.ToString()); } }