/// <summary>
 /// 金额汇总
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void RgCompanyItemDataBound(object sender, GridItemEventArgs e)
 {
     //if (_cost <= 0)
     //{
     //if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
     //{
     //    var lab = e.Item.FindControl("Lab_RealityBalance") as Label;
     //    if (lab != null)
     //        if (!string.IsNullOrEmpty(lab.Text))
     //        {
     //            _amount += Convert.ToDecimal(lab.Text);
     //        }
     //    //
     //    var labPay = e.Item.FindControl("LabPayRealityBalance") as Label;
     //    if (labPay != null)
     //        if (!string.IsNullOrEmpty(labPay.Text))
     //        {
     //            _payAmount += Convert.ToDecimal(labPay.Text);
     //        }
     //}
     //}
     if (e.Item.ItemType == GridItemType.Footer)
     {
         var tbTotalAmount = e.Item.FindControl("TB_TotalAmount") as Label;
         if (tbTotalAmount != null)
         {
             tbTotalAmount.Text += string.Format("合计:{0} 元", WebControl.NumberSeparator(_amount));// "计算的总数,或者也可以单独计算 ";//
         }
         var tbPayTotalAmount = e.Item.FindControl("TbTotalAmount") as Label;
         if (tbPayTotalAmount != null)
         {
             tbPayTotalAmount.Text += string.Format("合计:{0} 元", WebControl.NumberSeparator(_payAmount));// "计算的总数,或者也可以单独计算 ";//
         }
     }
 }
Exemple #2
0
 public string ShowStr(object filialeId, object money, object other)
 {
     if (money == null)
     {
         return(string.Empty);
     }
     if (money.ToString().Length == 0)
     {
         return(string.Empty);
     }
     if (Convert.ToDecimal(money) == 0)
     {
         return(string.Empty);
     }
     return(string.Format("{0}[{1}]", WebControl.NumberSeparator(money), WebControl.NumberSeparator(other)));
 }
        protected void StockGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            decimal total         = 0;
            int     totalQuantity = 0;

            if (IsPostBack)
            {
                WarehouseId = new Guid(RCB_Warehouse.SelectedValue);
                var goodsList = _storageRecordDao.GetGoodsOutInStorageStatisticsList(StorageType, StartTime, EndTime, CompanyId, GlobalConfig.KeepYear, HostingFilialeId, WarehouseId);
                StockGrid.DataSource = goodsList;
                foreach (var goodsOutInStorageStatisticsInfo in goodsList)
                {
                    if (goodsOutInStorageStatisticsInfo.StorageType == (int)StorageRecordType.BuyStockIn ||
                        goodsOutInStorageStatisticsInfo.StorageType == (int)StorageRecordType.BorrowIn ||
                        goodsOutInStorageStatisticsInfo.StorageType == (int)StorageRecordType.LendIn ||
                        goodsOutInStorageStatisticsInfo.StorageType == (int)StorageRecordType.SellReturnIn)
                    {
                        total         += Math.Abs(goodsOutInStorageStatisticsInfo.TotalPrice);
                        totalQuantity += goodsOutInStorageStatisticsInfo.Quantity;
                    }
                    if (goodsOutInStorageStatisticsInfo.StorageType == (int)StorageRecordType.BuyStockOut ||
                        goodsOutInStorageStatisticsInfo.StorageType == (int)StorageRecordType.AfterSaleOut ||
                        goodsOutInStorageStatisticsInfo.StorageType == (int)StorageRecordType.BorrowOut ||
                        goodsOutInStorageStatisticsInfo.StorageType == (int)StorageRecordType.LendOut ||
                        goodsOutInStorageStatisticsInfo.StorageType == (int)StorageRecordType.SellStockOut)
                    {
                        total         -= Math.Abs(goodsOutInStorageStatisticsInfo.TotalPrice);
                        totalQuantity -= goodsOutInStorageStatisticsInfo.Quantity;
                    }
                }
                TotalAmount   = WebControl.NumberSeparator(total);
                TotalQuantity = WebControl.NumberSeparator(totalQuantity);
            }
            else
            {
                StockGrid.DataSource = new List <GoodsOutInStorageStatisticsInfo>();
                TotalAmount          = "0";
            }
            var totalPrice = StockGrid.MasterTableView.Columns.FindByUniqueName("ToalAmount");
            var quantity   = StockGrid.MasterTableView.Columns.FindByUniqueName("Quantity");

            totalPrice.FooterText = total > 0 ? string.Format("合计:{0}", WebControl.NumberSeparator(total)) : string.Empty;
            quantity.FooterText   = totalQuantity > 0 ? string.Format("合计:{0}", WebControl.NumberSeparator(totalQuantity)) : string.Empty;
        }
Exemple #4
0
        protected void RgCheckInfoNeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            IList <CompanyFundReceiptInfo> list = _companyFundReceipt.GetAllFundReceiptInfoList(new Guid(SelectSaleFilialeId), ReceiptPage.DoReceivePay, Status,
                                                                                                StartTime, EndTime, ReceiptNo, Type).ToList();

            if (BankId != Guid.Empty)
            {
                list = list.Where(ent => ent.PayBankAccountsId == BankId).ToList();
            }
            if (SExecuteTime != DateTime.MinValue)
            {
                list = list.Where(c => c.ExecuteDateTime >= SExecuteTime).ToList();
            }
            if (EExecuteTime != DateTime.MaxValue)
            {
                list = list.Where(c => c.ExecuteDateTime < EExecuteTime).ToList();
            }
            if (list.Count != 0)
            {
                CompanyFundReceiptsList = list;
            }
            if (list.Count > 0)
            {
                BankIds = list.Where(ent => ent.PayBankAccountsId != Guid.Empty).Select(ent => ent.PayBankAccountsId).ToList();
            }
            //合计金额
            var sum = RG_CheckInfo.MasterTableView.Columns.FindByUniqueName("RealityBalance");

            if (list.Count > 0)
            {
                var realityBalanceSum = list.Sum(ent => Math.Abs(ent.RealityBalance));
                sum.FooterText = string.Format("合计:{0}", WebControl.NumberSeparator(realityBalanceSum));
            }
            else
            {
                sum.FooterText = string.Empty;
            }
            RG_CheckInfo.DataSource = list;
        }
        private void ShowFooterText(IList <CompanyFundReceiptInfo> list)
        {
            //待索取发票合计显示列(申请金额)
            var realityBalanceColumn = RG_CheckInfo.MasterTableView.Columns.FindByUniqueName("RealityBalance");
            //待认证发票合计显示列(打款日期)
            var finishDateColumn = RG_CheckInfo.MasterTableView.Columns.FindByUniqueName("FinishDate");

            if (list.Count > 0)
            {
                //发票待索取合计
                var sum1 = list.Where(ent => ent.ReceiptStatus == (int)CompanyFundReceiptState.GettingInvoice).Sum(
                    ent => ent.RealityBalance);
                //发票待认证合计
                var sum2 = list.Where(ent => ent.ReceiptStatus == (int)CompanyFundReceiptState.WaitAttestation).Sum(
                    ent => ent.RealityBalance);
                realityBalanceColumn.FooterText = "待索取发票合计:" + WebControl.NumberSeparator(sum1);
                finishDateColumn.FooterText     = "待认证发票合计:" + WebControl.NumberSeparator(sum2);
            }
            else
            {
                realityBalanceColumn.FooterText = "待索取发票合计:0.00";
                finishDateColumn.FooterText     = "待认证发票合计:0.00";
            }
        }
Exemple #6
0
        /// <summary>显示合计金额信息
        /// </summary>
        private void ShowFooterText()
        {
            var filialeName = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("FilialeName");

            filialeName.FooterText = "每月合计:";
            filialeName.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            var jan = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("January");

            jan.FooterText = _dicSum.ContainsKey(1) ? _dicSum[1] == 0 ? "0" : string.Format("{0}", WebControl.NumberSeparator(_dicSum[1])) : string.Empty;

            var feb = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("February");

            feb.FooterText = _dicSum.ContainsKey(2) ? _dicSum[2] == 0 ? "0" : string.Format("{0}", WebControl.NumberSeparator(_dicSum[2])) : string.Empty;

            var mar = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("March");

            mar.FooterText = _dicSum.ContainsKey(3) ? _dicSum[3] == 0 ? "0" : string.Format("{0}", WebControl.NumberSeparator(_dicSum[3])) : string.Empty;

            var apr = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("April");

            apr.FooterText = _dicSum.ContainsKey(4) ? _dicSum[4] == 0 ? "0" : string.Format("{0}", WebControl.NumberSeparator(_dicSum[4])) : string.Empty;

            var may = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("May");

            may.FooterText = _dicSum.ContainsKey(5) ? _dicSum[5] == 0 ? "0"  : string.Format("{0}", WebControl.NumberSeparator(_dicSum[5])) : string.Empty;

            var jun = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("June");

            jun.FooterText = _dicSum.ContainsKey(6) ? _dicSum[6] == 0 ? "0" : string.Format("{0}", WebControl.NumberSeparator(_dicSum[6])) : string.Empty;

            var july = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("July");

            july.FooterText = _dicSum.ContainsKey(7) ? _dicSum[7] == 0 ? "0" : string.Format("{0}", WebControl.NumberSeparator(_dicSum[7])) : string.Empty;

            var aug = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("August");

            aug.FooterText = _dicSum.ContainsKey(8) ? _dicSum[8] == 0 ? "0" : string.Format("{0}", WebControl.NumberSeparator(_dicSum[8])) : string.Empty;

            var sept = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("September");

            sept.FooterText = _dicSum.ContainsKey(9) ? _dicSum[9] == 0 ? "0" : string.Format("{0}", WebControl.NumberSeparator(_dicSum[9])) : string.Empty;

            var oct = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("October");

            oct.FooterText = _dicSum.ContainsKey(10) ? _dicSum[10] == 0 ? "0" : string.Format("{0}", WebControl.NumberSeparator(_dicSum[10])) : string.Empty;

            var nov = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("November");

            nov.FooterText = _dicSum.ContainsKey(11) ? _dicSum[11] == 0 ? "0" : string.Format("{0}", WebControl.NumberSeparator(_dicSum[11])) : string.Empty;

            var december = RgPurchaseInStockStatistics.MasterTableView.Columns.FindByUniqueName("December");

            december.FooterText = _dicSum.ContainsKey(12) ? _dicSum[12] == 0 ? "0" : string.Format("{0}", WebControl.NumberSeparator(_dicSum[12])) : string.Empty;
        }
Exemple #7
0
        //Grid数据源
        protected void GridDataBind()
        {
            #region 查询条件
            Guid     filialeId          = Guid.Empty;
            Guid     companyId          = Guid.Empty;
            DateTime?startApplyDateTime = null;
            DateTime?endApplyDateTime   = null;
            string   receiptStatus      = string.Empty;
            string   receiptNo          = string.Empty;
            string   invoiceNo          = string.Empty;
            int?     invoiceState       = null;
            int?     invoiceType        = null;
            DateTime?startOperatingTime = null;
            DateTime?endOperatingTime   = null;
            string   billingUnit        = string.Empty;
            int      pageIndex          = RG_ReceiptInvoice.CurrentPageIndex + 1;
            int      pageSize           = RG_ReceiptInvoice.PageSize;
            if (!string.IsNullOrEmpty(ddl_SaleFiliale.SelectedValue))
            {
                filialeId = new Guid(ddl_SaleFiliale.SelectedValue);
            }
            if (!string.IsNullOrEmpty(rcb_CompanyList.SelectedValue))
            {
                companyId = new Guid(rcb_CompanyList.SelectedValue);
            }
            if (!string.IsNullOrEmpty(txt_ApplyDateTimeStart.Text))
            {
                startApplyDateTime = DateTime.Parse(txt_ApplyDateTimeStart.Text);
            }
            if (!string.IsNullOrEmpty(txt_ApplyDateTimeEnd.Text))
            {
                endApplyDateTime = DateTime.Parse(txt_ApplyDateTimeEnd.Text).AddDays(1);
            }
            if (!string.IsNullOrEmpty(ddl_PayState.SelectedValue))
            {
                receiptStatus = ddl_PayState.SelectedValue;
            }
            if (!string.IsNullOrEmpty(txt_ReceipNo.Text))
            {
                receiptNo = txt_ReceipNo.Text;
            }
            if (!string.IsNullOrEmpty(txt_InvoiceNo.Text))
            {
                invoiceNo = txt_InvoiceNo.Text;
            }
            if (!string.IsNullOrEmpty(ddl_InvoiceState.SelectedValue))
            {
                invoiceState = int.Parse(ddl_InvoiceState.SelectedValue);
            }
            if (!string.IsNullOrEmpty(txt_OperatingTimeStart.Text))
            {
                startOperatingTime = DateTime.Parse(txt_OperatingTimeStart.Text);
            }
            if (!string.IsNullOrEmpty(txt_OperatingTimeEnd.Text))
            {
                endOperatingTime = DateTime.Parse(txt_OperatingTimeEnd.Text).AddDays(1);
            }
            if (!string.IsNullOrEmpty(txt_BillingUnit.Text))
            {
                billingUnit = txt_BillingUnit.Text;
            }
            if (!string.IsNullOrEmpty(ddl_InvoiceType.SelectedValue))
            {
                invoiceType = int.Parse(ddl_InvoiceType.SelectedValue);
            }
            #endregion

            int total;
            var data = _companyFundReceiptInvoice.Getlmshop_CompanyFundReceiptInvoiceByPage(filialeId, companyId,
                                                                                            startApplyDateTime, endApplyDateTime, receiptStatus, receiptNo, invoiceNo, invoiceState,
                                                                                            startOperatingTime, endOperatingTime, billingUnit, invoiceType, pageIndex, pageSize, out total);

            #region 合计
            DataTable result  = GetDataTable(data);
            var       sumData = result.AsEnumerable();

            var noTaxAmount = RG_ReceiptInvoice.MasterTableView.Columns.FindByUniqueName("NoTaxAmount");
            var tax         = RG_ReceiptInvoice.MasterTableView.Columns.FindByUniqueName("Tax");
            var taxAmount   = RG_ReceiptInvoice.MasterTableView.Columns.FindByUniqueName("TaxAmount");
            var invoiceNum  = RG_ReceiptInvoice.MasterTableView.Columns.FindByUniqueName("InvoiceNum");
            if (sumData.Any())
            {
                var sumNoTaxAmount = sumData.Sum(r => r.Field <decimal>("NoTaxAmount"));
                var sumTax         = sumData.Sum(r => r.Field <decimal>("Tax"));
                var sumTaxAmount   = sumData.Sum(r => r.Field <decimal>("TaxAmount"));
                if (!string.IsNullOrEmpty(ddl_InvoiceType.SelectedValue))
                {
                    if (int.Parse(ddl_InvoiceType.SelectedValue) == 5)
                    {
                        noTaxAmount.FooterText = string.Format("未税金额:{0}", WebControl.NumberSeparator(sumNoTaxAmount));
                        tax.FooterText         = string.Format("税额:{0}", WebControl.NumberSeparator(sumTax));
                    }
                    else
                    {
                        noTaxAmount.FooterText = String.Empty;
                        tax.FooterText         = String.Empty;
                    }
                }
                else
                {
                    noTaxAmount.FooterText = string.Format("未税金额:{0}", WebControl.NumberSeparator(sumNoTaxAmount));
                    tax.FooterText         = string.Format("税额:{0}", WebControl.NumberSeparator(sumTax));
                }
                taxAmount.FooterText  = string.Format("含税金额:{0}", WebControl.NumberSeparator(sumTaxAmount));
                invoiceNum.FooterText = "发票数量:" + sumData.Count();//sumData.Select(r => r.Field<int>("InvoiceTotal")).FirstOrDefault();
            }
            else
            {
                noTaxAmount.FooterText = string.Empty;
                tax.FooterText         = string.Empty;
                taxAmount.FooterText   = string.Empty;
            }

            #endregion

            RG_ReceiptInvoice.DataSource       = data;
            RG_ReceiptInvoice.VirtualItemCount = total;
        }
        protected void Rad_invoce_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            if (!IsPostBack)
            {
                rad_invoce.DataSource = new List <InvoiceBriefInfo>();
                return;
            }
            if (RDP_StartTime.SelectedDate != null && RDP_EndTime.SelectedDate != null)
            {
                var    filialeId = new Guid(RCB_FilialeList.SelectedValue);
                string invoiceNo = string.Empty;
                if (!string.IsNullOrEmpty(tbx_keyword.Text.Trim()))
                {
                    invoiceNo = tbx_keyword.Text.Trim();
                }

                var pageSize  = rad_invoce.PageSize;
                var pageIndex = rad_invoce.CurrentPageIndex + 1;
                int recordCount;

                var    kindType = Convert.ToByte(RcbKindType.SelectedValue);
                var    flag     = kindType == (Byte)InvoiceKindType.Electron;
                string msg;
                InvoiceStatisticsInfo = flag ? GetStatisticsInfo(EndTime, Convert.ToInt32(RCB_NoteType.SelectedValue), filialeId, invoiceNo.ToString(), StartTime, pageIndex, pageSize, out msg, out recordCount)
                    : Invoice.ReadInstance.Search(StartTime, EndTime, filialeId, Convert.ToInt32(RCB_NoteType.SelectedValue), invoiceNo, pageSize, pageIndex, out recordCount);
                rad_invoce.DataSource       = InvoiceStatisticsInfo.InvoiceList;
                rad_invoce.VirtualItemCount = recordCount;

                //正票
                var zpInfo = InvoiceStatisticsInfo.NoteStatistics.FirstOrDefault(ent => ent.NoteType == InvoiceNoteType.Effective);
                //废票
                var fpInfo = InvoiceStatisticsInfo.NoteStatistics.FirstOrDefault(ent => ent.NoteType == InvoiceNoteType.Abolish);

                if (flag)
                {
                    lb_lp.Text = zpInfo != null?string.Format("{0}", zpInfo.TotalQuantity) : "0";

                    lb_lpsum.Text = zpInfo != null?WebControl.NumberSeparator(zpInfo.TotalMoney.ToString("#.##")) : "0.00";


                    lb_hp.Text = fpInfo != null?string.Format("{0}", fpInfo.TotalQuantity) : "0";

                    lb_hpsum.Text = fpInfo != null?WebControl.NumberSeparator(fpInfo.TotalMoney.ToString("#.##")) : "0.00";

                    var sum = zpInfo?.TotalMoney - (fpInfo?.TotalMoney ?? 0);
                    //实际金额
                    lb_tolsum.Text = WebControl.NumberSeparator(sum ?? 0);
                }
                else
                {
                    lab_zp.Text = zpInfo != null?string.Format("{0}", zpInfo.TotalQuantity) : "0";

                    lab_zpsum.Text = zpInfo != null?WebControl.NumberSeparator(zpInfo.TotalMoney.ToString("#.##")) : "0.00";


                    lab_fp.Text = fpInfo != null?string.Format("{0}", fpInfo.TotalQuantity) : "0";

                    Label_fpje.Text = fpInfo != null?WebControl.NumberSeparator(fpInfo.TotalMoney.ToString("#.##")) : "0.00";

                    //退票
                    var tpInfo = InvoiceStatisticsInfo.NoteStatistics.FirstOrDefault(ent => ent.NoteType == InvoiceNoteType.Retreat);
                    Label_tpzs.Text = tpInfo != null?string.Format("{0}", tpInfo.TotalQuantity) : "0";

                    Label_tpje.Text = tpInfo != null?WebControl.NumberSeparator(tpInfo.TotalMoney.ToString("#.##")) : "0.00";

                    //实际金额
                    lab_tol.Text = WebControl.NumberSeparator((zpInfo != null ? zpInfo.TotalMoney : 0) + (tpInfo != null ? tpInfo.TotalMoney : 0));
                }
            }
            else
            {
                rad_invoce.DataSource = new List <InvoiceBriefInfo>();
            }
        }
Exemple #9
0
        //Grid数据源
        protected void GridDataBind()
        {
            try
            {
                IList <GoodsGrossProfitInfo> dataList = new List <GoodsGrossProfitInfo>();
                List <GoodsGrossProfitInfo>  sumSaleFilialeDataList = new List <GoodsGrossProfitInfo>();//汇总同一商品同一公司不同平台的数据
                Guid     saleFilialeId = string.IsNullOrEmpty(Rcb_SaleFiliale.SelectedValue) ? Guid.Empty : new Guid(Rcb_SaleFiliale.SelectedValue);
                DateTime startTime;
                DateTime endTime;
                if (ddl_TimeType.SelectedValue == "1")//当月查询
                {
                    startTime = DateTime.Parse(txt_StartTime.Text);
                    endTime   = DateTime.Now;
                    if (!string.IsNullOrEmpty(txt_EndTime.Text))
                    {
                        endTime = DateTime.Parse(txt_EndTime.Text);
                    }
                    endTime = endTime.AddDays(1);

                    #region 汇总同一商品同一公司不同平台的数据
                    if (saleFilialeId.Equals(Guid.Empty) && !ckb_GoodsType.Checked)
                    {
                        sumSaleFilialeDataList = _goodsGrossProfitRecordDetailBll.SumGoodsGrossProfitByGoodsIdAndSaleFilialeId(startTime, endTime, Hid_GoodsType.Value, txt_GoodsCode.Text, saleFilialeId, Hid_SalePlatform.Value, Hid_OrderType.Value).ToList();
                    }
                    #endregion
                    else
                    {
                        dataList = _goodsGrossProfitRecordDetailBll.SumGoodsGrossProfitRecordDetailInfos(startTime, endTime, Hid_GoodsType.Value, txt_GoodsCode.Text, saleFilialeId, Hid_SalePlatform.Value, Hid_OrderType.Value);
                    }
                }
                else if (ddl_TimeType.SelectedValue == "0")
                {
                    startTime = DateTime.Parse(txt_YearAndMonth.Text);
                    if (startTime.AddMonths(1).Equals(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01"))))
                    {
                        endTime = startTime.AddMonths(1);

                        #region 汇总同一商品同一公司不同平台的数据
                        if (saleFilialeId.Equals(Guid.Empty) && !ckb_GoodsType.Checked)
                        {
                            sumSaleFilialeDataList = _goodsGrossProfitRecordDetailBll.SumGoodsGrossProfitByGoodsIdAndSaleFilialeId(startTime, endTime, Hid_GoodsType.Value, txt_GoodsCode.Text, saleFilialeId, Hid_SalePlatform.Value, Hid_OrderType.Value).ToList();
                        }
                        #endregion
                        else
                        {
                            dataList = _goodsGrossProfitRecordDetailBll.SumGoodsGrossProfitRecordDetailInfos(startTime, endTime, Hid_GoodsType.Value, txt_GoodsCode.Text, saleFilialeId, Hid_SalePlatform.Value, Hid_OrderType.Value);
                        }
                    }
                    else
                    {
                        #region 汇总同一商品同一公司不同平台的数据
                        if (saleFilialeId.Equals(Guid.Empty) && !ckb_GoodsType.Checked)
                        {
                            sumSaleFilialeDataList = _goodsGrossProfitBll.SumGoodsGrossProfitFromMonthByGoodsIdAndSaleFilialeId(startTime, DateTime.MinValue, Hid_GoodsType.Value, txt_GoodsCode.Text, saleFilialeId, Hid_SalePlatform.Value, Hid_OrderType.Value).ToList();
                        }
                        #endregion
                        else
                        {
                            dataList = _goodsGrossProfitBll.SelectGoodsGrossProfitInfos(startTime, DateTime.MinValue, Hid_GoodsType.Value, txt_GoodsCode.Text, saleFilialeId, Hid_SalePlatform.Value, Hid_OrderType.Value);
                        }
                    }
                }

                RG_GrossProfit.Columns[0].Visible = true;
                RG_GrossProfit.Columns[1].Visible = true;
                RG_GrossProfit.Columns[2].Visible = false;
                RG_GrossProfit.Columns[7].Visible = true;
                RG_GrossProfit.Columns[9].Visible = true;
                IList <GoodsGrossProfitInfo> list = dataList;
                if (saleFilialeId.Equals(Guid.Empty))
                {
                    list = sumSaleFilialeDataList;
                    RG_GrossProfit.Columns[7].Visible = false;
                    RG_GrossProfit.Columns[9].Visible = false;
                }
                if (ckb_GoodsType.Checked)
                {
                    #region 汇总同一商品类型同一公司不同平台的数据
                    List <GoodsGrossProfitInfo> sumGoodsTypeDataList = new List <GoodsGrossProfitInfo>();
                    if (dataList.Any())
                    {
                        foreach (var item in dataList)
                        {
                            var info = sumGoodsTypeDataList.FirstOrDefault(act => act.GoodsType == item.GoodsType && act.SaleFilialeId == item.SaleFilialeId);
                            if (info != null)
                            {
                                info.SalesPriceTotal   += item.SalesPriceTotal;
                                info.PurchaseCostTotal += item.PurchaseCostTotal;
                                info.Quantity          += item.Quantity;
                            }
                            else
                            {
                                sumGoodsTypeDataList.Add(new GoodsGrossProfitInfo
                                {
                                    GoodsId           = Guid.Empty,
                                    SaleFilialeId     = item.SaleFilialeId,
                                    SalePlatformId    = Guid.Empty,
                                    OrderType         = -1,
                                    SalesPriceTotal   = item.SalesPriceTotal,
                                    PurchaseCostTotal = item.PurchaseCostTotal,
                                    Quantity          = item.Quantity,
                                    GoodsName         = string.Empty,
                                    GoodsCode         = string.Empty,
                                    GoodsType         = item.GoodsType
                                });
                            }
                        }
                    }
                    #endregion

                    list = sumGoodsTypeDataList;
                    RG_GrossProfit.Columns[0].Visible = false;
                    RG_GrossProfit.Columns[1].Visible = false;
                    RG_GrossProfit.Columns[2].Visible = true;
                    RG_GrossProfit.Columns[7].Visible = false;
                    RG_GrossProfit.Columns[9].Visible = false;
                }

                RG_GrossProfit.DataSource = list.OrderByDescending(act => act.SaleFilialeId).ThenByDescending(act => act.SalesPriceTotal);

                #region 合计
                var salesPriceTotal   = RG_GrossProfit.MasterTableView.Columns.FindByUniqueName("SalesPriceTotal");
                var purchaseCostTotal = RG_GrossProfit.MasterTableView.Columns.FindByUniqueName("PurchaseCostTotal");
                var grossProfit       = RG_GrossProfit.MasterTableView.Columns.FindByUniqueName("GrossProfit");
                var grossProfitMargin = RG_GrossProfit.MasterTableView.Columns.FindByUniqueName("GrossProfitMargin");

                if (list.Any())
                {
                    var sumPurchaseCostTotal = list.Sum(act => act.PurchaseCostTotal);
                    var sumSalesPriceTotal   = list.Sum(act => act.SalesPriceTotal);
                    var sumGrossProfit       = sumSalesPriceTotal - sumPurchaseCostTotal;
                    var sumGrossProfitMargin = sumGrossProfit / sumSalesPriceTotal;

                    salesPriceTotal.FooterText   = " 合 计:" + string.Format("{0}", WebControl.NumberSeparator(sumSalesPriceTotal));
                    purchaseCostTotal.FooterText = string.Format("{0}", WebControl.NumberSeparator(sumPurchaseCostTotal));
                    grossProfit.FooterText       = string.Format("{0}", WebControl.NumberSeparator(sumGrossProfit));
                    grossProfitMargin.FooterText = string.Format("{0}{1}", (sumGrossProfitMargin * 100).ToString("F"), "%");
                }
                else
                {
                    salesPriceTotal.FooterText   = string.Empty;
                    purchaseCostTotal.FooterText = string.Empty;
                    grossProfit.FooterText       = string.Empty;
                    grossProfitMargin.FooterText = string.Empty;
                }
                #endregion
            }
            catch (Exception ex)
            {
                SAL.LogCenter.LogService.LogError("商品毛利查询异常", "财务管理", ex);
            }
        }
Exemple #10
0
        //Grid数据源
        protected void GridDataBind()
        {
            List <CompanyFundReceiptInfo> list = _companyFundReceipt.GetAllFundReceiptInfoList(new Guid(SelectSaleFilialeId), ReceiptPage.PayCheckList,
                                                                                               Status, StartTime, EndTime, ReceiptNo, CompanyFundReceiptType.Payment).ToList();

            if (RT_CompanyClass.SelectedNode != null)
            {
                RadTreeNode currentNode = RT_CompanyClass.SelectedNode;
                //门店类型节点与店铺节点选择时数据绑定
                //modify by liangcanren at 2015-03-16
                var isShopJoinType = currentNode.Value.Length == Guid.Empty.ToString().Length;
                var companyClassId = isShopJoinType ? new Guid(currentNode.Value) : Guid.Empty;
                var shopList       = CacheCollection.Filiale.GetShopList();
                if (!isShopJoinType)
                {
                    shopList = shopList.Where(act => string.Format("{0}", act.ShopJoinType) == currentNode.Value).ToList();
                    if (shopList.Count != 0)
                    {
                        list = list.Where(c => shopList.Any(act => act.ID == c.CompanyID)).ToList();
                    }
                }
                else
                {
                    if (shopList.Any(act => act.ID == companyClassId))
                    {
                        list = list.Where(c => c.CompanyID == companyClassId).ToList();
                    }
                    else
                    {
                        if (companyClassId != Guid.Empty)
                        {
                            List <Guid> companylist = _companyCussent.GetCompanyCussentList(companyClassId).Select(cl => cl.CompanyId).ToList();
                            list = list.Where(c => companylist.Contains(c.CompanyID)).ToList();
                        }
                    }
                }
            }

            if (BankId != Guid.Empty)
            {
                list = list.Where(ent => ent.PayBankAccountsId == BankId).ToList();
            }
            if (PayType != -1)
            {
                if (PayType == 0)
                {
                    list = list.Where(c => string.IsNullOrEmpty(c.PurchaseOrderNo) && string.IsNullOrEmpty(c.StockOrderNos) &&
                                      c.SettleEndDate != DateTime.Parse("1999-09-09")).ToList();
                }
                if (PayType == 1)
                {
                    list = list.Where(c => !string.IsNullOrEmpty(c.StockOrderNos)).ToList();
                }
                if (PayType == 2)
                {
                    list = list.Where(c => !string.IsNullOrEmpty(c.PurchaseOrderNo)).ToList();
                }
                if (PayType == 3)
                {
                    list = list.Where(c => string.IsNullOrEmpty(c.PurchaseOrderNo) && string.IsNullOrEmpty(c.StockOrderNos) &&
                                      c.SettleStartDate == DateTime.Parse("1999-09-09")).ToList();
                }
                if (PayType == 4)
                {
                    list = list.Where(ent => ent.SettleStartDate == DateTime.Parse("1999-09-09")).ToList();
                }
            }

            if (!string.IsNullOrEmpty(txt_PaymentDate.Text))
            {
                list = list.Where(p => Convert.ToDateTime(p.PaymentDate).ToString("yyyy-MM").Equals(txt_PaymentDate.Text)).ToList();
            }

            if (!string.IsNullOrEmpty(RCB_CompanyList.SelectedValue))
            {
                list = list.Where(p => p.CompanyID.Equals(new Guid(RCB_CompanyList.SelectedValue))).ToList();
            }
            if (!string.IsNullOrEmpty(rcb_Applicant.SelectedValue) && !rcb_Applicant.SelectedValue.Equals(Guid.Empty.ToString()))
            {
                list = list.Where(p => p.ApplicantID.Equals(new Guid(rcb_Applicant.SelectedValue))).ToList();
            }

            //合计金额
            var sum = RG_CheckInfo.MasterTableView.Columns.FindByUniqueName("RealityBalance");

            if (list.Count > 0)
            {
                var realityBalanceSum = list.Sum(ent => Math.Abs(ent.RealityBalance));
                sum.FooterText = string.Format("合计:{0}", WebControl.NumberSeparator(realityBalanceSum));
            }
            else
            {
                sum.FooterText = string.Empty;
            }
            RG_CheckInfo.DataSource = list;
        }
        //Grid数据源
        protected void GridDataBind()
        {
            var costReportList = _costReport.GetReportList(Personnel.PersonnelId).OrderByDescending(r => r.ReportDate);
            var query          = costReportList.AsQueryable();

            #region 查询条件
            if (!string.IsNullOrEmpty(txt_ReportNo.Text))
            {
                query = query.Where(p => p.ReportNo.Equals(txt_ReportNo.Text.Trim()));
            }
            if (!string.IsNullOrEmpty(txt_ReportDateStart.Text))
            {
                var startTime = DateTime.Parse(txt_ReportDateStart.Text);
                query = query.Where(p => p.ReportDate >= startTime);
            }
            if (!string.IsNullOrEmpty(txt_ReportDateEnd.Text))
            {
                var endtime = DateTime.Parse(txt_ReportDateEnd.Text);
                query = query.Where(p => p.ReportDate < endtime.AddDays(1));
            }

            if (!string.IsNullOrEmpty(txt_ReportName.Text))
            {
                query = query.Where(p => p.ReportName.Contains(txt_ReportName.Text.Trim()));
            }

            switch (ddl_State.SelectedValue)
            {
            case "0":     //已处理
                query = query.Where(p =>
                                    p.State == (int)CostReportState.AuditingNoPass ||
                                    p.State == (int)CostReportState.InvoiceNoPass ||
                                    p.State == (int)CostReportState.Complete);
                break;

            case "1":     //未处理
                query = query.Where(p =>
                                    p.State == (int)CostReportState.Auditing ||
                                    p.State == (int)CostReportState.NoAuditing ||
                                    p.State == (int)CostReportState.AlreadyAuditing ||
                                    p.State == (int)CostReportState.WaitVerify ||
                                    p.State == (int)CostReportState.Pay ||
                                    p.State == (int)CostReportState.CompletedMayApply);
                break;

            case "-1":     //全部
                break;

            default:
                query = query.Where(p => p.State != (int)CostReportState.Complete);
                break;
            }
            #endregion

            #region 合计
            var totalName  = RG_Report.MasterTableView.Columns.FindByUniqueName("TotalName");
            var reportCost = RG_Report.MasterTableView.Columns.FindByUniqueName("ReportCost");
            var payCost    = RG_Report.MasterTableView.Columns.FindByUniqueName("PayCost");
            if (query.Any())
            {
                var sumReportCost = query.Sum(p => Math.Abs(p.ReportCost));
                var sumPayCost    = query.Sum(p => Math.Abs(p.PayCost));
                totalName.FooterText  = "合计:";
                reportCost.FooterText = string.Format("{0}", WebControl.NumberSeparator(sumReportCost));
                payCost.FooterText    = string.Format("{0}", WebControl.NumberSeparator(sumPayCost));
            }
            else
            {
                totalName.FooterText  = string.Empty;
                reportCost.FooterText = string.Empty;
                payCost.FooterText    = string.Empty;
            }
            #endregion

            RG_Report.DataSource = query.ToList();
        }
 public string GetDetailSum()
 {
     return(string.Format("合计{0}元", WebControl.NumberSeparator(_cost)));
 }