Пример #1
0
        private void MonthlyData_ItemPropertyChanged(object sender, ItemPropertyChangedEventArgs e)
        {
            MonthlyActivityStatusModel row = MonthlyData[e.CollectionIndex];

            //dont trigger isdirty on load
            if (e.PropertyName == "StatusID" || e.PropertyName == "Comments" || e.PropertyName == "ExpectedDateFirstSales" || e.PropertyName == "TrialStatusID")
            {
                isdirty = true;
                RaiseDirtyDataEvent();
                row.IsDirty = true;
                CheckDupComments();
            }

            //make changes based on selected status
            if (e.PropertyName == "StatusID")
            {
                if (row.StatusID == 10) //only Status 10
                {
                    IMessageBoxService msg1   = new MessageBoxService();
                    object[]           values = new object[2];
                    values = msg1.CompletedProjectDialog(null, ConvertObjToDecimal(SelectedProjectItem["EstimatedAnnualSales"]), MonthlyData[e.CollectionIndex].ExpectedDateFirstSales, (DateTime)MonthlyData[e.CollectionIndex].StatusMonth);
                    msg1   = null;
                    if (values != null)
                    {
                        MonthlyData[e.CollectionIndex].EstimatedAnnualSales   = ConvertObjToDecimal(values[0]);
                        MonthlyData[e.CollectionIndex].ExpectedDateFirstSales = ConvertObjToDate(values[1]);
                        //raise event - Completed
                        RaiseProjectStatusEvent(ProjectStatusType.Completed);
                    }
                }
                else  //all other statuses
                {
                    DateTime newdate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

                    if (MonthlyData[e.CollectionIndex].ExpectedDateFirstSales != null)
                    {
                        newdate = (DateTime)MonthlyData[e.CollectionIndex].ExpectedDateFirstSales;
                    }

                    IMessageBoxService msg      = new MessageBoxService();
                    DateTime?          retvalue = msg.ConfirmExpectedSalesDateDialog(null, newdate, (DateTime)MonthlyData[e.CollectionIndex].StatusMonth);
                    msg = null;
                    if (retvalue == null)
                    {
                        retvalue = DateTime.Now.AddMonths(1);
                    }

                    MonthlyData[e.CollectionIndex].ExpectedDateFirstSales = retvalue;
                    //raise event - Active
                    RaiseProjectStatusEvent(ProjectStatusType.Active);
                }

                //set default trial status
                if (MonthlyData[e.CollectionIndex].StatusID != Config.StatusIDforTrials)
                {
                    MonthlyData[e.CollectionIndex].TrialStatusID = 0;
                }
                else
                {
                    MonthlyData[e.CollectionIndex].TrialStatusID = Config.DefaultTrialStatusID;
                }

                //Set rows to disabled for later months if this row is status=10
                SetStatus10Rows();
                DisablePreviousMonthRows();
            }
        }