protected void btnSearch_Click(object sender, EventArgs e)
 {
     //构造JSON搜索块
     string json = string.Empty;
     string tag = string.Empty;
     try
     {
         CY.CSTS.Core.Business.InstrumentSearchJson searchJson = new CY.CSTS.Core.Business.InstrumentSearchJson();
         if (!string.IsNullOrEmpty(tbChineseName.Text.Trim()))
         {
             searchJson.Name = tbChineseName.Text.Trim();
         }
         if (ddlUnit.SelectedValue != "-1")
         {
             searchJson.Unit = new Guid(ddlUnit.SelectedValue.ToString());
         }
         json = Newtonsoft.Json.JavaScriptConvert.SerializeObject(searchJson);
     }
     catch (Exception ex)
     {
         Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('出错:" + ex.Message + "')</script>");
     }
     finally
     {
         json = Server.UrlEncode(json);
         string url = ResolveUrl("~/Foreground/instrument/InstrumentList.aspx?json=" + json + "");
         Response.Redirect(url);
     }
 }
Exemple #2
0
        /// <summary>
        /// 仪器搜索
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnInstrumentSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(tbInstrument.Text))
                {
                    CY.CSTS.Core.Business.InstrumentSearchJson json = new CY.CSTS.Core.Business.InstrumentSearchJson();

                    switch (Request.Form.Get("instrumentSearchType"))
                    {
                        case "unit":
                            json.UnitName = tbInstrument.Text;
                            break;
                        case "code":
                            json.Code = tbInstrument.Text;
                            break;
                        case "name":
                            json.Name = tbInstrument.Text;
                            break;
                        default:
                            json.Name = tbInstrument.Text;
                            break;
                    }
                    Response.Redirect("/Foreground/instrument/InstrumentList.aspx?json=" + Newtonsoft.Json.JavaScriptConvert.SerializeObject(json));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void Initial(
            string strjson,
            string strpageinfo,
            out CY.CSTS.Core.Business.InstrumentSearchJson json,
            out CY.CSTS.Core.Business.PagingInfo pageinfo
            )
        {
            try
            {

                json = new CY.CSTS.Core.Business.InstrumentSearchJson();

                pageinfo = new CY.CSTS.Core.Business.PagingInfo();

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void btnSearchInstrument_Click(object sender, EventArgs e)
        {
            /*构造查询JSON*/
            CY.CSTS.Core.Business.InstrumentSearchJson json = new CY.CSTS.Core.Business.InstrumentSearchJson();
            if (!string.IsNullOrEmpty(tbInstrumentCode.Text.Trim()))
            {
                json.Code = tbInstrumentCode.Text.Trim();
            }
            if (!string.IsNullOrEmpty(tbChineseName.Text.Trim()))
            {
                json.Name = tbChineseName.Text.Trim();
            }
            if (ddlMachineBigClass.SelectedValue != "0" && ddlMachineBigClass.SelectedValue != null)
            {
                string strNameMiddle = ddlMachineMiddleClass.ClientID.Replace("_", "$");
                string strNameSmall = ddlMachineSmallClass.ClientID.Replace("_", "$");
                if (Request.Form[strNameMiddle] != "0" && Request.Form[strNameSmall] == "0")
                {
                    json.Cate = int.Parse(Request.Form[strNameMiddle]);
                }
                else if (Request.Form[strNameMiddle] != "0" && Request.Form[strNameSmall] != "0")
                {
                    json.Cate = int.Parse(Request.Form[strNameSmall]);
                }
                else if (Request.Form[strNameMiddle] == "0" && Request.Form[strNameSmall] == "0")
                {
                    json.Cate = int.Parse(ddlMachineBigClass.SelectedValue);
                }
            }
            if (!string.IsNullOrEmpty(tbSpecific.Text.Trim()))
            {
                json.SPECTYPE = tbSpecific.Text.Trim();
            }
            if (!string.IsNullOrEmpty(tbManufacturer.Text.Trim()))
            {
                json.MANUFACTURE = tbManufacturer.Text.Trim();
            }
            if (ddlCountry.SelectedValue != "-1")
            {
                json.COUNTRYCODE = new Guid(ddlCountry.SelectedValue);
            }
            if (!string.IsNullOrEmpty(tbProducingArea.Text.Trim()))
            {
                json.PRODUCINGAREA = tbProducingArea.Text.Trim();
            }
            if (!string.IsNullOrEmpty(tbFunctionFeatures.Text.Trim()))
            {
                json.FUNCTIONFEATURES = tbFunctionFeatures.Text.Trim();
            }
            if (ddlUnit.SelectedValue != "-1")
            {
                json.Unit = new Guid(ddlUnit.SelectedValue);
            }
            if (!string.IsNullOrEmpty(tbEnglishName.Text.Trim()))
            {
                json.EnName = tbEnglishName.Text.Trim();
            }
            if (!string.IsNullOrEmpty(tbAlias.Text.Trim()))
            {
                json.ALIAS = tbAlias.Text.Trim();
            }
            decimal tepm1 = default(decimal);
            decimal tepm2 = default(decimal);
            if (!string.IsNullOrEmpty(tbLowerValue.Text.Trim()))
            {
                if (decimal.TryParse(tbLowerValue.Text.Trim(), out tepm1))
                {
                    json.lowerValue = tepm1;

                    if (!string.IsNullOrEmpty(tbHigherValue.Text.Trim()))
                    {
                        if (decimal.TryParse(tbHigherValue.Text.Trim(), out tepm2))
                        {
                            json.highValue = tepm2;
                        }
                    }
                }
            }
            //使用状态
            json.UseState = int.Parse(ddlUseState.SelectedValue);
            json.HasCMA = int.Parse(ddlHasCMA.SelectedValue);
            int isspecifical = 0;
            if (!string.IsNullOrEmpty(ddlIsSpecial.SelectedValue) &&
                int.TryParse(ddlIsSpecial.SelectedValue, out isspecifical) &&
                (isspecifical == 1 || isspecifical == 2))
            {
                json.IsSpecial = isspecifical;
            }

            int isshare = 0;
            if (!string.IsNullOrEmpty(ddlTotally.SelectedValue) &&
                int.TryParse(ddlTotally.SelectedValue, out isshare) &&
                (isshare == 1 || isshare == 2))
            {
                json.IsShare = isshare;
            }

            int ismission = 0;
            if (!string.IsNullOrEmpty(ddlAcceptMission.SelectedValue) &&
                int.TryParse(ddlAcceptMission.SelectedValue, out ismission) &&
                (ismission == 1 || ismission == 2))
            {
                json.IsMisssion = ismission;
            }
            int isservice = 0;
            if (!string.IsNullOrEmpty(ddlExternalService.SelectedValue) &&
                int.TryParse(ddlExternalService.SelectedValue, out isservice) &&
                (isservice == 1 || isservice == 2))
            {
                json.IsService = isservice;
            }

            /**************单位自建编号************/
            int instrument = 0;

            if (!string.IsNullOrEmpty(tbUnitBuildCode.Text) && int.TryParse(tbUnitBuildCode.Text, out instrument))
            {
                json.UnitBuildCode = instrument;
            }

            string jsonRes = string.Empty;
            jsonRes = Newtonsoft.Json.JavaScriptConvert.SerializeObject(json);
            jsonRes = Server.UrlEncode(jsonRes);
            string url = ResolveUrl("~/Foreground/instrument/InstrumentList.aspx?json=" + HttpUtility.HtmlEncode(jsonRes));
            Response.Redirect(url);
        }
        /// <summary>
        ///  json is Mandatory, pageinfo is Mandatory ,tag is switch
        /// </summary>
        protected void Initial(
            string strjson,
            string strpageinfo,
            string tag,
            int typeid,
            ref CY.CSTS.Core.Business.InstrumentSearchJson json,
            ref CY.CSTS.Core.Business.PagingInfo pageinfo,
            out int totalCount
            )
        {
            try
            {
                if (string.IsNullOrEmpty(strjson))
                {
                    json = new CY.CSTS.Core.Business.InstrumentSearchJson();
                }
                else
                {
                    strjson = strjson.Replace("NaN", "-1");
                    json = Newtonsoft.Json.JavaScriptConvert.DeserializeObject(HttpUtility.HtmlDecode(strjson), typeof(CY.CSTS.Core.Business.InstrumentSearchJson)) as CY.CSTS.Core.Business.InstrumentSearchJson;
                }

                if (string.IsNullOrEmpty(strpageinfo))
                {
                    pageinfo = new CY.CSTS.Core.Business.PagingInfo();
                }
                else
                {
                    pageinfo = Newtonsoft.Json.JavaScriptConvert.DeserializeObject(strpageinfo, typeof(CY.CSTS.Core.Business.PagingInfo)) as CY.CSTS.Core.Business.PagingInfo;
                }
                if (!string.IsNullOrEmpty(tag))
                {
                    json.tags.Add(tag);
                }

                if (json.Cates != null && json.Cate > 0)
                {
                    CY.CSTS.Core.Business.CLASSCODE baseClass = CY.CSTS.Core.Business.CLASSCODE.Load(json.Cate);

                    IEnumerable<CY.CSTS.Core.Business.CLASSCODE> originalClass = CY.CSTS.Core.Business.CLASSCODE.SelectLayerCate(CY.Utility.Common.CodeInterface.InstrumentCategoryLayer.LayerThird);

                    if (originalClass != null)
                    {
                        originalClass = originalClass.Where(item => item.RootPath.Contains(baseClass.RootPath));
                    }
                    IEnumerable<int> result = from p in originalClass select p.Id;
                    foreach (int r in result)
                    {
                        json.Cates.Add(r);
                    }
                }

                if (typeid > 0)
                {
                    json.Cates.Add(typeid);
                    json.Cate = typeid;
                }

                totalCount = CY.CSTS.Core.Business.view_INSTRUMENT.GetTotalCount(json);

                pageCount = (totalCount / pageinfo.PageSize) + (totalCount % pageinfo.PageSize > 0 ? 1 : 0);
            }
            catch (Exception ex)
            {
                json = new CY.CSTS.Core.Business.InstrumentSearchJson();
                totalCount = CY.CSTS.Core.Business.view_INSTRUMENT.GetTotalCount(json);
            }
        }
        protected void BtnSearch_Click(object sender, EventArgs e)
        {
            decimal money = default(decimal);
            if (!string.IsNullOrEmpty(tbLowerValue.Text.Trim()))
            {
                if (!decimal.TryParse(tbLowerValue.Text.Trim(), out money))
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('仪器价格上限必须为数字');</script> ");
                    return;
                }
            }
            if (!string.IsNullOrEmpty(tbHigherValue.Text.Trim()))
            {
                if (!decimal.TryParse(tbHigherValue.Text.Trim(), out money))
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('仪器价格下限必须为数字');</script> ");
                    return;
                }
            }
            if (!string.IsNullOrEmpty(tbHigherValue.Text.Trim()) && !string.IsNullOrEmpty(tbLowerValue.Text.Trim()))
            {
                if (decimal.Parse(tbHigherValue.Text.Trim()) - decimal.Parse(tbLowerValue.Text.Trim()) < 0)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('价格上限必须大于下限或为空!');</script> ");
                    return;
                }
            }

            //构造JSON搜索块
            string json = string.Empty;
            string tag = string.Empty;
            try
            {
                CY.CSTS.Core.Business.InstrumentSearchJson searchJson = new CY.CSTS.Core.Business.InstrumentSearchJson();
                if (!string.IsNullOrEmpty(tbChineseName.Text.Trim()))
                {
                    searchJson.Name = tbChineseName.Text.Trim();
                }
                if (!string.IsNullOrEmpty(tbSpecific.Text.Trim()))
                {
                    searchJson.SPECTYPE = tbSpecific.Text.Trim();
                }
                if (ddlUnit.SelectedValue != "-1")
                {
                    searchJson.Unit = new Guid(ddlUnit.SelectedValue.ToString());
                }

                decimal tepm1 = default(decimal);
                decimal tepm2 = default(decimal);
                if (!string.IsNullOrEmpty(tbLowerValue.Text.Trim()))
                {
                    if (decimal.TryParse(tbLowerValue.Text.Trim(), out tepm1))
                    {
                        searchJson.lowerValue = tepm1;

                        if (!string.IsNullOrEmpty(tbHigherValue.Text.Trim()))
                        {
                            if (decimal.TryParse(tbHigherValue.Text.Trim(), out tepm2))
                            {
                                searchJson.highValue = tepm2;
                            }
                        }
                    }
                }

                if (ddlMachineBigClass.SelectedValue != "0" && ddlMachineBigClass.SelectedValue != null)
                {
                    string strNameMiddle = ddlMachineMiddleClass.ClientID.Replace("_", "$");
                    string strNameSmall = ddlMachineSmallClass.ClientID.Replace("_", "$");
                    if (Request.Form[strNameMiddle] != "0" && Request.Form[strNameSmall] == "0")
                    {
                        searchJson.Cate = int.Parse(Request.Form[strNameMiddle]);
                    }
                    else if (Request.Form[strNameMiddle] != "0" && Request.Form[strNameSmall] != "0")
                    {
                        searchJson.Cate = int.Parse(Request.Form[strNameSmall]);
                    }
                    else if (Request.Form[strNameMiddle] == "0" && Request.Form[strNameSmall] == "0")
                    {
                        searchJson.Cate = int.Parse(ddlMachineBigClass.SelectedValue);
                    }
                }
                if (ddlTotally.SelectedValue != "-1")
                {
                    searchJson.IsShare = int.Parse(ddlTotally.SelectedValue);
                }
                json = Newtonsoft.Json.JavaScriptConvert.SerializeObject(searchJson);
            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('出错:" + ex.Message + "')</script>");
            }
            finally
            {
                json = Server.UrlEncode(json);
                string url = ResolveUrl("~/Foreground/instrument/InstrumentList.aspx?json=" + json + "");
                Response.Redirect(url);
            }
        }
        protected void Initial(
            ref CY.CSTS.Core.Business.view_INSTRUMENT instrument,
            ref CY.CSTS.Core.Business.InstrumentSearchJson json,
            ref CY.CSTS.Core.Business.PagingInfo pageinfo
            )
        {
            try
            {
                Guid id = new Guid(ViewState["id"].ToString());
                if (id != Guid.Empty)
                {
                    instrument = CY.CSTS.Core.Business.view_INSTRUMENT.Load(id);
                }

                json = new CY.CSTS.Core.Business.InstrumentSearchJson();

                pageinfo = new CY.CSTS.Core.Business.PagingInfo();

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #8
0
        private string HandlerRequestUnitJson()
        {
            System.Text.StringBuilder sbResult = new System.Text.StringBuilder();
            try
            {
                string strJson = string.Empty;

                string strPagingInfo = string.Empty;

                if (CY.Utility.Common.RequestUtility.IsGet)
                {
                    strJson = CY.Utility.Common.RequestUtility.GetQueryString("condition");
                    strPagingInfo = CY.Utility.Common.RequestUtility.GetQueryString("paginginfo");
                }
                else if (CY.Utility.Common.RequestUtility.IsPost)
                {
                    strJson = CY.Utility.Common.RequestUtility.GetFormString("condition");
                    strPagingInfo = CY.Utility.Common.RequestUtility.GetFormString("paginginfo");
                }

                if (string.IsNullOrEmpty(strJson) || string.IsNullOrEmpty(strPagingInfo))
                {
                    return sbResult.Append("{success:false,action:'none',status:'none',msg;'json is null'}").ToString();
                }

                json = Newtonsoft.Json.JavaScriptConvert.DeserializeObject(strJson, typeof(CY.CSTS.Core.Business.InstrumentSearchJson)) as CY.CSTS.Core.Business.InstrumentSearchJson;

                pagingInfo = Newtonsoft.Json.JavaScriptConvert.DeserializeObject(strPagingInfo, typeof(CY.CSTS.Core.Business.PagingInfo)) as CY.CSTS.Core.Business.PagingInfo;

                if (json == null || pagingInfo == null)
                {
                    return sbResult.Append("{success:false,action:'none',status:'none',msg;'json is null'}").ToString();
                }

                sbResult.Append("{");
                sbResult.Append("success:true");
                sbResult.Append(",action:'update'");
                sbResult.Append(",status:'update'");
                sbResult.Append(",");
                sbResult.Append(CreateJson(json, pagingInfo));
                sbResult.Append("}");
                return sbResult.ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

            }
        }