/// <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>
 /// <param name="_sumInfo"></param>
 private void ShowTotalSumInfo(TotalSumInfo _sumInfo)
 {
     if (_sumInfo != null)
     {
         lblTotalNumber.Text = _sumInfo.TotalSumNumber.ToString();
         lblTotalMoney.Text = _sumInfo.TotalSumMoney.ToString();
         lblTotalProfit.Text = _sumInfo.TOtalSumProfit.ToString();
     }
 }
        /// <summary>
        /// 查询返回结果
        /// </summary>
        /// <param name="_recors"></param>
        /// <param name="_Succed"></param>
        /// <param name="_MsgInfo"></param>
        void manager_QueryEndEvent(List<SellRecordInfo> _recors,TotalSumInfo _sumInfo, bool _Succed, string _MsgInfo)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new SellRecordsQueryManager.DelSellRecordQueryEndArg(SellRecordListQueryEndManager), new object[] { _recors,_sumInfo, _Succed, _MsgInfo });

            }
            else
            {
                SellRecordListQueryEndManager(_recors,_sumInfo, _Succed, _MsgInfo);
            }
        }
        /// <summary>
        /// 列表显示
        /// </summary>
        /// <param name="_list"></param>
        /// <param name="_state"></param>
        /// <param name="_strMsg"></param>
        private void SellRecordListQueryEndManager(List<SellRecordInfo> _list,TotalSumInfo _sumInfo, bool _state, string _strMsg)
        {
            if (_state)
            {
                ListViewReloadData(_list);
                TolMsgInfo.Text = _strMsg;
            }
            else
            {
                TolMsgInfo.Text = _strMsg;
            }
            ShowTotalSumInfo(_sumInfo);

            SortpanalBar.Visible = false;//隐藏loading..
            CmboxDeviceClass.Enabled = true;
            ThisList = _list;
        }
Exemplo n.º 5
0
        /// <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
        }