using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
using System.Xml;
using System.Data;
using System.Reflection;

namespace SiaSun.LMS.WPFClient.SYS
{
    public partial class STORAGE_SUMMARY_BATCH : AvalonDock.DocumentContent
    {
        public STORAGE_SUMMARY_BATCH()
        {
            InitializeComponent();
        }

        private void DocumentContent_Loaded(object sender, RoutedEventArgs e)
        {
            this.dgStorageSummary.U_WindowName = this.GetType().Name;
            this.dgStorageSummary.U_TableName = "STORAGE_SUMMARY_BATCH";
            this.dgStorageSummary.U_XmlTableName = "STORAGE_SUMMARY_BATCH";
            this.dgStorageSummary.U_OrderField = "GOODS_PROPERTY2";
            this.dgStorageSummary.U_Where = "1<>1";
            this.dgStorageSummary.U_AllowOperatData = false;
            this.dgStorageSummary.U_AllowChecked = false;
            this.dgStorageSummary.U_InitControl();
        }

        private void WrapPanel_Click(object sender, RoutedEventArgs e)
        {
            Button btn = e.OriginalSource as Button;
            if (btn != null)
            {
                switch (btn.Name)
                {
                    case "btnSearch":
                        DataTable dtQuantity = MainApp._I_BaseService.GetList("select GOODS_NAME,GOODS_PROPERTY2,sum(case when GOODS_PROPERTY9='4' and GOODS_CLASS_ID=1 then 1 else 0 end) as DONGJIE,sum(case when GOODS_PROPERTY9='4' and GOODS_CLASS_ID=1 then STORAGE_LIST_QUANTITY else 0 end) as DONGJIE_QUANTITY,sum(case when GOODS_PROPERTY9='2' and GOODS_CLASS_ID=1 then 1 else 0 end) as BUHEGE,sum(case when GOODS_PROPERTY9='2' and GOODS_CLASS_ID=1 then STORAGE_LIST_QUANTITY else 0 end) as BUHEGE_QUANTITY,sum(case when GOODS_PROPERTY9='1' and GOODS_CLASS_ID=1 then 1 else 0 end) as HEGE,sum(case when GOODS_PROPERTY9='1' and GOODS_CLASS_ID=1 then STORAGE_LIST_QUANTITY else 0 end) as HEGE_QUANTITY,sum(case when GOODS_PROPERTY9='0' and GOODS_CLASS_ID=1 then 1 else 0 end) as DAIJIAN,sum(case when GOODS_PROPERTY9='0' and GOODS_CLASS_ID=1 then STORAGE_LIST_QUANTITY else 0 end) as DAIJIAN_QUANTITY,count(0) as STOCK_QUANTITY,sum(STORAGE_LIST_QUANTITY) as STORAGE_LIST_QUANTITY from V_STORAGE_LIST where GOODS_CLASS_ID=1 group by GOODS_NAME,GOODS_PROPERTY2 order by GOODS_PROPERTY2");
                        this.dgStorageSummary.U_DataSource = dtQuantity.DefaultView;
                        break;
                    case "btnClear":
                        this.dgStorageSummary.U_InitControl();
                        break;
                }
            }
        }
    }
}