コード例 #1
0
ファイル: AddLab.ashx.cs プロジェクト: dalinhuang/cy-csts
        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);
        }