123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.StatisticalInquiry
- {
- public partial class FrmStoredValueReport : LYFZ.Software.UI.StatisticalInquiry.FrmStoredValueReport
- {
- public bool IsQueryByEmployee { get; set; } = false;
- public string strEmployeeId { get; set; } = "";
- LYFZ.BLL.BLL_ErpMemberCard memberCardBll = new BLL.BLL_ErpMemberCard();
- public FrmStoredValueReport()
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindGroupStoreName(this.cmbtreevStoreName, StrKeyCode: "qt002");
- DataRow();
- this.dgv.CellDoubleClick += dgv_CellDoubleClick;
-
- }
- void dgv_CellDoubleClick( object sender, DataGridViewCellEventArgs e )
- {
- if ( this.dgv.SelectedRows.Count > 0 )
- {
- DataGridViewRow dgvRow = this.dgv.SelectedRows[0];
- //LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm.MemberCardUseRecordsSuperSmallForm frm = new LYFZ.Software.MainBusiness.MembershipManage.SuperSmallForm.MemberCardUseRecordsSuperSmallForm();
- //frm.StrNumber = dgvRow.Tag.ToString();
- //frm.startTime = dtpStart.Value.ToString( "yyyy-MM-dd" ) + " 00:00:00";
- //frm.endTime = dtpEnd.Value.ToString( "yyyy-MM-dd" ) + " 23:59:59";
- //frm.Height = this.Height;
- //frm.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- //frm.Show();
- FrmStoredReport frmStored = new FrmStoredReport();
- frmStored.startTime = dtpStart.Value.ToString("yyyy-MM-dd") ;
- frmStored.endTime = dtpEnd.Value.ToString("yyyy-MM-dd") ;
- frmStored.txt_MemberText.Text = dgvRow.Cells["McCardHolder"].Value.ToString_s();
- frmStored.IsQueryByEmployee = true;
- frmStored.lab_DataTime.Text = "时间段:" + dtpStart.Value.ToString("yyyy-MM-dd")+" - "+ dtpEnd.Value.ToString("yyyy-MM-dd");
- frmStored.cmbtreevStoreName.TextFindTag(cmbtreevStoreName.Text);
- frmStored.ShowDialog();
- }
- }
- public override void btnQuery_Click( object sender, EventArgs e )
- {
- DataRow();
- }
- /// <summary>
- /// 绑定数据
- /// </summary>
- public void DataRow()
- {
- Dictionary<string, Dictionary<string, string>> tempDicList = new Dictionary<string, Dictionary<string, string>>();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
- {
- string startTime = dtpStart.Value.ToString( "yyyy-MM-dd" );
- string endTime = dtpEnd.Value.ToString( "yyyy-MM-dd" );
- DataTable storeData = memberCardBll.GetStoredValueCardData( startTime, endTime, IsQueryByEmployee == true ? strEmployeeId : "" );
- DataTable totalStoreData = memberCardBll.GetTotalStoredValueCardData( IsQueryByEmployee == true ? strEmployeeId : "" );
- Dictionary<string, Dictionary<string, string>> dicList = new Dictionary<string, Dictionary<string, string>>();
- for ( int i = 0; i < storeData.Rows.Count; i++ )
- {
- DataRow dr = storeData.Rows[i];
- Dictionary<string, string> tempColumDicList = new Dictionary<string, string>();
- if ( dicList.ContainsKey( dr["Mcacl_Number"].ToString() ) )
- {
- tempColumDicList = dicList[dr["Mcacl_Number"].ToString()];
- }
- else
- {
- dicList.Add( dr["Mcacl_Number"].ToString(), tempColumDicList );
- }
- BindData( dr, ref tempColumDicList );
- }
- for ( int i = 0; i < totalStoreData.Rows.Count; i++ )
- {
- DataRow dr = totalStoreData.Rows[i];
- Dictionary<string, string> tempColumDicList = new Dictionary<string, string>();
- if ( dicList.ContainsKey( dr["Mcacl_Number"].ToString() ) )
- {
- tempColumDicList = dicList[dr["Mcacl_Number"].ToString()];
- }
- else
- {
- dicList.Add( dr["Mcacl_Number"].ToString(), tempColumDicList );
- }
- BindTotalData( dr, ref tempColumDicList );
- }
- List<string> McNumber = new List<string>();
- foreach ( string key in dicList.Keys )
- {
- McNumber.Add( key );
- }
- string searchText = txt_MemberText.Text;
- if ( !string.IsNullOrEmpty( searchText ) )
- {
- searchText = " and (mc_CradNumber like '%" +
- searchText + "%' or cus_name like '%" +
- searchText + "%' or Cus_Telephone like '%" +
- searchText + "%') ";
- }
- else
- {
- searchText = "";
- }
- searchText += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetGroupQueryWhere(this.cmbtreevStoreName, "Mc_DividedShop");
- DataTable memberDataTable = memberCardBll.GetMemberCardDataValue( " Mc_Number in ('" + string.Join( "','", McNumber.ToArray() ) + "') " + searchText );
- for ( int i = 0; i < memberDataTable.Rows.Count; i++ )
- {
- if ( dicList.ContainsKey( memberDataTable.Rows[i]["Mc_Number"].ToString() ) )
- {
- tempDicList.Add( memberDataTable.Rows[i]["Mc_Number"].ToString(), dicList[memberDataTable.Rows[i]["Mc_Number"].ToString()] );
- Dictionary<string, string> tempColumDicList = dicList[memberDataTable.Rows[i]["Mc_Number"].ToString()];
- if ( !tempColumDicList.ContainsKey( "McNumber" ) )
- {
- tempColumDicList.Add( "McNumber", memberDataTable.Rows[i]["Mc_CradNumber"].ToString() );
- }
- if ( !tempColumDicList.ContainsKey( "McCardHolder" ) )
- {
- tempColumDicList.Add( "McCardHolder", memberDataTable.Rows[i]["Cus_Name"].ToString() );
- }
- if ( !tempColumDicList.ContainsKey( "McTelephone" ) )
- {
- tempColumDicList.Add( "McTelephone", memberDataTable.Rows[i]["Cus_Telephone"].ToString() );
- }
- if ( !tempColumDicList.ContainsKey( "McCardMoney" ) )
- {
- tempColumDicList.Add( "McCardMoney", memberDataTable.Rows[i]["Mc_Money"].ToString() );
- }
- if ( !tempColumDicList.ContainsKey( "McResidualStoredValue" ) )
- {
- if ( Convert.ToDecimal( tempColumDicList["McTotalStoredValue"].ToString() ) > 0 )
- {
- if ( tempColumDicList.ContainsKey( "McTotalConsumption" ) && tempColumDicList.ContainsKey( "McTotalStoredValue" ) )
- {
- string strValue = ((-1 * Convert.ToDecimal( tempColumDicList["McTotalConsumption"].ToString() ) /
- Convert.ToDecimal( tempColumDicList["McTotalStoredValue"].ToString() )) * 100).ToString( "0.00" ) + "%";
- tempColumDicList.Add( "McResidualStoredValue", strValue );
- }
- else
- {
- tempColumDicList.Add( "McResidualStoredValue", "" );
- }
- }
- else
- {
- tempColumDicList.Add( "McResidualStoredValue", "" );
- }
- }
- }
- //dicList[memberDataTable.Rows[i]["Mc_Number"].ToString()]
- }
- } );
- BindGridControlData( tempDicList );
- }
- void BindGridControlData( Dictionary<string, Dictionary<string, string>> dicList )
- {
- this.dgv.Rows.Clear();
- decimal mcmoney = 0;
- decimal recharge = 0;
- decimal giftAmount = 0;
- decimal withdrawals = 0;
- decimal consumption = 0;
- decimal totalStoredValue = 0;
- decimal totalConsumption = 0;
- foreach ( string key in dicList.Keys )
- {
- Dictionary<string, string> columList = dicList[key];
- int rowIndex = this.dgv.Rows.Add();
- this.dgv.Rows[rowIndex].Cells["McCardMoney"].Value = 0;
- this.dgv.Rows[rowIndex].Cells["McRecharge"].Value = 0;
- this.dgv.Rows[rowIndex].Cells["McGiftAmount"].Value = 0;
- this.dgv.Rows[rowIndex].Cells["McWithdrawals"].Value = 0;
- this.dgv.Rows[rowIndex].Cells["McConsumption"].Value = 0;
- this.dgv.Rows[rowIndex].Cells["McTotalStoredValue"].Value = 0;
- this.dgv.Rows[rowIndex].Cells["McTotalConsumption"].Value = 0;
- this.dgv.Rows[rowIndex].Tag = key;
- foreach ( string columKey in columList.Keys )
- {
- this.dgv.Rows[rowIndex].Cells[columKey].Value = columList[columKey];
- if ( columKey.Equals( "McCardMoney" ) )
- {
- mcmoney += Convert.ToDecimal( columList[columKey] );
- }
- if ( columKey.Equals( "McRecharge" ) )
- {
- recharge += Convert.ToDecimal( columList[columKey] );
- }
- if ( columKey.Equals( "McGiftAmount" ) )
- {
- giftAmount += Convert.ToDecimal( columList[columKey] );
- }
- if ( columKey.Equals( "McWithdrawals" ) )
- {
- withdrawals += Convert.ToDecimal( columList[columKey] );
- }
- if ( columKey.Equals( "McConsumption" ) )
- {
- consumption += Convert.ToDecimal( columList[columKey] );
- }
- if ( columKey.Equals( "McTotalStoredValue" ) )
- {
- totalStoredValue += Convert.ToDecimal( columList[columKey] );
- }
- if ( columKey.Equals( "McTotalConsumption" ) )
- {
- totalConsumption += Convert.ToDecimal( columList[columKey] );
- }
- }
- }
- lab_Message.Text = " 余额:" + mcmoney + " 充值金额:" + recharge + " 赠送金额:" + giftAmount +
- " 提现金额:" + withdrawals * -1 + " 已消费金额:" + consumption * -1 +
- " 累计充值金额:" + totalStoredValue + " 累计消费金额:" + totalConsumption * -1;
- }
- /// <summary>
- /// 绑定表格数据
- /// </summary>
- /// <param name="dr">数据</param>
- /// <param name="tempColumDicList"></param>
- void BindData( DataRow dr, ref Dictionary<string, string> tempColumDicList )
- {
- string keyData = dr["类型"].ToString();
- decimal valueData = 0;
- string giftData = "McGiftAmount";//"McGiftAmount";
- decimal giftValueData = 0;
- switch ( keyData )
- {
- case "充值":
- keyData = "McRecharge";
- valueData = Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "提现":
- keyData = "McWithdrawals";
- valueData = -1 * Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "取现":
- keyData = "McWithdrawals";
- valueData = -1 * Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "删除收款扣回":
- keyData = "McConsumption";
- valueData = Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "订单消费":
- keyData = "McConsumption";
- valueData = -1 * Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "服务消费":
- keyData = "McConsumption";
- valueData = -1 * Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "充值错误扣回":
- keyData = "McRecharge";
- valueData = -1 * Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = -1 * Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "送金额":
- keyData = "McRecharge";
- giftValueData = Convert.ToDecimal( dr["操作金额"].ToString() );
- break;
- case "删除储值提现扣回":
- keyData = "McWithdrawals";
- valueData = Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- }
- ///
- if ( tempColumDicList.ContainsKey( keyData ) )
- {
- tempColumDicList[keyData] = (Convert.ToDecimal( tempColumDicList[keyData] ) + Convert.ToDecimal( valueData )).ToString( "0.00" );
- }
- else
- {
- tempColumDicList.Add( keyData, valueData.ToString( "0.00" ) );
- }
- if ( tempColumDicList.ContainsKey( giftData ) )
- {
- tempColumDicList[giftData] = (Convert.ToDecimal( tempColumDicList[giftData] ) + Convert.ToDecimal( giftValueData )).ToString( "0.00" );
- }
- else
- {
- tempColumDicList.Add( giftData, giftValueData.ToString( "0.00" ) );
- }
- }
- /// <summary>
- /// 绑定表格数据
- /// </summary>
- /// <param name="dr">数据</param>
- /// <param name="tempColumDicList"></param>
- void BindTotalData( DataRow dr, ref Dictionary<string, string> tempColumDicList )
- {
- string keyData = dr["类型"].ToString();
- decimal valueData = 0;
- string giftData = "McTotalStoredValue";// "McTotalGift";
- decimal giftValueData = 0;
- switch ( keyData )
- {
- case "充值":
- keyData = "McTotalStoredValue";
- valueData = Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "提现":
- //keyData = "McTotalWithdrawals";
- keyData = "McTotalConsumption";
- valueData = -1 * Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "取现":
- //keyData = "McTotalWithdrawals";
- keyData = "McTotalConsumption";
- valueData = -1 * Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "删除收款扣回":
- keyData = "McTotalConsumption";
- valueData = Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "订单消费":
- keyData = "McTotalConsumption";
- valueData = -1 * Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "服务消费":
- keyData = "McTotalConsumption";
- valueData = -1 * Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "充值错误扣回":
- keyData = "McTotalStoredValue";
- valueData = -1 * Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = -1 * Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "送金额":
- //keyData = "McTotalGift";
- keyData = "McTotalStoredValue";
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- case "删除储值提现扣回":
- keyData = "McTotalConsumption";
- valueData = Convert.ToDecimal( dr["操作金额"].ToString() );
- giftValueData = Convert.ToDecimal( dr["赠送金额"].ToString() );
- break;
- }
- ///
- if ( tempColumDicList.ContainsKey( keyData ) )
- {
- tempColumDicList[keyData] = (Convert.ToDecimal( tempColumDicList[keyData] ) + Convert.ToDecimal( valueData )).ToString( "0.00" );
- }
- else
- {
- tempColumDicList.Add( keyData, valueData.ToString( "0.00" ) );
- }
- if ( tempColumDicList.ContainsKey( giftData ) )
- {
- tempColumDicList[giftData] = (Convert.ToDecimal( tempColumDicList[giftData] ) + Convert.ToDecimal( giftValueData )).ToString( "0.00" );
- }
- else
- {
- tempColumDicList.Add( giftData, giftValueData.ToString( "0.00" ) );
- }
- }
- internal void BindSearchDataTime( DateTime dtTime, DateTime dtTime2 )
- {
- rdoMouth.Checked = true;
- this.dtpStart.Value = new DateTime( dtTime.Year, dtTime.Month, dtTime.Day );
- this.dtpEnd.Value = new DateTime( dtTime2.Year, dtTime2.Month, dtTime2.Day );
- btnQuery_Click( null, null );
- }
- }
- }
|