Example #1
0
        public static void ImportInstrumentService()
        {
            ImportSqlServerUtility isql = new ImportSqlServerUtility();

            string strsql = "select * from INSTRSERVICE";

            DataSet ds = isql.ExecuteSqlDataSet(strsql);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Columns.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    CY.CSTS.Core.Business.INSTRSERVICE ser = new CY.CSTS.Core.Business.INSTRSERVICE();

                    ser.INSTRUMENTID = TransferInstrumentId(ds.Tables[0].Rows[i][0].ToString());

                    int result = 0;
                    ser.OUTOFFERED = !string.IsNullOrEmpty(ds.Tables[0].Rows[i][1].ToString()) && int.TryParse(ds.Tables[0].Rows[i][1].ToString(), out result) ? result : 2;

                    ser.OFFERTIME = !string.IsNullOrEmpty(ds.Tables[0].Rows[i][2].ToString()) ? int.Parse(ds.Tables[0].Rows[i][2].ToString()) : 0;

                    ser.SERVICEEXPLAIN = ds.Tables[0].Rows[i][3].ToString();

                    ser.SERVICECLASS = ds.Tables[0].Rows[i][4].ToString();

                    ser.ATLASMANUFACTURER = ds.Tables[0].Rows[i][5].ToString();

                    ser.ATLASNAME = ds.Tables[0].Rows[i][6].ToString();

                    ser.REMARK = ds.Tables[0].Rows[i][7].ToString();

                    ser.WRITEDATE = !string.IsNullOrEmpty(ds.Tables[0].Rows[i][8].ToString()) ? DateTime.Parse(ds.Tables[0].Rows[i][8].ToString()) : DateTime.MinValue;

                    ser.UPDATEDATE = ser.WRITEDATE;// !string.IsNullOrEmpty(ds.Tables[0].Rows[i][9].ToString()) ? DateTime.Parse(ds.Tables[0].Rows[i][8].ToString()) : DateTime.MinValue;

                    ser.Save();
                }
            }
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            StringBuilder result = new StringBuilder();
            if (context.Request.Params["instrumentid"] == null || context.Request.Params["outOffered"] == null || context.Request.Params["serviceType"] == null || context.Request.Params["serviceIncome"] == null || context.Request.Params["atlasName"] == null
                || context.Request.Params["serviceExplain"] == null || context.Request.Params["offerTime"] == null || context.Request.Params["testSampleNum"] == null || context.Request.Params["atlasManufacturer"] == null || context.Request.Params["remark"] == null)
            {
                result.Append("{result:false,msg:'参数错误!'}");
            }
            else
            {
                try
                {
                    Guid instrumentID = new Guid(context.Request.Params["instrumentid"]);
                    int outOffered = int.Parse(context.Request.Params["outOffered"]);
                    string serviceType = context.Request.Params["serviceType"];
                    decimal serviceIncome = decimal.Parse(context.Request.Params["serviceIncome"]);
                    string atlasName = context.Request.Params["atlasName"];
                    string serviceExplain = context.Request.Params["serviceExplain"];
                    int offerTime = int.Parse(context.Request.Params["offerTime"]);
                    int testSampleNum = int.Parse(context.Request.Params["testSampleNum"]);
                    string atlasManufacturer = context.Request.Params["atlasManufacturer"];
                    string remark = context.Request.Params["remark"];

                    CY.CSTS.Core.Business.INSTRSERVICE service = new CY.CSTS.Core.Business.INSTRSERVICE
                    {
                        INSTRUMENTID = instrumentID,
                        OUTOFFERED = outOffered,
                        SERVICECLASS = serviceType,
                        ServiceIncome = serviceIncome,
                        OFFERTIME = offerTime,
                        TestSampleNum = testSampleNum,
                        ATLASMANUFACTURER = atlasManufacturer,
                        ATLASNAME = atlasName,
                        SERVICEEXPLAIN = serviceExplain,
                        REMARK = remark
                    };
                    service.Save();

                    result.Append("{result:true,");
                    result.Append(string.Format("serviceId:'{0}'", service.Id));
                    result.Append(string.Format(",outOffered:'{0}'", service.OUTOFFERED));
                    result.Append(string.Format(",serviceType:'{0}'", service.SERVICECLASS));
                    result.Append(string.Format(",serviceIncome:'{0}'", service.ServiceIncome));
                    result.Append(string.Format(",atlasName:'{0}'", service.ATLASNAME));
                    result.Append(string.Format(",serviceExplain:'{0}'", service.SERVICEEXPLAIN));
                    result.Append(string.Format(",offerTime:'{0}'", service.OFFERTIME));
                    result.Append(string.Format(",testSampleNum:'{0}'", service.TestSampleNum));
                    result.Append(string.Format(",atlasManufacturer:'{0}'", service.ATLASMANUFACTURER));
                    result.Append(string.Format(",remark:'{0}'", service.REMARK));
                    result.Append("}");
                }
                catch (Exception ex)
                {
                    result = new StringBuilder();
                    result.Append("{result:false,msg:" + ex.Message + "}");
                }
            }

            context.Response.Write(result);
        }
Example #3
0
        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;
            }
        }