/// <summary> /// 删除实体 /// </summary> /// <param name="param">删除条件实体</param> /// <returns></returns> public WCFAddUpdateResult DelInfo(SYS_CurrencyParam param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); int affect = 0; try { #region 判断 if (param.RateTaxID == null) { throw new WarnException("请指定ID!"); } #endregion WhereClip whereClip = GetWhereClip(param); SYS_CurrencyResult info = new SYS_CurrencyResult(); info.IsDeleted = true; affect = this.Update <SYS_CurrencyResult>(info, whereClip); #region 设置返回值 ret.Key = affect; #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); } return(ret); }
private void tsbDel_Click(object sender, EventArgs e) { SYS_CurrencyParam param = new SYS_CurrencyParam(); param.RateTaxID = rateTaxID; SYS_CurrencyResult rst = currencyLogic.GetInfo(param); if (rst != null) { if (MessageBox.Show("请确认是否删除记录:【" + rst.CurrencyCode + "-" + rst.ExchangeRate + "-" + rst.RateDate + "】", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { WCFAddUpdateResult result = this.AsyncExecute <WCFAddUpdateResult, SYS_CurrencyParam>(param, currencyLogic.DelInfo, (a) => { if (a.Key > 0) { BindDataGridView(); } }); } } else { this.ShowMessage("请选择需要删除的数据字典!"); } }
public WCFAddUpdateResult DelInfo(SYS_CurrencyParam param) { WCFAddUpdateResult ret = new WCFAddUpdateResult(); ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.Sys.SYS_CurrencyBLL", "DelInfo", param); ret = (rst == null ? new WCFAddUpdateResult() : rst.Result as WCFAddUpdateResult); return(ret); }
public SYS_CurrencyResult GetInfo(SYS_CurrencyParam param) { SYS_CurrencyResult ret = new SYS_CurrencyResult(); ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.Sys.SYS_CurrencyBLL", "GetInfo", param); ret = (rst == null ? new SYS_CurrencyResult() : rst.Result as SYS_CurrencyResult); return(ret); }
public List <SYS_CurrencyResult> GetList(SYS_CurrencyParam param) { ExeResult rst = new ExeResult(); rst = this.Execute("ZNLCRM.BLL.Sys.SYS_CurrencyBLL", "GetList", param); List <SYS_CurrencyResult> list = new List <SYS_CurrencyResult>(); list = (rst == null ? new List <SYS_CurrencyResult>() : rst.Result as List <SYS_CurrencyResult>); return(list); }
/// <summary> /// 获取一条信息记录 /// </summary> /// <param name="param"></param> /// <returns></returns> public SYS_CurrencyResult GetInfo(SYS_CurrencyParam param) { this.CheckSession(); SYS_CurrencyResult rst = new SYS_CurrencyResult(); #region 判断 if (param.RateTaxID == null) { throw new WarnException("请指定ID!"); } #endregion #region 获取实体 rst = this.Select <SYS_CurrencyResult>(GetWhereClip(param)); #endregion return(rst); }
private void BindDataGridView() { try { SYS_CurrencyParam param = new SYS_CurrencyParam(); if (!string.IsNullOrEmpty(cboCurrency.Text)) { param.CurrencyCode = cboCurrency.SelectedValue.ToStringHasNull(); } List <SYS_CurrencyResult> rst = this.AsyncExecute <List <SYS_CurrencyResult>, SYS_CurrencyParam>(param, currencyLogic.GetList, a => { dgvCurrency.DataSource = a; }); } catch (Exception e) { this.ShowMessage(e.Message); } }
WhereClip GetWhereClip(SYS_CurrencyParam param) { this.CheckSession(); WhereClip where = SYS_Currency._.IsDeleted == 0; if (param.RateTaxID != null) { where = where && SYS_Currency._.RateTaxID == param.RateTaxID; } if (!string.IsNullOrEmpty(param.CurrencyCode)) { where = where && SYS_Currency._.CurrencyCode.Like("%" + param.CurrencyCode + "%"); } if (param.CurrencyCodes != null && param.CurrencyCodes.Length > 0) { where = where && SYS_Currency._.CurrencyCode.In(param.CurrencyCodes); } if (param.RateDate != null) { where = where && SYS_Currency._.RateDate >= param.RateDate; } return(where); }
public decimal?GetExchangeRate(DateTime?compareDate, string currency) { compareDate = compareDate.ToDateTime().Date.Add(new TimeSpan(23, 59, 59)); SYS_CurrencyParam param = new SYS_CurrencyParam() { GetLastRate = true, RateDate = compareDate, CurrencyCode = currency }; List <SYS_CurrencyResult> listRst = this.GetList(param); decimal?exchangeRate = null; try { if (listRst != null && listRst.Count > 0) { try { exchangeRate = listRst.OrderByDescending(a => a.RateDate).Select(a => a.ExchangeRate).FirstOrDefault(); } catch { exchangeRate = null; } } } catch (WarnException exp) { } if (exchangeRate != null) { return(exchangeRate); } else { return(null); } }
/// <summary> /// 获取集合 /// </summary> /// <param name="param"></param> /// <returns></returns> public List <SYS_CurrencyResult> GetList(SYS_CurrencyParam param) { this.CheckSession(); List <SYS_CurrencyResult> ret = new List <SYS_CurrencyResult>(); try { #region 取最近一条汇率记录 if (param.GetLastRate.ToBooleanHasNull()) { #region 获取条件下的最靠近的汇率 #region 获取条件下的最靠近的汇率的条件日期列表 WhereClip whereClip = GetWhereClip(param); List <SYS_CurrencyResult> lastRst = new List <SYS_CurrencyResult>(); List <Field> lstField = new List <Field>() { SYS_Currency._.CurrencyCode, SYS_Currency._.RateDate.Min().As("RateDate"), }; PageList <SYS_CurrencyResult> pageRst = this.SelectList <SYS_CurrencyResult>(1, 500, lstField , whereClip, null , new GroupByClip("CurrencyCode"), null); WhereClip whereClipLast = SYS_Currency._.IsDeleted == false; WhereClip whereClipLastEx = WhereClip.All; #endregion #region 生成取值条件 int countStep = -1; if (pageRst != null) { foreach (SYS_CurrencyResult info in pageRst.ResultList) { if (countStep == -1) { whereClipLastEx = (whereClipLastEx && SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate); } else { whereClipLastEx = whereClipLastEx || (SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate); } countStep++; } } #endregion #region 条件步骤 if (countStep >= 0) { whereClipLast = whereClipLast && (whereClipLastEx); lastRst = this.SelectList <SYS_CurrencyResult>(whereClipLast); foreach (SYS_CurrencyResult info in lastRst) { if (!ret.Exists(a => a.CurrencyCode == info.CurrencyCode && a.RateDate == info.RateDate)) { ret.Add(info); } } } #endregion #endregion #region 获取最近条件 #region 获取最后一次日期条件 lastRst = new List <SYS_CurrencyResult>(); lstField = new List <Field>() { SYS_Currency._.CurrencyCode, SYS_Currency._.RateDate.Max().As("RateDate"), }; pageRst = this.SelectList <SYS_CurrencyResult>(1, 500, lstField , SYS_Currency._.IsDeleted == false, null , new GroupByClip("CurrencyCode"), null); whereClipLast = SYS_Currency._.IsDeleted == false; whereClipLastEx = WhereClip.All; #endregion #region 组合最后一次日期条件 countStep = -1; if (pageRst != null) { foreach (SYS_CurrencyResult info in pageRst.ResultList) { if (countStep == -1) { whereClipLastEx = (whereClipLastEx && SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate); } else { whereClipLastEx = whereClipLastEx || (SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate); } countStep++; } } if (countStep >= 0) { whereClipLast = whereClipLast && (whereClipLastEx); } #endregion #endregion #region 获取最近条件,将结果进行组合,加入返回值 lastRst = this.SelectList <SYS_CurrencyResult>(whereClipLast); foreach (SYS_CurrencyResult info in lastRst) { if (!ret.Exists(a => a.CurrencyCode == info.CurrencyCode && a.RateDate == info.RateDate)) { ret.Add(info); } } #endregion } else { WhereClip whereClip = GetWhereClip(param); ret = this.SelectList <SYS_CurrencyResult>(whereClip, SYS_Currency._.CreatedTime.Asc); } #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }