/// <summary> /// 4.销售 /// </summary> private void getXSListData() { KPS.BLL.XiaoShouManager manager = new BLL.XiaoShouManager(); try { string strDataTypeObj = string.Format("DataType={0}", DeviceInfo.DeviceID); System.Collections.ICollection _List = manager.GetModelList(strDataTypeObj); if (ListDataLoadingEndEvent != null) { ListDataLoadingEndEvent(_List, true, "获取列表成功"); } } catch (Exception ex) { if (ListDataLoadingEndEvent != null) { ListDataLoadingEndEvent(null, false, ex.Message); } } }
/// <summary> /// 开始处理 /// </summary> private void start() { string strSQL = ""; string strBeginTime = thiscondition.StartTime.ToString("yyyy-MM-dd 00:00:00"); string strEndTime = thiscondition.EndTime.ToString("yyyy-MM-dd 23:59:59"); List<SellRecordInfo> list = null; TotalSumInfo _suminfo = new TotalSumInfo(); #region 组织查询条件 string strKeyName = ""; switch (thiscondition.TotalType) { case SellTotalType.Customer: strKeyName = "p_gys"; strSQL = @"select p_gys,sum(p_sl1) as totalsl,sum(CCur(PSI_XiaoShou.p_sl2)*p_sl1) as totalje,sum(Profit*p_sl1) as totallr FROM (select PSI_XiaoShou.*,(CCur(PSI_XiaoShou.p_sl2)-CCur(PSI_GouJin.p_sl2)) as Profit from PSI_XiaoShou left join PSI_GouJin on PSI_XiaoShou.GJID=PSI_GouJin.ID)TabAA where (p_date>=#" + strBeginTime + "# and p_date<=#" + strEndTime + "#) and DataType=" +thiscondition.DeviceType+ " group by p_gys"; break; case SellTotalType.Product: strKeyName = "p_cpmc"; strSQL = @"select p_cpmc,sum(p_sl1) as totalsl,sum(CCur(PSI_XiaoShou.p_sl2)*p_sl1) as totalje,sum(Profit*p_sl1) as totallr FROM (select PSI_XiaoShou.*,(CCur(PSI_XiaoShou.p_sl2)-CCur(PSI_GouJin.p_sl2)) as Profit from PSI_XiaoShou left join PSI_GouJin on PSI_XiaoShou.GJID=PSI_GouJin.ID)TabAA where (p_date>=#" + strBeginTime + "# and p_date<=#" + strEndTime + "#) and DataType=" + thiscondition.DeviceType + " group by p_cpmc"; break; case SellTotalType.ProductAndType: strKeyName = "pgxh"; strSQL = @"select pgxh, sum(p_sl1) as totalsl,sum(CCur(PSI_XiaoShou.p_sl2)*p_sl1) as totalje,sum(Profit*p_sl1) as totallr FROM (select PSI_XiaoShou.*,(CCur(PSI_XiaoShou.p_sl2)-CCur(PSI_GouJin.p_sl2)) as Profit,(PSI_XiaoShou.p_cpmc&'+'&PSI_XiaoShou.p_ggxh) as pgxh from PSI_XiaoShou left join PSI_GouJin on PSI_XiaoShou.GJID=PSI_GouJin.ID)TabAA where (p_date>=#" + strBeginTime + "# and p_date<=#" + strEndTime + "#) and DataType=" + thiscondition.DeviceType + " group by pgxh"; break; default: break; } #endregion #region 数据查询 格式化 事件通知 返回记录 KPS.BLL.XiaoShouManager bll=new BLL.XiaoShouManager(); DataSet _ds = bll.GetDataBySQL(strSQL); if (_ds != null) { if (_ds.Tables[0].Rows.Count > 0) { SellRecordInfo _newrecord = null; list = new List<SellRecordInfo>(); int _Index = 1; foreach (DataRow _row in _ds.Tables[0].Rows) { _newrecord = FormatRecordByDataRow(_row, strKeyName); if (_newrecord != null) { _newrecord.SType = thiscondition.TotalType; _newrecord.SortNo = _Index; list.Add(_newrecord); _suminfo.TotalSumNumber += _newrecord.STotalNumber; _suminfo.TotalSumMoney += _newrecord.STotalMoney; _suminfo.TOtalSumProfit += _newrecord.SProfit; _Index++; } } if (QueryEndEvent != null) { QueryEndEvent(list,_suminfo, true,string.Format("共找到{0}条符合条件的记录!",list.Count)); } } else { if (QueryEndEvent != null) { QueryEndEvent(list, _suminfo, true, "未能找到符合条件的记录!"); } } } else { if (QueryEndEvent != null) { QueryEndEvent(list, _suminfo, false, "查询失败,查询结果格式错误!"); } } #endregion }
/// <summary> /// 开始处理 /// </summary> private void start() { string strSQL = ""; string strBeginTime = thiscondition.StartTime.ToString("yyyy-MM-dd 00:00:00"); string strEndTime = thiscondition.EndTime.ToString("yyyy-MM-dd 23:59:59"); List <SellRecordInfo> list = null; TotalSumInfo _suminfo = new TotalSumInfo(); #region 组织查询条件 string strKeyName = ""; switch (thiscondition.TotalType) { case SellTotalType.Customer: strKeyName = "p_gys"; strSQL = @"select p_gys,sum(p_sl1) as totalsl,sum(CCur(PSI_XiaoShou.p_sl2)*p_sl1) as totalje,sum(Profit*p_sl1) as totallr FROM (select PSI_XiaoShou.*,(CCur(PSI_XiaoShou.p_sl2)-CCur(PSI_GouJin.p_sl2)) as Profit from PSI_XiaoShou left join PSI_GouJin on PSI_XiaoShou.GJID=PSI_GouJin.ID)TabAA where (p_date>=#" + strBeginTime + "# and p_date<=#" + strEndTime + "#) and DataType=" + thiscondition.DeviceType + " group by p_gys"; break; case SellTotalType.Product: strKeyName = "p_cpmc"; strSQL = @"select p_cpmc,sum(p_sl1) as totalsl,sum(CCur(PSI_XiaoShou.p_sl2)*p_sl1) as totalje,sum(Profit*p_sl1) as totallr FROM (select PSI_XiaoShou.*,(CCur(PSI_XiaoShou.p_sl2)-CCur(PSI_GouJin.p_sl2)) as Profit from PSI_XiaoShou left join PSI_GouJin on PSI_XiaoShou.GJID=PSI_GouJin.ID)TabAA where (p_date>=#" + strBeginTime + "# and p_date<=#" + strEndTime + "#) and DataType=" + thiscondition.DeviceType + " group by p_cpmc"; break; case SellTotalType.ProductAndType: strKeyName = "pgxh"; strSQL = @"select pgxh, sum(p_sl1) as totalsl,sum(CCur(PSI_XiaoShou.p_sl2)*p_sl1) as totalje,sum(Profit*p_sl1) as totallr FROM (select PSI_XiaoShou.*,(CCur(PSI_XiaoShou.p_sl2)-CCur(PSI_GouJin.p_sl2)) as Profit,(PSI_XiaoShou.p_cpmc&'+'&PSI_XiaoShou.p_ggxh) as pgxh from PSI_XiaoShou left join PSI_GouJin on PSI_XiaoShou.GJID=PSI_GouJin.ID)TabAA where (p_date>=#" + strBeginTime + "# and p_date<=#" + strEndTime + "#) and DataType=" + thiscondition.DeviceType + " group by pgxh"; break; default: break; } #endregion #region 数据查询 格式化 事件通知 返回记录 KPS.BLL.XiaoShouManager bll = new BLL.XiaoShouManager(); DataSet _ds = bll.GetDataBySQL(strSQL); if (_ds != null) { if (_ds.Tables[0].Rows.Count > 0) { SellRecordInfo _newrecord = null; list = new List <SellRecordInfo>(); int _Index = 1; foreach (DataRow _row in _ds.Tables[0].Rows) { _newrecord = FormatRecordByDataRow(_row, strKeyName); if (_newrecord != null) { _newrecord.SType = thiscondition.TotalType; _newrecord.SortNo = _Index; list.Add(_newrecord); _suminfo.TotalSumNumber += _newrecord.STotalNumber; _suminfo.TotalSumMoney += _newrecord.STotalMoney; _suminfo.TOtalSumProfit += _newrecord.SProfit; _Index++; } } if (QueryEndEvent != null) { QueryEndEvent(list, _suminfo, true, string.Format("共找到{0}条符合条件的记录!", list.Count)); } } else { if (QueryEndEvent != null) { QueryEndEvent(list, _suminfo, true, "未能找到符合条件的记录!"); } } } else { if (QueryEndEvent != null) { QueryEndEvent(list, _suminfo, false, "查询失败,查询结果格式错误!"); } } #endregion }