This is a migrated thread and some comments may be shown as answers.
How can i use InvokeCommandAction in GridView -> DataTemplete
0 Answers 15 Views
This is a migrated thread and some comments may be shown as answers.
Park
Top achievements
Rank 1
Park asked on 12 Dec 2011, 01:08 PM
hi

here my source

i want to mouseleftbuttondown event image, textblock in templete, and execute  SaleViewCommand(ViewModel)

how can i do?

thank 

  <telerik:RadGridView Grid.Row="2"  x:Name="rgvCalendar"
   AutoGenerateColumns="False" ShowGroupPanel="False" IsFilteringAllowed="False"
   ItemsSource="{Binding SshSaleRowCollection}" Margin="0" AlternateRowBackground="#7FF4F4F4">
   <telerik:RadGridView.Columns>
    <telerik:GridViewDataColumn HeaderTextAlignment="Center" Header="일" MinWidth="120" Width="*" IsReadOnly="True" Background="#FFFFFFFF"
     CellTemplate="{StaticResource tplSunday}"
     DataMemberBinding="{Binding SshSaleRowCollection.Sunday}"/>
    <telerik:GridViewDataColumn HeaderTextAlignment="Center" Header="월" MinWidth="120" Width="*" IsReadOnly="True" Background="#FFFFFFFF"
     CellTemplate="{StaticResource tplMonday}"
     DataMemberBinding="{Binding SshSaleRowCollection.Monday}" />
    <telerik:GridViewDataColumn HeaderTextAlignment="Center" Header="화" MinWidth="120" Width="*" IsReadOnly="True" Background="#FFFFFFFF"
     CellTemplate="{StaticResource tplTuesday}"
     DataMemberBinding="{Binding SshSaleRowCollection.Tuesday}" />
    <telerik:GridViewDataColumn HeaderTextAlignment="Center" Header="수" MinWidth="120" Width="*" IsReadOnly="True" Background="#FFFFFFFF"
     CellTemplate="{StaticResource tplWednesday}"
     DataMemberBinding="{Binding SshSaleRowCollection.Wednesday}" />
    <telerik:GridViewDataColumn HeaderTextAlignment="Center" Header="목" MinWidth="120" Width="*" IsReadOnly="True" Background="#FFFFFFFF"
     CellTemplate="{StaticResource tplThursday}"
     DataMemberBinding="{Binding SshSaleRowCollection.Thursday}" />
    <telerik:GridViewDataColumn HeaderTextAlignment="Center" Header="금" MinWidth="120" Width="*" IsReadOnly="True" Background="#FFFFFFFF"
     CellTemplate="{StaticResource tplFriday}"
     DataMemberBinding="{Binding SshSaleRowCollection.Friday}" />
    <telerik:GridViewDataColumn HeaderTextAlignment="Center" Header="토" MinWidth="120" Width="*" IsReadOnly="True"
     CellTemplate="{StaticResource tplSaturday}"
     DataMemberBinding="{Binding SshSaleRowCollection.Saturday}" />
            </telerik:RadGridView.Columns>
  </telerik:RadGridView>

 <DataTemplate x:Key="tplMonday" >
        <Border BorderBrush="#FF666666" BorderThickness="1" Background="#FFFFFFFF">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="32" />
                    <RowDefinition Height="1" />
                    <RowDefinition Height="18" />
                    <RowDefinition Height="1" />
                    <RowDefinition Height="18" />
                    <RowDefinition Height="1" />
                    <RowDefinition Height="18" />
                    <RowDefinition Height="1" />
                    <RowDefinition Height="18" />
                    <RowDefinition Height="1" />
                    <RowDefinition Height="18" />
                    <RowDefinition Height="1" />
                    <RowDefinition Height="18" />
                    <RowDefinition Height="1" />
                    <RowDefinition Height="18" />
                    <RowDefinition Height="1" />
                    <RowDefinition Height="18" />
                </Grid.RowDefinitions>

                <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Left">
                   <!--here is i want mouseleftbuttondown event -->
                    <TextBlock TextWrapping="Wrap" Text="{Binding Monday.DtDay}" FontWeight="Bold" FontSize="14" Margin="5,8,0,0" Foreground="#FF000000" />
                    <TextBlock TextWrapping="Wrap" Text="{Binding Monday.DtHDay}" FontSize="12" Margin="0,10,0,0" Foreground="#FF000000" />
                    <Image Stretch="Uniform" Width="26" Height="30" Source="{Binding Monday.ImgUrlWthr}" Margin="4,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
                    <Image Stretch="Uniform" Width="26" Height="30" Source="{Binding Monday.ImgUrlSale}"  Margin="4,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
                </StackPanel>

                <Path Data="M8,79 L90.097504,79" Grid.Row="1" Fill="{Binding Monday.Fill1}" Height="1" Margin="0,0,0,0" Stretch="Fill" Stroke="{Binding Monday.Fill1}"/>

                <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,0">
                    <TextBlock TextWrapping="Wrap" Margin="5,0,0,0" Text="{Binding Monday.TxtSale}" FontWeight="Bold" FontSize="11" Foreground="#FF000000" />
                    <TextBlock TextWrapping="Wrap" Margin="5,0,0,0" Text="{Binding Monday.PSale}" FontSize="10" Foreground="{Binding Monday.PSaleColor}" />
                </StackPanel>

                <Path Data="M8,79 L90.097504,79" Grid.Row="3" Fill="{Binding Monday.Fill2}" Height="1" Margin="0,0,0,0" Stretch="Fill" Stroke="{Binding Monday.Fill2}"/>

                <TextBlock Grid.Row="4" TextWrapping="Wrap" Text="{Binding Monday.AmtSale, StringFormat=N0}" FontSize="10" Foreground="#FF000000" Margin="0,0,5,0" TextAlignment="Right" />

                <Path Data="M8,79 L90.097504,79" Grid.Row="5" Fill="{Binding Monday.Fill1}" Height="1" Margin="0,0,0,0" Stretch="Fill" Stroke="{Binding Monday.Fill1}"/>

                <StackPanel Grid.Row="6" Orientation="Horizontal">
                    <TextBlock TextWrapping="Wrap" Margin="5,0,0,0" Text="{Binding Monday.TxtEvent}" FontWeight="Bold" FontSize="11" Foreground="#FF000000" />
                    <TextBlock TextWrapping="Wrap" Margin="5,0,0,0" Text="{Binding Monday.PEvent}" FontSize="10" Foreground="{Binding Monday.PEventColor}"/>
                </StackPanel>

                <Path Data="M8,79 L90.097504,79" Grid.Row="7" Fill="{Binding Monday.Fill2}" Height="1" Margin="0,0,0,0" Stretch="Fill" Stroke="{Binding Monday.Fill2}"/>

                <TextBlock Grid.Row="8" TextWrapping="Wrap" Text="{Binding Monday.AmtEvent, StringFormat=N0}" FontSize="10" Foreground="#FF000000" Margin="0,0,5,0" TextAlignment="Right"  />

                <Path Data="M8,79 L90.097504,79" Grid.Row="9" Fill="{Binding Monday.Fill1}" Height="1" Margin="0,0,0,0" Stretch="Fill" Stroke="{Binding Monday.Fill1}"/>

                <TextBlock Grid.Row="10" TextWrapping="Wrap" Margin="5,0,0,0" Text="{Binding Monday.TxtPrevSale}" FontWeight="Bold" FontSize="11" Foreground="#FF000000" />

                <Path Data="M8,79 L90.097504,79" Grid.Row="11" Fill="{Binding Monday.Fill2}" Height="1" Margin="0,0,0,0" Stretch="Fill" Stroke="{Binding Monday.Fill2}"/>

                <TextBlock Grid.Row="12" TextWrapping="Wrap" Text="{Binding Monday.PrevAmtSale, StringFormat=N0}" FontSize="10" Foreground="#FF000000" Margin="0,0,5,0" TextAlignment="Right"  />

                <Path Data="M8,79 L90.097504,79" Grid.Row="13" Fill="{Binding Monday.Fill1}" Height="1" Margin="0,0,0,0" Stretch="Fill" Stroke="{Binding Monday.Fill1}"/>

                <TextBlock Grid.Row="14" TextWrapping="Wrap" Margin="5,0,0,0"  Text="{Binding Monday.TxtPrevEvent}" FontWeight="Bold" FontSize="11" Foreground="#FF000000" />

                <Path Data="M8,79 L90.097504,79" Grid.Row="15" Fill="{Binding Monday.Fill2}" Height="1" Margin="0,0,0,0" Stretch="Fill" Stroke="{Binding Monday.Fill2}"/>

                <TextBlock Grid.Row="16" TextWrapping="Wrap" Text="{Binding Monday.PrevAmtEvent, StringFormat=N0}" FontSize="10" Foreground="#FF000000" Margin="0,0,5,0" TextAlignment="Right"  />

            </Grid>
        </Border>
    </DataTemplate>


using System.ComponentModel.Composition;
using System.Windows.Controls;
using MKERP.Store.ViewModels;

namespace MKERP.Store.Views
{
    [Export(typeof(UserControl))]
    public partial class StrCalendarView : UserControl
    {
        [Import]
        public StrCalendarViewModel StrCalendarVM
        {
            get { return this.DataContext as StrCalendarViewModel; }
            set
            {
                this.DataContext = value;

                value.ViewName = this.ToString();

            }
        }

        public StrCalendarView()
        {
            InitializeComponent();
        }
    }
}


using System;
using System.ComponentModel.Composition;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Windows.Controls;
using System.Windows.Input;
using System.Linq;
using Microsoft.Practices.Prism.ViewModel;
using Microsoft.Practices.Prism.Events;
using Microsoft.Expression.Interactivity.Core;
using MKERP.Infrastructures.Interface;
using MKERP.Infrastructures.Popup;
using MKERP.Infrastructures.EventAggregator;
using MKERP.Web;
using MKERP.Store.Models;
using System.Collections.Generic;
using Telerik.Windows.Controls;
using MKERP.Infrastructures;
using System.Globalization;
using System.Threading;
using MKERP.Store.Views;
using System.Windows;
using Telerik.Windows.Controls.GridView;

 

namespace MKERP.Store.ViewModels
{
    [Export(typeof(StrCalendarViewModel))]
    public class StrCalendarViewModel : NotificationObject, IMKERPViewModel
    {
        #region 검색조건 : Getting시 넘겨 줄 인자값 저장

        private string sIdStore;
        /// <summary>
        /// 매장명
        /// </summary>
        public string SIdStore
        {
            get { return sIdStore; }
            set
            {
                sIdStore = value;
                RaisePropertyChanged(() => this.SIdStore);
            }
        }

        private DateTime sDtYmSale;
        /// <summary>
        /// - DtYmGoal 기준일자(등록년월)
        /// </summary>
        public DateTime SDtYmSale
        {
            get { return sDtYmSale; }
            set
            {
                if (sDtYmSale != value)
                {
                    sDtYmSale = value;
                    RaisePropertyChanged(() => this.SDtYmSale);
                }
            }
        }

        #endregion

        //프로퍼티 : 필수 프로퍼티와 해당 뷰에서 필요한 프로퍼티
        string viewName;
        /// <summary>
        /// #Requirement - 현재의 뷰이름 
        /// </summary>
        public string ViewName
        {
            get
            {
                return viewName;
            }
            set
            {
                if (viewName != value)
                {
                    viewName = value;
                    RaisePropertyChanged(() => this.ViewName);
                }
            }
        }

        string viewTitle;
        /// <summary>
        /// #Requirement - 화면 디스플레이명
        /// </summary>
        public string ViewTitle
        {
            get { return viewTitle; }
            set
            {
                viewTitle = value;
                this.RaisePropertyChanged(() => ViewTitle);
            }
        }

        string messageData;
        /// <summary>
        /// #Requirement - 뷰모델의 MessageData : 각 모델에서 발생되는 메시지를 취합
        /// </summary>
        public string MessageData
        {
            get
            {
                return messageData;
            }
            set
            {
                if (messageData != value)
                {
                    messageData = value;
                    RaisePropertyChanged(() => this.MessageData);
                }
            }
        }

        /// <summary>
        /// RadDatePicker의 날짜 형식 변경(년-월)
        /// </summary>
        public CultureInfo CurrentCulture
        {
            get
            {
                CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture.Clone() as CultureInfo;
                currentCulture.DateTimeFormat.ShortDatePattern = "yyyy/MM";

                return currentCulture;
            }
        }

 

        SshSaleRow selSDay;
        /// <summary>
        ///
        /// </summary>
        public SshSaleRow SelSDay
        {
            get
            {
                return selSDay;
            }
            set
            {
                if (selSDay != value)
                {
                    selSDay = value;
                    RaisePropertyChanged(() => this.selSDay);
                }
            }
        }

        //프로퍼티 : 임폴트 할 모델 프로퍼티        
        /// <summary>
        /// 매장명 콤보데이터
        /// </summary>
        public IMKERPDataCbiStoreCombo CbiStoreCombo { get; set; }

        /// <summary>
        ///
        /// </summary>
        public IMKERPModelSshSale SshSaleModel { get; set; }

        //프로퍼티 : 임폴트 할 뷰모델 프로퍼티
        private PopupStrCalendarVeiw PopupStrSalesDay { get; set; }

        //컬렉션 : 각 각의 Model에서 받은 데이터가 저장됨
        ObservableCollection<SshSaleRow> sshSaleRowCollection;
        /// <summary>
        /// 매장형태콤보박스에 바인딩 시 REF_NUM1 => 1인 것만...
        /// </summary>
        public ObservableCollection<SshSaleRow> SshSaleRowCollection
        {
            get
            {
                return sshSaleRowCollection;
            }
            set
            {
                if (sshSaleRowCollection != value)
                {
                    sshSaleRowCollection = value;
                    RaisePropertyChanged(() => this.SshSaleRowCollection);
                }
            }
        }

        ObservableCollection<AmtSlsTotalRow> amtSlsTotalRowCollection;
        /// <summary>
        /// 매장형태콤보박스에 바인딩 시 REF_NUM1 => 1인 것만...
        /// </summary>
        public ObservableCollection<AmtSlsTotalRow> AmtSlsTotalRowCollection
        {
            get
            {
                return amtSlsTotalRowCollection;
            }
            set
            {
                if (amtSlsTotalRowCollection != value)
                {
                    amtSlsTotalRowCollection = value;
                    RaisePropertyChanged(() => this.AmtSlsTotalRowCollection);
                }
            }
        }

        ObservableCollection<pr_SSH_SALE_Select_Result> prCollection;
        /// <summary>
        ///
        /// </summary>
        public ObservableCollection<pr_SSH_SALE_Select_Result> PrCollection
        {
            get
            {
                return prCollection;
            }
            set
            {
                if (prCollection != value)
                {
                    prCollection = value;
                    RaisePropertyChanged(() => this.PrCollection);
                }
            }
        }

        //생성자 : 인스턴스화 시켜줌
        /// <summary>
        /// #Requirement - 임포트생성자(런타임)
        /// #Requirement **[Import] IEventAggregator _eventAggregator
        /// </summary>
        [ImportingConstructor]
        public StrCalendarViewModel(
            IEventAggregator _eventAggregator
            , IMKERPDataCbiStoreCombo _cbiStorecombo
            , IMKERPModelSshSale _sshSaleModel
            )
        {           
            // #Requirement **이벤트어그리게이트 서브스크립
            _eventAggregator.GetEvent<CompositePresentationEvent<PaneSelectedChangeEvent>>().Subscribe(OnViewSelected);

            // **모델           
            CbiStoreCombo = _cbiStorecombo;
            SshSaleModel = _sshSaleModel;
            // **컬렉션
            SshSaleRowCollection = new ObservableCollection<SshSaleRow>();
            AmtSlsTotalRowCollection = new ObservableCollection<AmtSlsTotalRow>();
            PrCollection = new ObservableCollection<pr_SSH_SALE_Select_Result>();

            // 현재 년,월 설정
            SDtYmSale = DateTime.Parse(DateTime.Now.ToString("yyyy-MM"));
        
         

            PopupStrSalesDay = new PopupStrCalendarVeiw();
        }

        /// <summary>
        /// #Requirement - 뷰모델생성자(디자인 타임)
        /// </summary>
        public StrCalendarViewModel()
        {
        }

        //프로퍼티체인지
        /// <summary>
        /// #Requirement 프로퍼티 체인지 이벤트 구현
        /// </summary>
        public void OnViewSelected(PaneSelectedChangeEvent paneSelectedChangeEvent)
        {
            if (paneSelectedChangeEvent.CurrentViewName == ViewName)
            {
                ViewTitle = paneSelectedChangeEvent.CurrentViewTitle;
                SshSaleModel.PropertyChanged += new PropertyChangedEventHandler(SshSaleModel_PropertyChanged);
             
            }
            else
            {
                SshSaleModel.PropertyChanged -= SshSaleModel_PropertyChanged;
            }
        }

        void SshSaleModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (SshSaleModel.LastExecuteSender == null || !SshSaleModel.LastExecuteSender.Equals(this))
                return;

            switch (e.PropertyName)
            {
                case "MessageData":
                    MessageData = "[SSH_SALE]" + SshSaleModel.MessageData;
                    break;
                case "SshSaleYmcollection":
                    PrCollection = new ObservableCollection<pr_SSH_SALE_Select_Result>(SshSaleModel.SshSaleYmcollection);

                    //월 매출 합계
                    AmtSlsTotalRow totalSaleRow = new AmtSlsTotalRow();
                    AmtSlsTotalRow totalEventRow = new AmtSlsTotalRow();

                    //주 매출 초기화
                    SshSaleRow weekRow = new SshSaleRow();
                    //weekRow.LinkCellEditCommand = CellEditCommand;//**

                    // 조회된 년월의 마지막날
                    int lastday = SDtYmSale.AddMonths(1).AddDays(-1).Day;;

                    //조회되는 월의 일별 매출 Form  생성.
                    for (int d = 0; d < lastday; d++)
                    {
                        DateTime day = SDtYmSale.AddDays(d);
                        int week = (int)day.DayOfWeek + 1;

                        //해당일자의 매출 정보 조회
                        pr_SSH_SALE_Select_Result p = PrCollection.Where(w => w.DT_SALES.Equals(day)).FirstOrDefault();

                        //일별 매출 정보 입력
                        SetSaleDay(week, d + 1, weekRow, p);

                        //토요일일 경우 row data 생성 및 신규 주 매출 추가
                        if ((int)day.DayOfWeek == 6)
                        {
                            SshSaleRowCollection.Add(weekRow);
                            weekRow = new SshSaleRow();
                        }
                        else
                        {
                            //주 중에 매출 정보가 종료되면 row data 생성
                            if (lastday.Equals(d + 1))
                            {
                                SshSaleRowCollection.Add(weekRow);
                            }
                        }

                        //매출 정보가 있을 경우 월 매출에 합산.
                        if (p != null)
                        {
                            totalSaleRow.AmtNslsTotal = (totalSaleRow.AmtNslsTotal == null) ? 0 : totalSaleRow.AmtNslsTotal;
                            totalSaleRow.AmtEslsTotal = (totalSaleRow.AmtEslsTotal == null) ? 0 : totalSaleRow.AmtEslsTotal;
                            totalEventRow.AmtNslsTotal = (totalEventRow.AmtNslsTotal == null) ? 0 : totalEventRow.AmtNslsTotal;
                            totalEventRow.AmtEslsTotal = (totalEventRow.AmtEslsTotal == null) ? 0 : totalEventRow.AmtEslsTotal;

                            totalSaleRow.AmtNslsTotal += p.AMT_SALES;
                            totalSaleRow.AmtEslsTotal += p.AMT_EVENT;
                            totalEventRow.AmtNslsTotal += p.PREV_SALES;
                            totalEventRow.AmtEslsTotal += p.PREV_EVENT;
                        }
                    }

                    //월 매출 기본 정보 입력 후 추가
                    totalSaleRow.DtYm = SDtYmSale.ToString("yyyy-MM");
                    totalEventRow.DtYm = SDtYmSale.AddYears(-1).ToString("yyyy-MM");
                    AmtSlsTotalRowCollection.Add(totalSaleRow);
                    AmtSlsTotalRowCollection.Add(totalEventRow);
                    break;
            }
        }

        private void SetSaleDay(int? check, int day, SshSaleRow row, pr_SSH_SALE_Select_Result p)
        {
            SaleDay weekday = new SaleDay();

            switch (check)
            {
                case 1:
                    weekday = row.Sunday;
                    break;
                case 2:
                    weekday = row.Monday;
                    break;
                case 3:
                    weekday = row.Tuesday;
                    break;
                case 4:
                    weekday = row.Wednesday;
                    break;
                case 5:
                    weekday = row.Thursday;
                    break;
                case 6:
                    weekday = row.Friday;
                    break;
                case 7:
                    weekday = row.Saturday;
                    break;
            }

            if (p != null)//
            {
                //날짜
                weekday.DtDay = p.DT_SALES.Day.ToString();
                //휴일/정상
                weekday.DtHDay = (p.YN_HDAY == "Y") ? "(휴일)" : "(정상)";
                //날씨아이콘               
                weekday.ImgUrlWthr = MemberShip.Current.HostUri + "/Images/icon/" + p.CD_WTHR + ".png";
                //행사아이콘
                weekday.ImgUrlSale = (p.YN_BSALE == "Y") ? MemberShip.Current.HostUri +  "/Images/icon/Sale.png" : "";
                //weekday.ImgUrlSale = MemberShip.Current.HostUri + "/Images/icon/sale.png";
                //상세보기 아이콘
                weekday.BtnImgUrl = MemberShip.Current.HostUri + "/Images/icon/Click.png";
                //정상텍스트 
                weekday.TxtSale = "정상";
                //정상매출
                weekday.AmtSale = (p.AMT_SALES == null) ? 0 : p.AMT_SALES;
                //정상매출%
                weekday.PSale = "(" + Convert.ToDecimal(p.PER_SALES).ToString("N2") + "%" + GetArrow(p.PER_SALES) + ")";
                weekday.PSaleColor = GetColor(p.PER_SALES);
                //행사텍스트
                weekday.TxtEvent = "행사";
                //행사매출
                weekday.AmtEvent = (p.AMT_EVENT == null) ? 0 : p.AMT_EVENT;
                //행사%
                weekday.PEvent = "(" + Convert.ToDecimal(p.PER_EVENT).ToString("N2") + "%" + GetArrow(p.PER_EVENT) + ")";
                weekday.PEventColor = GetColor(p.PER_EVENT);
                //전년정상텍스트
                weekday.TxtPrevSale = "전년정상";
                //전년정상매출
                //dayRow.Sunday.PrevAmtSale = (p.PREV_SALES == null) ? 0 : p.PREV_SALES;
                weekday.PrevAmtSale = p.PREV_SALES;
                //전년행사텍스트
                weekday.TxtPrevEvent = "전년행사";
                //전년행사매출
                //dayRow.Sunday.PrevAmtEvent = (p.PREV_EVENT == null) ? 0 : p.PREV_EVENT;
                weekday.PrevAmtEvent = p.PREV_EVENT;
                // 선색상1
                weekday.Fill1 = "#FFDDDDDD";
                // 선색상2
                weekday.Fill2 = "#FFF1F1F1";
            }
            else//
            {
                weekday.DtDay = Convert.ToString(day);
            }
           
        }

        /// <summary>
        /// 매출 증가, 감소 텍스트 칼라
        /// </summary>
        /// <param name="value">매출%</param>
        /// <returns></returns>
        private string GetColor(Nullable<decimal> value)
        {
            return (value > 0) ? "#FF9D0909" : (value < 0) ? "#FF041281" : "#FF000000";
        }
        /// <summary>
        /// 매출 증가, 감소 화살표
        /// </summary>
        /// <param name="value">매출%</param>
        /// <returns></returns>
        private string GetArrow(Nullable<decimal> value)
        {
            return (value > 0) ? "↑" : (value < 0) ? "↓" : "";
        }

 

   

 

        /// <summary>
        /// 로드커맨드
        /// </summary>
        public ICommand LoadedCommand
        {
            get
            {
                return null;
            }
        }

        ICommand addCommand;
        /// <summary>
        /// 추가커맨드
        /// </summary>
        public ICommand AddCommand
        {
            get
            {
                if (addCommand == null)
                {
                    addCommand = new ActionCommand(grid =>
                    {
                       
                    });
                }
                return addCommand;
            }
        }

        ICommand removeCommand;
        /// <summary>
        /// 삭제커맨드
        /// </summary>
        public ICommand RemoveCommand
        {
            get
            {
                if (removeCommand == null)
                {
                    removeCommand = new ActionCommand(() =>
                    {

                    });
                }
                return removeCommand;
            }
        }

        /// <summary>
        /// 취소커맨드
        /// </summary>
        ICommand cancelCommand;
        public ICommand CancelCommand
        {
            get
            {
                if (cancelCommand == null)
                {
                    cancelCommand = new ActionCommand(() =>
                    {

                    });
                }
                return cancelCommand;
            }
        }

        /// <summary>
        /// 저장커맨드
        /// </summary>
        ICommand saveCommand;
        public ICommand SaveCommand
        {
            get
            {
                if (saveCommand == null)
                {
                    saveCommand = new ActionCommand(() =>
                    {

                    });
                }
                return saveCommand;
            }
        }

        /// <summary>
        /// 조회커맨드
        /// </summary>
        ICommand selectCommand;
        public ICommand SelectCommand
        {
            get
            {
                if (selectCommand == null)
                {
                    selectCommand = new ActionCommand(() =>
                    {
                        //SshSaleModel.Getting("S0241001", DateTime.Parse("2010-01-01"), this);//테스트용
                        if (SIdStore != null)
                        {
                            SshSaleRowCollection.Clear();
                            AmtSlsTotalRowCollection.Clear();
                            PrCollection.Clear();

                            SDtYmSale = Convert.ToDateTime(SDtYmSale.ToString("yyyy-MM-01") + " 00:00:00");
                            SshSaleModel.PrGetting(SIdStore, SDtYmSale, this);
                        }
                        else
                        {
                            MessageData = "매장을 선택해 주세요.";
                        }
                       
                    });
                }
                return selectCommand;
            }
        }

        ICommand selectSaleCommand;
        /// <summary>
        /// 정상매출 커맨드
        /// </summary>
        public ICommand SelectSaleCommand
        {
            get
            {
                if (selectSaleCommand == null)
                {
                    selectSaleCommand = new ActionCommand(() =>
                    {
                        //확인 팝업 출력
                        Confirm costCf = new Confirm();
                        costCf.DisplayMessage = "선택한 내역을 삭제 하시겠습니까?";
                        //삭제할 아이템을 테그에 넣어서 전달
                        costCf.Tag = "test";
                        //클로즈 되었을때 어디로 갈지 정해주고
                        costCf.Closed += new EventHandler<Telerik.Windows.Controls.WindowClosedEventArgs>(cf_Closed);
                        //다이얼로그 창으로 출력
                        costCf.ShowDialog();
                    });
                }
                return selectSaleCommand;
            }
        }
   
        // i want execute command~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        private ICommand saleViewCommand;
        /// <summary>
        ///
        /// </summary>
        public ICommand SaleViewCommand
        {
            get
            {
                if (saleViewCommand == null)
                {
                    saleViewCommand = new ActionCommand(day =>
                    {
                        TextBlock txt = day as TextBlock;
                        if (txt != null)
                        {
                            string ss = txt.Text;

                            //SaleDay selDay = day as SaleDay;

                            if (day != null)
                            {
                                //PopupStrSalesDay.ShowDialog();
                                //PopupStrSalesDay.DtDay = ss;

                                MessageBox.Show("날짜 : " + ss );
                            }
                        }                      
                        else
                        {
                            MessageData = "조회하실 날짜를 선택하세요.";
                            return;
                        }
                      
                    });//new ActionCommand(grid =>
                }//if (cellEditCommand == null)
                return saleViewCommand;
            }
        }

        private void cf_Closed(object sender, WindowClosedEventArgs e)
        {
            //대답이 예인경우만 처리
            if (e.DialogResult == true)
            {
                switch ((sender as Confirm).Tag.ToString())
                {
                    case "test":
                        break;
                }
            }
        }

    }

No answers yet. Maybe you can help?

Asked by
Park
Top achievements
Rank 1
Share this question
or