protected void btnSave_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(tbNameEdit.Text.Trim())) { lbErr.Text = "实验室名称不能为空"; tbNameEdit.Focus(); } else { string express = "\\w{1,}@\\w{1,}\\.\\w{1,}"; System.Text.RegularExpressions.Regex myRegex = new System.Text.RegularExpressions.Regex(express); bool suc = myRegex.IsMatch(tbEmailEdit.Text.Trim()); if (!suc) { lbErr.Text = "请输入正确的邮箱格式"; tbEmailEdit.Focus(); return; } Lab lab = Lab.Load(gloalID); lab.Name = tbNameEdit.Text.Trim(); lab.OtherName1 = tbOtherNameEdit.Text.Trim(); lab.OtherName2 = tbOtherName2Edit.Text.Trim(); lab.Address = tbAddressEdit.Text.Trim(); lab.Postalcode = tbPostEdit.Text.Trim(); lab.Tel = tbTelEdit.Text.Trim(); lab.Fax = tbFaxEdit.Text.Trim(); lab.Website = tbWebSiteEdit.Text.Trim(); lab.Email = tbEmailEdit.Text.Trim(); lab.LabSortID = new Guid(ddllevelSortEdit.SelectedValue.ToString()); lab.LabLevelID = new Guid(ddllevelEdit.SelectedValue.ToString()); lab.LabPrincipal = tbPrincipalEdit.Text.Trim(); lab.LinkMan = tbLinkManEdit.Text.Trim(); lab.IsRecognize = radioY.Checked == true ? 1 : 2; lab.RecognizeNumber = tbRecognizeNumberEdit.Text.Trim(); lab.OrganizationCode = tbOrganizationCodeEdit.Text.Trim(); lab.Synopsis = tbSynopsisEdit.Text.Trim(); lab.Remark = tbRemarkEdit.Text.Trim(); lab.Save(); string labDom = hdDomID.Value; if (!string.IsNullOrEmpty(labDom)) { List<LabDomain> labDomainlist = LabDomain.SelectLabDomainsByAndLabID(gloalID) as List<LabDomain>; if (labDomainlist != null) { if (labDomainlist.Count > 0) { for (int d = 0; d < labDomainlist.Count; d++) { LabDomain labD = LabDomain.Load(labDomainlist[d].Id); labD.DeleteOnSave(); labD.Save(); } } string[] domIDTemp = labDom.Split(','); for (int j = 0; j < domIDTemp.Count(); j++) { string domID = domIDTemp[j]; LabDomain labDomSave = new LabDomain(); labDomSave.LabID = gloalID; labDomSave.DomainID = new Guid(domID); labDomSave.Save(); } } } CY.CSTS.Core.Business.FreshNews fresh = new CY.CSTS.Core.Business.FreshNews(); CY.CSTS.Core.Business.User user = Session["User"] as CY.CSTS.Core.Business.User; fresh.Sponsor = user.Name; fresh.FreshEvent = "修改信息"; fresh.Embracer = lab.Name; fresh.UnitId = lab.UnitID; fresh.EventType = 8; fresh.EventTime = DateTime.Now; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('修改成功');window.location.href='Detail.aspx?id=" + gloalID + "'</script>"); } } catch (Exception ex) { lbErr.Text = ex.Message; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; string result = string.Empty; if(context.Request.Params["tbLabName"]==null) { result="{success:false,msg:'不能为空'}"; } else { try { Lab lab=new Lab(); lab.Name=context.Request.Params["tbLabName"].ToString(); lab.UnitID=new Guid(context.Request.Params["UnitID"].ToString()); lab.OtherName1=context.Request.Params["tbOtherName1"].ToString(); lab.OtherName2=context.Request.Params["tbOtherName2"].ToString(); lab.Address=context.Request.Params["tbAddress"].ToString(); lab.Postalcode=context.Request.Params["tbPostalcode"].ToString(); lab.Tel=context.Request.Params["tbTel"].ToString(); lab.Fax=context.Request.Params["tbFax"].ToString(); lab.Website=context.Request.Params["tbWebsite"].ToString(); lab.Email=context.Request.Params["tbEmail"].ToString(); lab.LabSortID=new Guid(context.Request.Params["ddlLabSort"].ToString()); lab.LabLevelID=new Guid(context.Request.Params["ddlLabLevel"].ToString()); lab.LabPrincipal=context.Request.Params["tbLabPrincipal"].ToString(); lab.LinkMan=context.Request.Params["tbLinkMan"].ToString(); lab.IsRecognize=int.Parse(context.Request.Params["tbRecognize"].ToString()); lab.RecognizeNumber=context.Request.Params["tbRecognizeNumber"].ToString(); lab.OrganizationCode=context.Request.Params["tbOrganizationCode"].ToString(); lab.Synopsis=context.Request.Params["tbSynopsis"].ToString(); lab.Remark=context.Request.Params["tbRemark"].ToString(); lab.Save(); CY.CSTS.Core.Business.FreshNews fresh = new CY.CSTS.Core.Business.FreshNews(); fresh.Sponsor = "管理员"; fresh.FreshEvent = "添加实验室" + lab.Name; CY.CSTS.Core.Business.UnitInfo unitinfo = CY.CSTS.Core.Business.UnitInfo.Load(lab.UnitID); fresh.Embracer = unitinfo.UnitName; fresh.UnitId = lab.UnitID; fresh.EventType = 8; fresh.EventTime = DateTime.Now; string domIDtemp = context.Request.Params["tbDomainID"]; if (!string.IsNullOrEmpty(domIDtemp)) { string[] domID=domIDtemp.Split(','); if (domID.Length > 0) { for (int m = 0; m < domID.Length; m++) { LabDomain labDomain = new LabDomain(); labDomain.LabID = lab.Id; labDomain.DomainID =new Guid(domID[m]); labDomain.Save(); } } } result = "{success:true}"; } catch(Exception ex) { result="{success:false,msg:'"+ex.Message+"'}"; } } context.Response.Write(result); }