Exemplo n.º 1
0
        public static List <ConstantType> GetConstantTypes()
        {
            ConstantApi constantApi = new ConstantApi();

            var respType = constantApi.GetConstantTypes();

            if (respType.Code == 1 && respType.DataCount > 0)
            {
                _constantTypes = JsonConvert.DeserializeObject <List <ConstantType> >(respType.Data.ToString());
            }
            return(_constantTypes);
        }
Exemplo n.º 2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            List <ConstantType> list = null;

            ControlHelper.ThreadRunExt(AppHelper.MainForm, () =>
            {
                var succ = true;
                var msg  = "";
                try
                {
                    ResponseModel responseModel = new ResponseModel();
                    ConstantApi constantApi     = new ConstantApi();
                    responseModel = constantApi.GetConstantTypes();

                    //Hashtable hashtable = null;
                    //string sql = "SELECT  * FROM ConstantType WHERE 1=1 ";

                    //if (!string.IsNullOrEmpty(txtSeach.Text.Trim()))
                    //{
                    //    hashtable = new Hashtable();
                    //    hashtable.Add("TypeName", "%" + txtSeach.Text.Trim() + "%");
                    //    sql += " AND TypeName like @DefineType";
                    //}
                    //list = _mssqlHelper.QueryList<ConstantType>(sql, hashtable).ToList();


                    if (responseModel.Code == 1)
                    {
                        if (responseModel.DataCount > 0)
                        {
                            list = JsonConvert.DeserializeObject <List <ConstantType> >(responseModel?.Data?.ToString());
                            ControlHelper.ThreadInvokerControl(AppHelper.MainForm, () =>
                            {
                                if (list != null)
                                {
                                    CGridHelper.ClearGrid(dgv);
                                    CGridHelper.FillGrid <ConstantType>(dgv, list);
                                }
                            });
                        }
                        else
                        {
                            succ = false;
                            msg  = "查询数据为空!";
                        }
                        //FrmTips.ShowTips(AppHelper.MainForm, "查询数据为空!", 2000, true, ContentAlignment.MiddleCenter, null, TipsSizeMode.Medium, new Size(300, 100), TipsState.Success);
                    }
                    else
                    {
                        succ = false;
                        msg  = responseModel?.Message;
                    }
                    // FrmTips.ShowTips(AppHelper.MainForm,responseModel?.Message, 2000, true, ContentAlignment.MiddleCenter, null, TipsSizeMode.Medium, new Size(300, 100), TipsState.Error);
                }
                catch (Exception ex)
                {
                    succ = false;
                    msg  = ex.Message;
                }
                if (!succ)
                {
                    ControlHelper.ThreadInvokerControl(AppHelper.MainForm, () =>
                    {
                        FrmTips.ShowTips(AppHelper.MainForm, msg, 2000, true, ContentAlignment.MiddleCenter, null, TipsSizeMode.Medium, new Size(300, 100), TipsState.Error);
                    });
                }
            }, null, AppHelper.MainForm, true, "正在查询……", 200);
        }