public static void ImportMachineset() { try { string strsql = "select * from Machineset"; string insertsql = "insert into RSet(old,new) values('{0}','{1}')"; ImportSqlServerUtility isql = new ImportSqlServerUtility(); RelationSqlServerUtility rsql = new RelationSqlServerUtility(); DataSet ds = isql.ExecuteSqlDataSet(strsql); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Columns.Count > 0) { CY.CSTS.Core.Business.MACHINESET set = null; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { set = new CY.CSTS.Core.Business.MACHINESET(); set.UnitID = CY.CSTS.Import.Core.Business.UnitInfo.TransferUnitId(ds.Tables[0].Rows[i][0].ToString()); set.LabID = CY.CSTS.Import.Core.Business.Lab.TransferLabId(ds.Tables[0].Rows[i][1].ToString()); set.SETNAME = ds.Tables[0].Rows[i][3].ToString(); set.LINKMAN = ds.Tables[0].Rows[i][4].ToString(); set.GroupInstance = ds.Tables[0].Rows[i][5].ToString(); set.PHONE = ds.Tables[0].Rows[i][6].ToString(); set.FAX = ds.Tables[0].Rows[i][7].ToString(); set.EMAIL = ds.Tables[0].Rows[i][8].ToString(); set.SETMAN = ds.Tables[0].Rows[i][9].ToString(); set.AUDITINGSTATE = !string.IsNullOrEmpty(ds.Tables[0].Rows[i][10].ToString()) && bool.Parse(ds.Tables[0].Rows[i][10].ToString()) ? 1 : 2; set.AUDITINGDATE = !string.IsNullOrEmpty(ds.Tables[0].Rows[i][11].ToString()) ? DateTime.Parse(ds.Tables[0].Rows[i][11].ToString()) : DateTime.MinValue; set.REMARK = ds.Tables[0].Rows[i][12].ToString(); set.WRITEDATE = !string.IsNullOrEmpty(ds.Tables[0].Rows[i][13].ToString()) ? DateTime.Parse(ds.Tables[0].Rows[i][13].ToString()) : DateTime.MinValue; ; set.UPDATEDATE = !string.IsNullOrEmpty(ds.Tables[0].Rows[i][14].ToString()) ? DateTime.Parse(ds.Tables[0].Rows[i][14].ToString()) : DateTime.MinValue; set.Save(); rsql.ExecuteSql(string.Format(insertsql, ds.Tables[0].Rows[i][2].ToString(), set.Id)); } } } catch (Exception ex) { throw ex; } }
protected void BindGv(Guid id) { CY.CSTS.Core.Business.User U = (CY.CSTS.Core.Business.User)Session["User"]; if (U == null) { lbAlert.InnerText = "请登录"; } else { string sqlwhere = "UserID='" + U.Id + "'"; IList<CY.CSTS.Core.Business.MachineGroupMember> memList = CY.CSTS.Core.Business.MachineGroupMember.GetMachineGroupMemberDynamic(sqlwhere, ""); IList<CY.CSTS.Core.Business.MACHINESET> maList = new List<CY.CSTS.Core.Business.MACHINESET>(); if (U.UserType == 2 || U.UserType == 3) { CY.CSTS.Core.Business.MACHINESET mset = new CY.CSTS.Core.Business.MACHINESET(); for (int i = 0; i < memList.Count; i++) { mset = CY.CSTS.Core.Business.MACHINESET.Load(memList[i].MachineGroupID); if (mset != null) { maList.Add(mset); } } } else if (U.UserType == 6 || U.UserType == 7)//单位管理员 { maList = CY.CSTS.Core.Business.MACHINESET.SelectMACHINESETsByAndUnitID(U.UnitID); } gvSur.DataSource = maList; gvSur.DataBind(); int NeedCount = maList.Count; lbNeedAdd.Text = NeedCount.ToString(); int AddCount = 0; int UnCount = 0; for (int i = 0; i < maList.Count; i++) { string sqlstr = "where surveyID='" + id + "' and MACHINESETID='" + maList[i].Id + "'"; IList<CY.CSTS.Core.Business.SurveyTable> sbList = CY.CSTS.Core.Business.SurveyTable.GetSurveyTableBySql(sqlstr); if (sbList.Count == 0||sbList==null) { UnCount++; } } for (int i = 0; i < gvSur.Rows.Count; i++) { string sqlstr = "where surveyID='" + id + "' and MACHINESETID='" + gvSur.DataKeys[i].Value.ToString().Trim() + "'"; IList<CY.CSTS.Core.Business.SurveyTable> sbList = CY.CSTS.Core.Business.SurveyTable.GetSurveyTableBySql(sqlstr); if (sbList != null && sbList.Count != 0) { if (sbList[0].Status == 1) { gvSur.Rows[i].Cells[5].Text = "已保存"; } else if (sbList[0].Status == 2) { gvSur.Rows[i].Cells[5].Text = "已申请"; } else if (sbList[0].Status == 3) { gvSur.Rows[i].Cells[5].Text = "未审核"; } else if (sbList[0].Status == 4) { gvSur.Rows[i].Cells[5].Text = "通过"; } else if (sbList[0].Status == 5) { gvSur.Rows[i].Cells[5].Text = "不通过"; } else if (sbList[0].Status == 6) { gvSur.Rows[i].Cells[5].Text = "驳回修改"; } else if (sbList[0].Status == 7) { gvSur.Rows[i].Cells[5].Text = "关闭"; } } else { gvSur.Rows[i].Cells[5].Text = "未申请"; } } lbUnCount.Text = UnCount.ToString(); AddCount = NeedCount - UnCount; lbAddcount.Text = AddCount.ToString(); //CY.CSTS.Core.Business.MachineGroupMember. } }
protected void btAddGroup_Click(object sender, EventArgs e) { try { CY.CSTS.Core.Business.MACHINESET newMg = new CY.CSTS.Core.Business.MACHINESET(); // 验证 // 单位编号 if (!string.IsNullOrEmpty(tbUnit.Text) && Request.Params["hidUnit"] != null && Request.Params["hidUnit"].ToString() != "") { newMg.UnitID = new Guid(Request.Params["hidUnit"].ToString()); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "<script>alert('单位不能为空')</script>"); return; } // 实验室 //if (!string.IsNullOrEmpty(ddlLabID.SelectedValue)) //if (Request.Form["selLabID"] != null && Request.Form["selLabID"].ToString() != "") //if (Request.QueryString["selLabID"] != null && Request.QueryString["selLabID"].ToString() != "") if (!string.IsNullOrEmpty(hiddenLabID.Text.Trim())) { //newMg.LabID = new Guid(ddlLabID.SelectedValue); //newMg.LabID = new Guid(Request.Form["selLabID"]); //newMg.LabID = new Guid(Request.QueryString["selLabID"].ToString()); newMg.LabID = new Guid(hiddenLabID.Text.Trim()); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "<script>alert('没有选择实验室')</script>"); return; } // 机组编号 if (!string.IsNullOrEmpty(tbSetCode.Text.Trim())) { if (CY.CSTS.Core.Business.MACHINESET.GetAllMACHINESET().Where(item => item.SetCode == tbSetCode.Text.Trim()).ToList<CY.CSTS.Core.Business.MACHINESET>().Count == 0) { newMg.SetCode = tbSetCode.Text.Trim(); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "<script>alert('该机组编号已存在')</script>"); return; } } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "<script>alert('没有写机组编号')</script>"); return; } // 机组名称 if (!string.IsNullOrEmpty(tbSetName.Text.Trim())) { newMg.SETNAME = tbSetName.Text.Trim(); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "<script>alert('没有写机组名称')</script>"); return; } // 机组联系人 if (!string.IsNullOrEmpty(tbLINKMAN.Text.Trim())) { newMg.LINKMAN = tbLINKMAN.Text.Trim(); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "<script>alert('没有写机组名称')</script>"); return; } // 机组特色及承担项目情况 newMg.GroupInstance = tbGroupInstance.Text.Trim(); // 机组电话 //if (!string.IsNullOrEmpty(tbPHONE.Text) && Regex.IsMatch(tbPHONE.Text, @"^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$")) //{ // newMg.PHONE = tbPHONE.Text; //} //else //{ // Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "<script>alert('没有写机组电话或电话格式不对')</script>"); // return; //} // 传真 newMg.FAX = tbFAX.Text.Trim(); // 机组电子邮件 if (!string.IsNullOrEmpty(tbEMAIL.Text.Trim()) && Regex.IsMatch(tbEMAIL.Text.Trim(), @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")) { newMg.EMAIL = tbEMAIL.Text.Trim(); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "<script>alert('没有写电子邮件或电子邮件格式不对')</script>"); return; } // 机组负责人 if (!string.IsNullOrEmpty(tbSETMAN.Text.Trim())) { newMg.SETMAN = tbSETMAN.Text.Trim(); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "", "<script>alert('没有写机组负责人')</script>"); return; } // 审核状态 //newMg.AUDITINGSTATE = Int32.Parse(ddlAUDITINGSTATE.SelectedValue); // 审核人 //newMg.ASSESSOR = tbASSESSOR.Text; // 审核时间 //if (tbAUDITINGDATE.Text.Trim() != "") //{ // newMg.AUDITINGDATE = Convert.ToDateTime(tbAUDITINGDATE.Text); //} //else //{ // newMg.AUDITINGDATE = DateTime.Now; //} // 备注 newMg.REMARK = tbREMARK.Text.Trim(); // 填表日期 if (tbWRITEDATE.Text.Trim() != "") { newMg.WRITEDATE = Convert.ToDateTime(tbWRITEDATE.Text.Trim()); } else { newMg.WRITEDATE = DateTime.Now; } newMg.Save(); CY.CSTS.Core.Business.FreshNews fresh = new CY.CSTS.Core.Business.FreshNews(); fresh.Sponsor = "管理员"; fresh.FreshEvent = "添加机组"; fresh.Embracer = tbUnit.Text; fresh.EmbracerId = newMg.UnitID; fresh.UnitId = newMg.UnitID; fresh.EventType = 4; fresh.EventTime = DateTime.Now; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('新增成功');window.location.href='MachineGroupList.aspx';</script>"); } catch (Exception ex) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('新增失败,"+ex.Message+"');';</script>"); } }
protected void BtnSaveEdit_Click(object sender, EventArgs e) { #region validation if (string.IsNullOrEmpty(tbInstrumentCode.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器编号不能为空!');</script>"); return; } if (string.IsNullOrEmpty(tbUnit.Text) || string.IsNullOrEmpty(hidUnit.Value) || !CY.Utility.Common.StringHelper.IsGuid(hidUnit.Value)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('单位不能为空!');</script>"); return; } if (string.IsNullOrEmpty(tbPersonnal.Text) || string.IsNullOrEmpty(hidPersonnal.Value) || !CY.Utility.Common.StringHelper.IsGuid(hidPersonnal.Value)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器负责人不能为空!');</script>"); return; } if (string.IsNullOrEmpty(tbChineseName.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器中文名称不能为空!');</script>"); return; } if (string.IsNullOrEmpty(tbValueRMB.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器原值不能为空!');</script>"); return; } if (string.IsNullOrEmpty(tbPurchaseDate.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('购进日期不能为空!');</script>"); return; } string machineClass = string.Empty; if (ddlMachineBigClass.SelectedValue != "0" && !string.IsNullOrEmpty(Request.Form["ddlMachineMiddleClass"]) && !string.IsNullOrEmpty(Request.Form["ddlMachineSmallClass"])) { machineClass = Request.Form["ddlMachineSmallClass"]; } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器分类编号不能为空!');</script>"); return; } if (string.IsNullOrEmpty(ddlProvince.SelectedValue) || ddlProvince.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlProvince.SelectedValue)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器所在省不能为空'!);</script>"); return; } if (string.IsNullOrEmpty(Request.Form["ddlCity"]) || Request.Form["ddlCity"].Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(Request.Form["ddlCity"])) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器所在市不能为空!');</script>"); return; } //if (string.IsNullOrEmpty(ddlGetMode.SelectedValue) || ddlGetMode.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlGetMode.SelectedValue)) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('获取方式不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlWorkState.SelectedValue) || ddlWorkState.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('运行状态不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlUseState.SelectedValue) || ddlUseState.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('使用状态不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlCountry.SelectedValue) || ddlCountry.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlCountry.SelectedValue)) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('国别不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlProduceSort.SelectedValue) || ddlProduceSort.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlProduceSort.SelectedValue)) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器产区类别不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlBudgeSource.SelectedValue) || ddlBudgeSource.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlBudgeSource.SelectedValue)) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器购置经费来源不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlExamination.SelectedValue) || ddlExamination.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlExamination.SelectedValue)) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器检定情况不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlHasCMA.SelectedValue) || ddlHasCMA.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('是否计量认证不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlIsSpecial.SelectedValue) || ddlIsSpecial.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('是否特色仪器不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlTotally.SelectedValue) || ddlTotally.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('是否愿意共用不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlAcceptMission.SelectedValue) || ddlAcceptMission.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('是否接受任务不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlExternalService.SelectedValue) || ddlExternalService.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('是否对外服务不能为空!');</script>"); // return; //} decimal temp = default(decimal); if (!decimal.TryParse(tbValueRMB.Text.Trim(), out temp)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器原值不是数字!');</script>"); return; } if (tbNationalPay.Text != "") { if (!decimal.TryParse(tbNationalPay.Text.Trim(), out temp)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('国拨经费不是数字!');</script>"); return; } } DateTime tempDate = default(DateTime); if (tbDisgardTime.Text != "") { if (!DateTime.TryParse(tbDisgardTime.Text, out tempDate)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('报废年限格式不对!');</script>"); return; } } if (tbProduceDate.Text != "") { if (!DateTime.TryParse(tbProduceDate.Text, out tempDate)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('生产日期格式不对!');</script>"); return; } } if (!DateTime.TryParse(tbPurchaseDate.Text, out tempDate)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('购进日期格式不对!');</script>"); return; } if (!string.IsNullOrEmpty(tbLab.Text) && !string.IsNullOrEmpty(hidLab.Value)) { if (!CY.Utility.Common.StringHelper.IsGuid(hidLab.Value)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('所属实验室输入有误!');</script>"); return; } } if (string.IsNullOrEmpty(tbSetName.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('机组名称不能为空!');</script>"); return; } //if (!string.IsNullOrEmpty(tbMachineGroup.Text) && !string.IsNullOrEmpty(hidMachineGroup.Value)) //{ // if (!CY.Utility.Common.StringHelper.IsGuid(hidMachineGroup.Value)) // { // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('所属机组输入有误!');</script>"); // return; // } //} #endregion try { CY.CSTS.Core.Business.view_INSTRUMENT instrument = CY.CSTS.Core.Business.view_INSTRUMENT.Load(InstrumentID); if (instrument != null) { #region 添加仪器基本信息 //修改仪器用途 string instrumentPurpose = string.Empty; List<CY.CSTS.Core.Business.PURPOSE> purposelist = CY.CSTS.Core.Business.PURPOSE.GetPurposeDynamic(" [InstruId]='" + InstrumentID + "'", "") as List<CY.CSTS.Core.Business.PURPOSE>; foreach (CY.CSTS.Core.Business.PURPOSE p in purposelist) { p.DeleteOnSave(); p.Save(); } for (int i = 0; i < cblPurpose.Items.Count; i++) { if (cblPurpose.Items[i].Selected) { instrumentPurpose += cblPurpose.Items[i].Text; CY.CSTS.Core.Business.PURPOSE purpose = new CY.CSTS.Core.Business.PURPOSE { PURPOSEID = new Guid(cblPurpose.Items[i].Value), InstruId = instrument.Id }; purpose.Save(); } } //修改仪器测试及研究领域 string instrumentDomain = string.Empty; List<CY.CSTS.Core.Business.INSTRREALM> realmlist = CY.CSTS.Core.Business.INSTRREALM.GetInstrrealmDynamic(" [InstruId]='" + InstrumentID + "'", "") as List<CY.CSTS.Core.Business.INSTRREALM>; foreach (CY.CSTS.Core.Business.INSTRREALM rel in realmlist) { rel.DeleteOnSave(); rel.Save(); } for (int i = 0; i < cblRealm.Items.Count; i++) { if (cblRealm.Items[i].Selected) { instrumentDomain += cblRealm.Items[i].Text; CY.CSTS.Core.Business.INSTRREALM instrrealm = new CY.CSTS.Core.Business.INSTRREALM { DomainId = new Guid(cblRealm.Items[i].Value), InstruId = instrument.Id }; instrrealm.Save(); } } //修改仪器信息 instrument.ACCEPTMISSION = int.Parse(ddlAcceptMission.SelectedValue); instrument.ALIAS = tbAlias.Text; instrument.AUDITINGDATE = System.DateTime.Now; instrument.BUGETSOURCE = (ddlBudgeSource.SelectedValue == "0") ? Guid.Empty : new Guid(ddlBudgeSource.SelectedValue); instrument.SITE = new Guid(ddlProvince.SelectedValue); instrument.CITY = new Guid(Request.Form["ddlCity"]); instrument.COUNTRYCODE = (ddlCountry.SelectedValue == "0") ? Guid.Empty : new Guid(ddlCountry.SelectedValue); instrument.DISCARDTIME = (tbDisgardTime.Text == "") ? default(DateTime) : DateTime.Parse(tbDisgardTime.Text); instrument.ENAME = tbEnglishName.Text; instrument.EXAMINATION = (ddlExamination.SelectedValue == "0") ? Guid.Empty : new Guid(ddlExamination.SelectedValue); instrument.EXTERNALSERVICE = int.Parse(ddlExternalService.SelectedValue); instrument.FUNCTIONFEATURES = tbFunctionFeatures.Text; instrument.GETMODE = (ddlGetMode.SelectedValue == "0") ? Guid.Empty : new Guid(ddlGetMode.SelectedValue); instrument.GUIDELINE = tbGuidline.Text; instrument.HasCMA = int.Parse(ddlHasCMA.SelectedValue); instrument.HNAME = tbChineseName.Text; instrument.InstruCode = tbInstrumentCode.Text; instrument.IsSpecial = int.Parse(ddlIsSpecial.SelectedValue); instrument.LaboratoryId = (hidLab.Value == "" || hidLab.Value == null) ? Guid.Empty : new Guid(hidLab.Value); instrument.MANUFACTURE = tbManufacturer.Text; instrument.NATIONALPAY = (tbNationalPay.Text == "") ? default(decimal) : decimal.Parse(tbNationalPay.Text); instrument.PERSONNELID = new Guid(hidPersonnal.Value); instrument.PRODUCEDATE = (tbProduceDate.Text == "") ? default(DateTime) : DateTime.Parse(tbProduceDate.Text); instrument.PRODUCESORT = (ddlProduceSort.SelectedValue == "0") ? Guid.Empty : new Guid(ddlProduceSort.SelectedValue); instrument.PRODUCINGAREA = tbProducingArea.Text; instrument.PURCHASEDATE = DateTime.Parse(tbPurchaseDate.Text); instrument.PURPOSEID = instrumentPurpose; instrument.REALMID = instrumentDomain; instrument.REMARK = tbRemark.Text; instrument.SPECTYPE = tbSpecific.Text; instrument.TOTALLY = int.Parse(ddlTotally.SelectedValue); instrument.UPDATEDATE = System.DateTime.Now; instrument.VALUERMB = decimal.Parse(tbValueRMB.Text); instrument.WorkingforUnitId = new Guid(hidUnit.Value); instrument.WRITEDATE = System.DateTime.Now; instrument.CLASSCODE = machineClass; instrument.UseState = int.Parse(ddlUseState.SelectedValue); instrument.WorkState = int.Parse(ddlWorkState.SelectedValue); try { instrument.Gather = !string.IsNullOrEmpty(ddlGather.SelectedValue) ? int.Parse(ddlGather.SelectedValue) : 0; } catch { } //改变仪器状态 //申请入网状态无修改功能(state=3时) switch (instrument.AUDITINGSTATE) { case 1: instrument.AUDITINGSTATE = 1; break; case 2: instrument.AUDITINGSTATE = 2; break; case 4: instrument.AUDITINGSTATE = 4; break; case 5: instrument.AUDITINGSTATE = 5; break; case 6: instrument.AUDITINGSTATE = 6; break; case 7: instrument.AUDITINGSTATE = 7; break; case 8: instrument.AUDITINGSTATE = 4; break; case 9: instrument.AUDITINGSTATE = 4; break; case 10: instrument.AUDITINGSTATE = 4; break; case 11: instrument.AUDITINGSTATE = 4; break; default: instrument.AUDITINGSTATE = 1; break; } instrument.Save(); //保存修改的仪器图片及视频信息 SaveFiles(instrument.Id); SaveImg(instrument.Id); #endregion #region 修改仪器机组信息 CY.CSTS.Core.Business.MACHINESET machineSet = CY.CSTS.Core.Business.MACHINESET.Load(instrument.MachineGroupId); //机组已存在 if (machineSet != null) { machineSet.UnitID = new Guid(hidUnit.Value); machineSet.LabID = (hidLab.Value == "" || hidLab.Value == null) ? Guid.Empty : new Guid(hidLab.Value); machineSet.SETNAME = tbSetName.Text; machineSet.GroupInstance = tbGroupInstance.Text; machineSet.EMAIL = tbEMAIL.Text; machineSet.FAX = tbFAX.Text; machineSet.LINKMAN = tbLinkMan.Text; machineSet.PHONE = tbPHONE.Text; machineSet.REMARK = tbMachineSetRemark.Text; machineSet.WRITEDATE = System.DateTime.Now; machineSet.UPDATEDATE = System.DateTime.Now; machineSet.SetCode = tbInstrumentCode.Text.Trim(); machineSet.Save(); string[] machineSetUser = Request.Form.GetValues("mgperson"); List<CY.CSTS.Core.Business.MachineGroupMember> mgMember = CY.CSTS.Core.Business.MachineGroupMember.SelectMachineGroupMembersByAndMachineGroupID(machineSet.Id) as List<CY.CSTS.Core.Business.MachineGroupMember>; List<string> tempMachineSetUser = new List<string>(); if (machineSetUser != null && machineSetUser.Count() > 0) { tempMachineSetUser = machineSetUser.ToList(); } //将重复的机组人员ID去掉 if (tempMachineSetUser != null && tempMachineSetUser.Count > 0) { if (mgMember.Count != 0) { foreach (CY.CSTS.Core.Business.MachineGroupMember m in mgMember) { for (int i = 0; i < machineSetUser.Length; i++) { if (m.UserID == new Guid(machineSetUser[i])) { tempMachineSetUser.Remove(machineSetUser[i]); } } } } } if (tempMachineSetUser.Count != 0) { for (int i = 0; i < tempMachineSetUser.Count; i++) { Guid userId = new Guid(tempMachineSetUser[i]); CY.CSTS.Core.Business.MachineGroupMember machineGroupMember = new CY.CSTS.Core.Business.MachineGroupMember { InstruID = instrument.Id, MachineGroupID = machineSet.Id, UserID = userId }; machineGroupMember.Save(); } } } else//机组不存在 { if (!string.IsNullOrEmpty(tbSetName.Text)) { CY.CSTS.Core.Business.MACHINESET machinegroup = new CY.CSTS.Core.Business.MACHINESET(); machinegroup.UnitID = new Guid(hidUnit.Value); machinegroup.LabID = (hidLab.Value == "" || hidLab.Value == null) ? Guid.Empty : new Guid(hidLab.Value); machinegroup.GroupInstance = tbGroupInstance.Text; machinegroup.EMAIL = tbEMAIL.Text; machinegroup.FAX = tbFAX.Text; machinegroup.LINKMAN = tbLinkMan.Text; machinegroup.PHONE = tbPHONE.Text; machinegroup.REMARK = tbMachineSetRemark.Text; machinegroup.WRITEDATE = System.DateTime.Now; machinegroup.UPDATEDATE = System.DateTime.Now; machinegroup.SETNAME = tbSetName.Text; machinegroup.SetCode = tbInstrumentCode.Text.Trim(); machinegroup.Save(); instrument.MachineGroupId = machinegroup.Id; instrument.Save(); if (machinegroup.Id != null && machinegroup.Id != Guid.Empty) { string[] machineSetUser = Request.Form.GetValues("mgperson"); if (machineSetUser != null && machineSetUser.Length != 0) { for (int i = 0; i < machineSetUser.Length; i++) { Guid userId = new Guid(machineSetUser[i]); CY.CSTS.Core.Business.MachineGroupMember machineGroupMember = new CY.CSTS.Core.Business.MachineGroupMember { InstruID = instrument.Id, MachineGroupID = machinegroup.Id, UserID = userId }; machineGroupMember.Save(); } } } } } #endregion /*Tag*/ if (!string.IsNullOrEmpty(tbTag.Text.Trim())) { string tagTemp = tbTag.Text.Trim(); if (tagTemp.Contains(",")) { tagTemp = tagTemp.Replace(",", ","); } else if (tagTemp.Contains(" ")) { tagTemp = tagTemp.Replace(" ", ","); } CY.CSTS.Core.Business.Tag tag = CY.CSTS.Core.Business.Tag.SelectTagsDynamic(" ContentID='" + instrument.Id + "'", ""); if (tag != null) { tag.TagName = tagTemp; tag.Save(); } else { CY.CSTS.Core.Business.Tag tagCore = new CY.CSTS.Core.Business.Tag(); tagCore.ContentType = 1; tagCore.ContentID = instrument.Id; tagCore.TagName = tagTemp; tagCore.Save(); } } } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('修改仪器信息成功!');window.location.href='InstrumentInfo.aspx?Id=" + InstrumentID + "';</script>"); } catch (Exception ex) { throw ex; } }
protected void bindgvAdmiss() { CY.CSTS.Core.Business.User U = (CY.CSTS.Core.Business.User)Session["User"]; if (U == null) { lbErr.Text = "请登录"; } else { if (U.UnitID != null) { string sqlwhere = "UserID='" + U.Id + "'"; IList<CY.CSTS.Core.Business.MachineGroupMember> memList = CY.CSTS.Core.Business.MachineGroupMember.GetMachineGroupMemberDynamic(sqlwhere, ""); IList<CY.CSTS.Core.Business.MACHINESET> maList = new List<CY.CSTS.Core.Business.MACHINESET>(); if (U.UserType == 3) { CY.CSTS.Core.Business.MACHINESET mset = new CY.CSTS.Core.Business.MACHINESET(); for (int i = 0; i < memList.Count; i++) { mset = CY.CSTS.Core.Business.MACHINESET.Load(memList[i].MachineGroupID); maList.Add(mset); } } //获取用户所属机组列表 IList<CY.CSTS.Core.Business.CommissionedApplication> comAppList = new List<CY.CSTS.Core.Business.CommissionedApplication>(); IList<CY.CSTS.Core.Business.CommissionedApplication> applist = new List<CY.CSTS.Core.Business.CommissionedApplication>(); CY.CSTS.Core.Business.UnitInfo unit = CY.CSTS.Core.Business.UnitInfo.Load(U.UnitID); if (unit != null) { string wherecondition = "[AdmissibilityID]='" + unit.Id + "'"; string order = ""; comAppList = CY.CSTS.Core.Business.CommissionedApplication.SelectCommissionedApplicationDynamic(wherecondition, order); //获取单位受理申请列表 if (U.UserType == 6 || U.UserType == 7)//单位 人员有问题 { applist = comAppList; } else if (U.UserType == 3 || U.UserType == 2)//机组 { for (int i = 0; i < comAppList.Count; i++) { if (comAppList[i].InstrumentID != null) { if (CY.CSTS.Core.Business.view_INSTRUMENT.Load(comAppList[i].InstrumentID) != null) { Guid groupId = CY.CSTS.Core.Business.view_INSTRUMENT.Load(comAppList[i].InstrumentID).MachineGroupId;//仪器所属机组ID for (int j = 0; j < maList.Count; j++) { if (maList[j].Id == groupId && comAppList[i].Status != 1)//保存状态 { applist.Add(comAppList[i]); continue; } } } } } } else { tabAdmissibility.Visible = false; lbErr.Text = "您不是机组成员或单位管理员,无权查看委托列表!"; } gvAdmiss.DataSource = applist; gvAdmiss.DataBind(); for (int i = 0; i < gvAdmiss.Rows.Count; i++) { if (applist[i].Status == 2) { gvAdmiss.Rows[i].Cells[7].Text = "未审核"; } else if (applist[i].Status == 3) { gvAdmiss.Rows[i].Cells[7].Text = "受理"; } else if (applist[i].Status == 4) { gvAdmiss.Rows[i].Cells[7].Text = "不受理"; } else if (applist[i].Status == 5) { gvAdmiss.Rows[i].Cells[7].Text = "测试中"; } else if (applist[i].Status == 6) { gvAdmiss.Rows[i].Cells[7].Text = "测试完成"; } } } } else { lbErr.Text = "没有所属单位"; tabAdmissibility.Visible = false; } } }
protected void BtnAddInstrument_Click(object sender, EventArgs e) { #region validation if (Request.Form["ddlCity"] != null && Request.Form["ddlCity"] != "0") { hdDdlCity.Value = Request.Form["ddlCity"];//把城市保留下来 } if (ddlMachineBigClass.SelectedValue != "0" && !string.IsNullOrEmpty(Request.Form["ddlMachineMiddleClass"]) && !string.IsNullOrEmpty(Request.Form["ddlMachineSmallClass"])) { hdMiddleClassID.Value = Request.Form["ddlMachineMiddleClass"];//仪器中类 hdSmallClassID.Value = Request.Form["ddlMachineSmallClass"];//仪器小类 } if (string.IsNullOrEmpty(tbInstrumentCode.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('自建编号不能为空!');</script>"); return; } if (string.IsNullOrEmpty(tbUnit.Text) || string.IsNullOrEmpty(hidUnit.Value) || !CY.Utility.Common.StringHelper.IsGuid(hidUnit.Value)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('单位不能为空!');</script>"); return; } if (string.IsNullOrEmpty(tbPersonnal.Text) || string.IsNullOrEmpty(hidPersonnal.Value) || !CY.Utility.Common.StringHelper.IsGuid(hidPersonnal.Value)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器负责人不能为空!');</script>"); return; } if (string.IsNullOrEmpty(tbChineseName.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器中文名称不能为空!');</script>"); return; } if (string.IsNullOrEmpty(tbValueRMB.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器原值不能为空!');</script>"); return; } if (string.IsNullOrEmpty(tbPurchaseDate.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('购进日期不能为空!');</script>"); return; } string machineClass = string.Empty; if (ddlMachineBigClass.SelectedValue != "0" && !string.IsNullOrEmpty(Request.Form["ddlMachineMiddleClass"]) && !string.IsNullOrEmpty(Request.Form["ddlMachineSmallClass"])) { machineClass = Request.Form["ddlMachineSmallClass"]; } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器分类编号不能为空!');</script>"); return; } if (string.IsNullOrEmpty(ddlProvince.SelectedValue) || ddlProvince.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlProvince.SelectedValue)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器所在省不能为空'!);</script>"); return; } if (string.IsNullOrEmpty(Request.Form["ddlCity"]) || Request.Form["ddlCity"].Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(Request.Form["ddlCity"])) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器所在市不能为空!');</script>"); return; } //if (string.IsNullOrEmpty(ddlGetMode.SelectedValue) || ddlGetMode.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlGetMode.SelectedValue)) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('获取方式不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlWorkState.SelectedValue) || ddlWorkState.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('运行状态不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlUseState.SelectedValue) || ddlUseState.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('使用状态不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlCountry.SelectedValue) || ddlCountry.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlCountry.SelectedValue)) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('国别不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlProduceSort.SelectedValue) || ddlProduceSort.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlProduceSort.SelectedValue)) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器产区类别不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlBudgeSource.SelectedValue) || ddlBudgeSource.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlBudgeSource.SelectedValue)) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器购置经费来源不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlExamination.SelectedValue) || ddlExamination.SelectedValue.Equals("0") || !CY.Utility.Common.StringHelper.IsGuid(ddlExamination.SelectedValue)) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器检定情况不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlHasCMA.SelectedValue) || ddlHasCMA.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('是否计量认证不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlIsSpecial.SelectedValue) || ddlIsSpecial.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('是否特色仪器不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlTotally.SelectedValue) || ddlTotally.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('是否愿意共用不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlAcceptMission.SelectedValue) || ddlAcceptMission.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('是否接受任务不能为空!');</script>"); // return; //} //if (string.IsNullOrEmpty(ddlExternalService.SelectedValue) || ddlExternalService.SelectedValue.Equals("0")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('是否对外服务不能为空!');</script>"); // return; //} if (string.IsNullOrEmpty(tbSpecific.Text.Trim())) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('规格型号不能为空!');</script>"); tbSpecific.Focus(); return; } decimal temp = default(decimal); if (!decimal.TryParse(tbValueRMB.Text.Trim(), out temp)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('仪器原值不是数字!');</script>"); return; } if (tbNationalPay.Text != "") { if (!decimal.TryParse(tbNationalPay.Text.Trim(), out temp)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('国拨经费不是数字!');</script>"); return; } } DateTime tempDate = default(DateTime); if (tbDisgardTime.Text != "") { if (!DateTime.TryParse(tbDisgardTime.Text, out tempDate)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('报废年限格式不对!');</script>"); return; } } if (tbProduceDate.Text != "") { if (!DateTime.TryParse(tbProduceDate.Text, out tempDate)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('生产日期格式不对!');</script>"); return; } } if (!DateTime.TryParse(tbPurchaseDate.Text, out tempDate)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('购进日期格式不对!');</script>"); return; } if (!string.IsNullOrEmpty(tbLab.Text) && !string.IsNullOrEmpty(hidLab.Value)) { if (!CY.Utility.Common.StringHelper.IsGuid(hidLab.Value)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('所属实验室输入有误!');</script>"); return; } } if (string.IsNullOrEmpty(tbSetName.Text)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('机组名称不能为空!');</script>"); return; } //if (!string.IsNullOrEmpty(tbMachineGroup.Text) && !string.IsNullOrEmpty(hidMachineGroup.Value)) //{ // if (!CY.Utility.Common.StringHelper.IsGuid(hidMachineGroup.Value)) // { // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('所属机组输入有误!');</script>"); // return; // } //} #endregion try { CY.CSTS.Core.Business.InstrumentCode instrumentCode = new CY.CSTS.Core.Business.InstrumentCode(); instrumentCode.Id = Guid.NewGuid(); instrumentCode.Save(); string unitTypeName = string.Empty; CY.CSTS.Core.Business.UnitInfo unitInfo = CY.CSTS.Core.Business.UnitInfo.Load(new Guid(hidUnit.Value.Trim())); CY.CSTS.Core.Business.UnitType unitType = CY.CSTS.Core.Business.UnitType.Load(unitInfo.UnitType); if (unitType == null) { unitTypeName = "科研单位"; } else { unitTypeName = unitType.Name; } #region 添加仪器基本信息 #region 添加仪器机组信息 Guid machinegroupid = default(Guid); if (tbSetName.Text != "") { CY.CSTS.Core.Business.MACHINESET machineSet = new CY.CSTS.Core.Business.MACHINESET { UnitID = (hidUnit.Value == "" || hidUnit.Value == null) ? Guid.Empty : new Guid(hidUnit.Value), LabID = (hidLab.Value == "" || hidLab.Value == null) ? Guid.Empty : new Guid(hidLab.Value), SetCode = tbInstrumentCode.Text.Trim(), SETNAME = tbSetName.Text, GroupInstance = tbGroupInstance.Text, EMAIL = tbEMAIL.Text, FAX = tbFAX.Text, LINKMAN = tbLinkMan.Text, PHONE = tbPHONE.Text, REMARK = tbMachineSetRemark.Text, WRITEDATE = System.DateTime.Now, UPDATEDATE = System.DateTime.Now }; machineSet.Save(); machinegroupid = machineSet.Id; } if (!machinegroupid.Equals(default(Guid))) { string[] machineSetUser = Request.Form.GetValues("mgperson"); if (machineSetUser != null && machineSetUser.Length > 0) { for (int i = 0; i < machineSetUser.Length; i++) { Guid userId = new Guid(machineSetUser[i]); CY.CSTS.Core.Business.MachineGroupMember machineGroupMember = new CY.CSTS.Core.Business.MachineGroupMember { InstruID = instrumentCode.Id, MachineGroupID = machinegroupid, UserID = userId }; machineGroupMember.Save(); } } } #endregion //添加仪器用途 string instrumentPurpose = string.Empty; for (int i = 0; i < cblPurpose.Items.Count; i++) { if (cblPurpose.Items[i].Selected) { instrumentPurpose += cblPurpose.Items[i].Text; CY.CSTS.Core.Business.PURPOSE purpose = new CY.CSTS.Core.Business.PURPOSE { PURPOSEID = new Guid(cblPurpose.Items[i].Value), InstruId = instrumentCode.Id }; purpose.Save(); } } //添加仪器测试及研究领域 string instrumentDomain = string.Empty; for (int i = 0; i < cblRealm.Items.Count; i++) { if (cblRealm.Items[i].Selected) { instrumentDomain += cblRealm.Items[i].Text; CY.CSTS.Core.Business.INSTRREALM instrrealm = new CY.CSTS.Core.Business.INSTRREALM { DomainId = new Guid(cblRealm.Items[i].Value), InstruId = instrumentCode.Id }; instrrealm.Save(); } } #region 添加仪器信息 switch (unitTypeName) { case "科研单位": CY.CSTS.Core.Business.INSTRUMENT instrument = new CY.CSTS.Core.Business.INSTRUMENT { ACCEPTMISSION = int.Parse(ddlAcceptMission.SelectedValue), ALIAS = tbAlias.Text, ASSESSOR = u.Name,//审核人 AUDITINGDATE = System.DateTime.Now, BUGETSOURCE = (ddlBudgeSource.SelectedValue == "0") ? Guid.Empty : new Guid(ddlBudgeSource.SelectedValue), SITE = new Guid(ddlProvince.SelectedValue), CITY = new Guid(Request.Form["ddlCity"]), COUNTRYCODE = (ddlCountry.SelectedValue == "0") ? Guid.Empty : new Guid(ddlCountry.SelectedValue), DISCARDTIME = (tbDisgardTime.Text == "") ? default(DateTime) : DateTime.Parse(tbDisgardTime.Text), ENAME = tbEnglishName.Text, EXAMINATION = (ddlExamination.SelectedValue == "0") ? Guid.Empty : new Guid(ddlExamination.SelectedValue), EXTERNALSERVICE = int.Parse(ddlExternalService.SelectedValue), FUNCTIONFEATURES = tbFunctionFeatures.Text, GETMODE = (ddlGetMode.SelectedValue == "0") ? Guid.Empty : new Guid(ddlGetMode.SelectedValue), GUIDELINE = tbGuidline.Text, HasCMA = int.Parse(ddlHasCMA.SelectedValue), HNAME = tbChineseName.Text, InstruCode = tbInstrumentCode.Text, IsSpecial = int.Parse(ddlIsSpecial.SelectedValue), LaboratoryId = (hidLab.Value == "" || hidLab.Value == null) ? Guid.Empty : new Guid(hidLab.Value), MachineGroupId = machinegroupid, MANUFACTURE = tbManufacturer.Text, NATIONALPAY = (tbNationalPay.Text == "") ? default(decimal) : decimal.Parse(tbNationalPay.Text), PERSONNELID = new Guid(hidPersonnal.Value), PRODUCEDATE = (tbProduceDate.Text == "") ? default(DateTime) : DateTime.Parse(tbProduceDate.Text), PRODUCESORT = (ddlProduceSort.SelectedValue == "0") ? Guid.Empty : new Guid(ddlProduceSort.SelectedValue), PRODUCINGAREA = tbProducingArea.Text, PURCHASEDATE = DateTime.Parse(tbPurchaseDate.Text), PURPOSEID = instrumentPurpose, REALMID = instrumentDomain, REMARK = tbRemark.Text, SPECTYPE = tbSpecific.Text, TOTALLY = int.Parse(ddlTotally.SelectedValue), UPDATEDATE = System.DateTime.Now, VALUERMB = decimal.Parse(tbValueRMB.Text), WorkingforUnitId = new Guid(hidUnit.Value), WRITEDATE = System.DateTime.Now, CLASSCODE = machineClass, Id = instrumentCode.Id, UseState = int.Parse(ddlUseState.SelectedValue), WorkState = int.Parse(ddlWorkState.SelectedValue), AUDITINGSTATE = 2, /**************添加采集盒状态****************/ Gather = !string.IsNullOrEmpty(ddlGather.SelectedValue) ? int.Parse(ddlGather.SelectedValue) : 0, }; instrument.Save(); SaveTag(instrument.Id); break; case "企业": CY.CSTS.Core.Business.EnterpriseInstrument enterpriseInstrument = new CY.CSTS.Core.Business.EnterpriseInstrument { ACCEPTMISSION = int.Parse(ddlAcceptMission.SelectedValue), ALIAS = tbAlias.Text, ASSESSOR = u.Name,// "load from session", AUDITINGDATE = System.DateTime.Now, BUGETSOURCE = (ddlBudgeSource.SelectedValue == "0") ? Guid.Empty : new Guid(ddlBudgeSource.SelectedValue), SITE = new Guid(ddlProvince.SelectedValue), CITY = new Guid(Request.Form["ddlCity"]), COUNTRYCODE = (ddlCountry.SelectedValue == "0") ? Guid.Empty : new Guid(ddlCountry.SelectedValue), DISCARDTIME = (tbDisgardTime.Text == "") ? default(DateTime) : DateTime.Parse(tbDisgardTime.Text), ENAME = tbEnglishName.Text, EXAMINATION = (ddlExamination.SelectedValue == "0") ? Guid.Empty : new Guid(ddlExamination.SelectedValue), EXTERNALSERVICE = int.Parse(ddlExternalService.SelectedValue), FUNCTIONFEATURES = tbFunctionFeatures.Text, GETMODE = (ddlGetMode.SelectedValue == "0") ? Guid.Empty : new Guid(ddlGetMode.SelectedValue), GUIDELINE = tbGuidline.Text, HasCMA = int.Parse(ddlHasCMA.SelectedValue), HNAME = tbChineseName.Text, InstruCode = tbInstrumentCode.Text, IsSpecial = int.Parse(ddlIsSpecial.SelectedValue), LaboratoryId = (hidLab.Value == "" || hidLab.Value == null) ? Guid.Empty : new Guid(hidLab.Value), MachineGroupId = machinegroupid, MANUFACTURE = tbManufacturer.Text, NATIONALPAY = (tbNationalPay.Text == "") ? default(decimal) : decimal.Parse(tbNationalPay.Text), PERSONNELID = new Guid(hidPersonnal.Value), PRODUCEDATE = (tbProduceDate.Text == "") ? default(DateTime) : DateTime.Parse(tbProduceDate.Text), PRODUCESORT = (ddlProduceSort.SelectedValue == "0") ? Guid.Empty : new Guid(ddlProduceSort.SelectedValue), PRODUCINGAREA = tbProducingArea.Text, PURCHASEDATE = DateTime.Parse(tbPurchaseDate.Text), PURPOSEID = instrumentPurpose, REALMID = instrumentDomain, REMARK = tbRemark.Text, SPECTYPE = tbSpecific.Text, TOTALLY = int.Parse(ddlTotally.SelectedValue), UPDATEDATE = System.DateTime.Now, VALUERMB = decimal.Parse(tbValueRMB.Text), WorkingforUnitId = new Guid(hidUnit.Value), WRITEDATE = System.DateTime.Now, CLASSCODE = machineClass, Id = instrumentCode.Id, UseState = int.Parse(ddlUseState.SelectedValue), WorkState = int.Parse(ddlWorkState.SelectedValue), AUDITINGSTATE = 2, Gather = !string.IsNullOrEmpty(ddlGather.SelectedValue) ? int.Parse(ddlGather.SelectedValue) : 0 }; enterpriseInstrument.Save(); SaveTag(enterpriseInstrument.Id); break; case "高校": CY.CSTS.Core.Business.UniversityInstrument universityInstrument = new CY.CSTS.Core.Business.UniversityInstrument { ACCEPTMISSION = int.Parse(ddlAcceptMission.SelectedValue), ALIAS = tbAlias.Text, ASSESSOR = u.Name,// "load from session", AUDITINGDATE = System.DateTime.Now, BUGETSOURCE = (ddlBudgeSource.SelectedValue == "0") ? Guid.Empty : new Guid(ddlBudgeSource.SelectedValue), SITE = new Guid(ddlProvince.SelectedValue), CITY = new Guid(Request.Form["ddlCity"]), COUNTRYCODE = (ddlCountry.SelectedValue == "0") ? Guid.Empty : new Guid(ddlCountry.SelectedValue), DISCARDTIME = (tbDisgardTime.Text == "") ? default(DateTime) : DateTime.Parse(tbDisgardTime.Text), ENAME = tbEnglishName.Text, EXAMINATION = (ddlExamination.SelectedValue == "0") ? Guid.Empty : new Guid(ddlExamination.SelectedValue), EXTERNALSERVICE = int.Parse(ddlExternalService.SelectedValue), FUNCTIONFEATURES = tbFunctionFeatures.Text, GETMODE = (ddlGetMode.SelectedValue == "0") ? Guid.Empty : new Guid(ddlGetMode.SelectedValue), GUIDELINE = tbGuidline.Text, HasCMA = int.Parse(ddlHasCMA.SelectedValue), HNAME = tbChineseName.Text, InstruCode = tbInstrumentCode.Text, IsSpecial = int.Parse(ddlIsSpecial.SelectedValue), LaboratoryId = (hidLab.Value == "" || hidLab.Value == null) ? Guid.Empty : new Guid(hidLab.Value), MachineGroupId = machinegroupid, MANUFACTURE = tbManufacturer.Text, NATIONALPAY = (tbNationalPay.Text == "") ? default(decimal) : decimal.Parse(tbNationalPay.Text), PERSONNELID = new Guid(hidPersonnal.Value), PRODUCEDATE = (tbProduceDate.Text == "") ? default(DateTime) : DateTime.Parse(tbProduceDate.Text), PRODUCESORT = (ddlProduceSort.SelectedValue == "0") ? Guid.Empty : new Guid(ddlProduceSort.SelectedValue), PRODUCINGAREA = tbProducingArea.Text, PURCHASEDATE = DateTime.Parse(tbPurchaseDate.Text), PURPOSEID = instrumentPurpose, REALMID = instrumentDomain, REMARK = tbRemark.Text, SPECTYPE = tbSpecific.Text, TOTALLY = int.Parse(ddlTotally.SelectedValue), UPDATEDATE = System.DateTime.Now, VALUERMB = decimal.Parse(tbValueRMB.Text), WorkingforUnitId = new Guid(hidUnit.Value), WRITEDATE = System.DateTime.Now, CLASSCODE = machineClass, Id = instrumentCode.Id, UseState = int.Parse(ddlUseState.SelectedValue), WorkState = int.Parse(ddlWorkState.SelectedValue), AUDITINGSTATE = 2, Gather = !string.IsNullOrEmpty(ddlGather.SelectedValue) ? int.Parse(ddlGather.SelectedValue) : 0 }; universityInstrument.Save(); SaveTag(universityInstrument.Id); break; default: break; } #endregion //添加仪器图片及视频信息 SaveFiles(instrumentCode.Id); SaveImg(instrumentCode.Id); #endregion #region 添加仪器附件信息 //添加仪器附件 string[] attachModel = Request.Form.GetValues("tbAttachmentModel"); string[] attachNum = Request.Form.GetValues("tbAttachmentNum"); string[] mainFunction = Request.Form.GetValues("tbMainFunction"); string[] attachName = Request.Form.GetValues("tbAttachmentName"); string[] attachPrice = Request.Form.GetValues("tbAttachmentPrice"); string[] attachManufacturer = Request.Form.GetValues("tbAttachmentManufacturer"); string[] attachRemark = Request.Form.GetValues("tbAttachRemark"); if (attachName.Length != 0) { for (int i = 0; i < attachName.Length; i++) { if (attachName[i] != "") { CY.CSTS.Core.Business.INSTRATTACHMENT attachment = new CY.CSTS.Core.Business.INSTRATTACHMENT { InstruId = instrumentCode.Id, ATTACHMENTNAME = attachName[i], //ATTACHMENTAMOUNT = int.Parse(attachNum[i]), //ATTACHMENTPRICE = decimal.Parse(attachPrice[i]), ATTACHMENTSPEC = attachModel[i], MANUFACTURER = attachManufacturer[i], PURPOSE = mainFunction[i], REMARK = attachRemark[i], WRITEDATE = System.DateTime.Now, UPDATEDATE = System.DateTime.Now }; attachment.Save(); } } } #endregion #region 添加仪器应用信息 string[] appDate = Request.Form.GetValues("tbApplicationDate"); string[] famousUser = Request.Form.GetValues("tbFamousUser"); string[] influentialNum = Request.Form.GetValues("tbInfluentialNum"); string[] trait = Request.Form.GetValues("tbTrait"); string[] appFruit = Request.Form.GetValues("tbApplicationFruit"); string[] appRemark = Request.Form.GetValues("tbApplicationRemark"); if (appDate.Length != 0) { for (int i = 0; i < appDate.Length; i++) { if (appDate[i] != "") { CY.CSTS.Core.Business.INSTRAPPLICATION application = new CY.CSTS.Core.Business.INSTRAPPLICATION { InstruId = instrumentCode.Id, YEAR = DateTime.Parse(appDate[i]), FAMOUSUSERS = famousUser[i], INFLUENTIALNUM = int.Parse(influentialNum[i]), FRUIT = appFruit[i], TRAIT = trait[i], REMARK = appRemark[i], WRITEDATE = System.DateTime.Now, UPDATEDATE = System.DateTime.Now }; application.Save(); } } } #endregion #region 添加仪器测试项目收费标准信息 string[] feeType = Request.Form.GetValues("tbFeeType"); string[] feeStandard = Request.Form.GetValues("tbFeeStandard"); string[] feeItem = Request.Form.GetValues("tbFeeItem"); string[] feeRemark = Request.Form.GetValues("tbFeeRemark"); if (feeItem.Length != 0) { for (int i = 0; i < feeItem.Length; i++) { if (feeItem[i] != "") { CY.CSTS.Core.Business.INSTRFEE instrfee = new CY.CSTS.Core.Business.INSTRFEE { InstruId = instrumentCode.Id, FEEITEM = feeItem[i], FEECLASS = feeType[i], FEESTANDARD = feeStandard[i], REMARK = feeRemark[i], WRITEDATE = System.DateTime.Now, UPDATEDATE = System.DateTime.Now }; instrfee.Save(); } } } #endregion #region 添加仪器服务信息 string[] outOffered = Request.Form.GetValues("ddlOutOffered"); string[] serivceType = Request.Form.GetValues("ddlSerivceType"); string[] serviceIncome = Request.Form.GetValues("tbServiceIncome"); string[] atlasName = Request.Form.GetValues("tbAtlasName"); string[] serviceExplain = Request.Form.GetValues("tbServiceExplain"); string[] offerTime = Request.Form.GetValues("tbOfferTime"); string[] testSampleNum = Request.Form.GetValues("tbTestSampleNum"); string[] atlasManufacturer = Request.Form.GetValues("tbAtlasManufacturer"); string[] serviceRemark = Request.Form.GetValues("tbServiceRemark"); if (outOffered.Length != 0) { for (int i = 0; i < outOffered.Length; i++) { if (offerTime[i] != "" && testSampleNum[i] != "") { CY.CSTS.Core.Business.INSTRSERVICE instrservice = new CY.CSTS.Core.Business.INSTRSERVICE { INSTRUMENTID = instrumentCode.Id, OUTOFFERED = int.Parse(outOffered[i]), SERVICECLASS = serivceType[i], OFFERTIME = int.Parse(offerTime[i]), ATLASMANUFACTURER = atlasManufacturer[i], ATLASNAME = atlasName[i], ServiceIncome = decimal.Parse(serviceIncome[i]), TestSampleNum = int.Parse(testSampleNum[i]), SERVICEEXPLAIN = serviceExplain[i], REMARK = serviceRemark[i], WRITEDATE = System.DateTime.Now, UPDATEDATE = System.DateTime.Now }; instrservice.Save(); } } } #endregion CY.CSTS.Core.Business.FreshNews fresh = new CY.CSTS.Core.Business.FreshNews(); fresh.Sponsor = "管理员"; fresh.FreshEvent = "添加仪器" + tbSetName.Text; if (tbEnglishName.Text.Trim() != "") { fresh.FreshEvent += "(" + tbEnglishName.Text + ")"; } fresh.Embracer = tbUnit.Text.Trim(); fresh.EmbracerId = new Guid(hidUnit.Value); fresh.UnitId = new Guid(hidUnit.Value); fresh.EventType = 3; fresh.EventTime = DateTime.Now; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('添加成功!');window.location.href='InstrumentList.aspx';</script>"); } catch (Exception ex) { throw ex; } }