private void OldCIReferenceChanged()
        {
            if (!_oldCIReferenceSelectedRow.IsNotNullOrEmpty())
            {
                return;
            }

            DataTable dt = bll.GetCIReferenceNumber(new DDCI_INFO()
            {
                IDPK = -99999
            }).ToDataTable <V_CI_REFERENCE_NUMBER>().Clone();

            dt.ImportRow(_oldCIReferenceSelectedRow.Row);

            List <V_CI_REFERENCE_NUMBER> lstEntity = (from row in dt.AsEnumerable()
                                                      select new V_CI_REFERENCE_NUMBER()
            {
                CI_REFERENCE = row.Field <string>("CI_REFERENCE"),
                FRCS_DATE = row.Field <string>("FRCS_DATE"),
                CUST_DWG_NO = row.Field <string>("CUST_DWG_NO"),
                CUST_CODE = row.Field <string>("CUST_CODE").ToDecimalValue(),
                FINISH_CODE = row.Field <string>("FINISH_CODE"),
                CUST_DWG_NO_ISSUE = row.Field <string>("CUST_DWG_NO_ISSUE"),
                CUST_STD_DATE = row.Field <string>("CUST_STD_DATE"),
                IDPK = row.Field <string>("IDPK").ToIntValue(),
            }).ToList <V_CI_REFERENCE_NUMBER>();

            if (lstEntity.IsNotNullOrEmpty() && lstEntity.Count > 0)
            {
                V_CI_REFERENCE_NUMBER currentEntity   = lstEntity[0];
                List <DDCI_INFO>      lstActiveEntity = bll.GetEntitiesByPrimaryKey(new DDCI_INFO()
                {
                    IDPK = currentEntity.IDPK
                });

                if (lstActiveEntity.IsNotNullOrEmpty() && lstActiveEntity.Count > 0)
                {
                    OldActiveEntity           = lstActiveEntity[0].DeepCopy <DDCI_INFO>();
                    OldActiveEntity.ZONE_CODE = null;

                    CIReferenceZoneDataSource.RowFilter = "CODE in('" + lstActiveEntity[0].ZONE_CODE.ToValueAsString() + "','"
                                                          + (lstActiveEntity[0].CI_REFERENCE.IsNotNullOrEmpty() ? lstActiveEntity[0].CI_REFERENCE.ToValueAsString().Substring(0, 1) : "") + "')";
                    if (CIReferenceZoneDataSource.Count > 0)
                    {
                        OldActiveEntity.ZONE_CODE = CIReferenceZoneDataSource[0].Row["CODE"].ToValueAsString();
                    }
                    CIReferenceZoneDataSource.RowFilter = null;
                }
            }
        }
        public CopyCIReferenceViewModel(UserInformation userInformation, WPF.MDI.MdiChild mdiChild, DDCI_INFO oldActiveEntity,
                                        OperationMode operationMode)
        {
            bll = new FeasibleReportAndCostSheet(userInformation);

            EnquiryReceivedOn = bll.ServerDateTime();

            OldCIReferenceDataSource  = bll.GetCIReferenceNumber().ToDataTable <V_CI_REFERENCE_NUMBER>().DefaultView;
            CIReferenceZoneDataSource = bll.GetZoneDetails().ToDataTable <CI_REFERENCE_ZONE>().DefaultView;

            OldActiveEntity = oldActiveEntity;

            if (!OldActiveEntity.IsNotNullOrEmpty())
            {
                OldActiveEntity = new DDCI_INFO();
            }
            EntityPrimaryKey = oldActiveEntity.IDPK;

            #region DropdownColumns Settins
            CiReferenceZoneDropDownItems = new ObservableCollection <DropdownColumns>()
            {
                new DropdownColumns()
                {
                    ColumnName = "CODE", ColumnDesc = "Zone Code", ColumnWidth = "25*"
                },
                new DropdownColumns()
                {
                    ColumnName = "DESCRIPTION", ColumnDesc = "Zone", ColumnWidth = "75*"
                }
            };

            OldCIReferenceDropDownItems = new ObservableCollection <DropdownColumns>()
            {
                new DropdownColumns()
                {
                    ColumnName = "CI_REFERENCE", ColumnDesc = "CI Reference", ColumnWidth = "90"
                },
                new DropdownColumns()
                {
                    ColumnName = "FRCS_DATE", ColumnDesc = "FRCS Date", ColumnWidth = "80"
                },
                new DropdownColumns()
                {
                    ColumnName = "CUST_DWG_NO", ColumnDesc = "Drawing No.", ColumnWidth = "100"
                },
                new DropdownColumns()
                {
                    ColumnName = "CUST_CODE", ColumnDesc = "Customer Code", ColumnWidth = "100"
                },
                new DropdownColumns()
                {
                    ColumnName = "FINISH_CODE", ColumnDesc = "Finish Code", ColumnWidth = "80"
                },
                new DropdownColumns()
                {
                    ColumnName = "CUST_DWG_NO_ISSUE", ColumnDesc = "Customer Drawing Issue No.", ColumnWidth = "175"
                },
                new DropdownColumns()
                {
                    ColumnName = "CUST_STD_DATE", ColumnDesc = "Customer STD Date ", ColumnWidth = "150"
                }
            };

            #endregion

            this.ciReferenceEndEditCommand = new DelegateCommand(this.ciReferenceEndEdit);
            this.oldReferenceSelectedItemChangedCommand = new DelegateCommand(this.OldCIReferenceChanged);

            this.enquiryReceivedOnChangedCommand = new DelegateCommand(this.EnquiryReceivedOnChanged);
            this.saveCommand = new DelegateCommand(this.SaveSubmitCommand);
            this.ciReferenceZoneSelectedItemChangedCommand = new DelegateCommand(this.CIReferenceZoneChanged);

            ActionPermission        = bll.GetUserRights("CIReferenceCopy");
            ActionPermission.AddNew = true;
            ActionPermission.Edit   = true;
            ActionPermission.Save   = true;
            ActionPermission.Close  = true;
            ActionPermission.Print  = true;

            ActionMode = operationMode;
        }