private void btnSave_BtnClick(object sender, EventArgs e) { try { if (!validator1.Validate()) { return; } entityFiller.FillEntity(m_chargeDefine); m_chargeDefine.ItemName = combDefine.Text; m_chargeDefine.ItemCode = combDefine.SelectedValue.ToString(); ConstantApi constantApi = new ConstantApi(); var responseModel = constantApi.SaveChargeDefine(m_chargeDefine); //bool succ = _mssqlHelper.InsertOrUpdate(m_netTypeDefine, null, new string[] { "ID" }, null); if (responseModel.Code.Equals(1)) { FrmTips.ShowTipsSuccess(AppHelper.MainForm, "保存成功!", ContentAlignment.MiddleCenter, 1000); bIsUpdate = true; this.DialogResult = DialogResult.OK; this.Close(); } else { FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败!" + responseModel.Message, ContentAlignment.MiddleCenter, 1000); } } catch (Exception ex) { FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败!" + ex.Message, ContentAlignment.MiddleCenter, 1000); } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (dgv.CurrentRow == null || dgv.CurrentRow.Index < 0) { FrmTips.ShowTipsError(AppHelper.MainForm, "未选中任何行!", ContentAlignment.MiddleCenter, 1000); return; } ConstantType entity = CGridHelper.GetCurrentData <ConstantType>(dgv); ConstantApi constantApi = new ConstantApi(); var resp = constantApi.DeleteConstantType(entity.ID); //string sql = "DELETE ConstantType WHERE ID = @ID"; //Hashtable hashtable = new Hashtable(); //hashtable.Add("ID", entity.ID); //if (_mssqlHelper.ExcuteNonQuery(sql, hashtable) > 0) //{ if (resp.Code == 1) { FrmTips.ShowTipsSuccess(AppHelper.MainForm, "删除成功!", ContentAlignment.MiddleCenter, 1000); CGridHelper.DeleteRow(dgv); } else { FrmTips.ShowTipsError(AppHelper.MainForm, "删除失败!" + resp.Message, ContentAlignment.MiddleCenter, 1000); } } catch (Exception ex) { FrmTips.ShowTipsError(AppHelper.MainForm, "删除异常!" + ex.Message, ContentAlignment.MiddleCenter, 3000); } }
public FeeTools() { ConstantApi constantApi = new ConstantApi(); var resp = constantApi.GetChargeDefines(); if (resp.Code == 1 && resp.DataCount > 0) { m_chargeDefines = JsonConvert.DeserializeObject <List <ChargeDefine> >(resp.Data?.ToString()); } }
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); }
private void Init() { // ArrayList mylist = new ArrayList(); List <ConstantDefine> constantDefines = new List <ConstantDefine>(); ConstantApi constantApi = new ConstantApi(); var respType = constantApi.GetConstantDefines(); if (respType.Code == 1 && respType.DataCount > 0) { constantDefines = JsonConvert.DeserializeObject <List <ConstantDefine> >(respType.Data.ToString()).Where(p => p.TypeName.Equals("收费项目")).ToList(); } //foreach (var item in defines) //{ // mylist.Add(new DictionaryEntry(item.Code, item.TypeName)); //} combDefine.DataSource = constantDefines; combDefine.DisplayMember = "ConstantName"; combDefine.ValueMember = "ConsatntCode"; }
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); }