Esempio n. 1
0
        /// <summary>
        /// Provide validation for the segment by overriding this method.
        /// </summary>
        protected override void ValidationMethod(object sender, EventArgs e)
        {
            Trace.WriteLine("ValidationMethod entered.", Name);

            if (Parent != null && Parent.Name != Name)
            {
                throw new ApplicationException(string.Format("Parent must be of type: {0} not {1}", Name, Parent.Name));
            }

            if (string.IsNullOrEmpty(UploadKey))
            {
                throw new ApplicationException("Upload key is a required field.");
            }
            if (!string.IsNullOrEmpty(AhsId))
            {
                throw new ApplicationException("AhsId must be empty.");
            }
            if (!IsNullOrLong(FileTranLogId))
            {
                throw new ApplicationException("FileTranLogId is a numeric field: " + FileTranLogId);
            }
            if (!IsNullOrLong(ParentNodeId))
            {
                throw new ApplicationException("ParentNodeId is a numeric field: " + ParentNodeId);
            }
            if (!string.IsNullOrEmpty(ClientNodeId) && !IsNullOrLong(ClientNodeId))
            {
                throw new ApplicationException("ClientNodeId is a required numeric field.");
            }
            if (!(State.Length == 0 || State.Length == 2))
            {
                throw new ApplicationException("State must be 2 char code: " + State);
            }

            if (Phone.Length > 0)
            {
                Phone = (FormatPhoneField(Phone));
            }

            if (Fax.Length > 0)
            {
                Fax = (FormatPhoneField(Fax));
            }

            if (AltPhone.Length > 0)
            {
                AltPhone = (FormatPhoneField(AltPhone));
            }

            if (AltFax.Length > 0)
            {
                AltFax = (FormatPhoneField(AltFax));
            }

            if (LocName.Length > 80)
            {
                LocName = LocName.Substring(0, 80);
            }
        }
        private void AddSubmitCommand()
        {
            if (LocCode.IsNotNullOrEmpty() || LocName.IsNotNullOrEmpty())
            {
                if (ShowWarningMessage(PDMsg.BeforeCloseForm, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    CommonFormValUpdtae();
                    return;
                }
                else
                {
                    NextAction = "ADD";
                    SetUserRights("ADD");
                    // EditEnable = true;
                    //AddEnable = false;
                    LocCode            = string.Empty;
                    LocName            = string.Empty;
                    DeleteEnable       = false;
                    TxtReadOnly        = false;
                    IsVisibilityDelete = Visibility.Visible;
                    IsActive           = true;
                    IsDeleteEnable     = false;

                    ButtonEnable = Visibility.Collapsed;
                    FocusButton  = true;
                }
            }
            else
            {
                NextAction = "ADD";
                SetUserRights("ADD");
                // EditEnable = true;
                //AddEnable = false;
                LocCode            = string.Empty;
                LocName            = string.Empty;
                DeleteEnable       = false;
                TxtReadOnly        = false;
                IsVisibilityDelete = Visibility.Visible;
                IsActive           = true;
                IsDeleteEnable     = false;

                ButtonEnable = Visibility.Collapsed;
                FocusButton  = true;
            }
        }
        public void CommonFormValUpdtae()
        {
            try
            {
                isActiveSave = (IsActive) ? false : true;
                if (ButtonEnable == Visibility.Visible)
                {
                    NextAction = "EDIT";
                }
                else if (ButtonEnable == Visibility.Collapsed)
                {
                    NextAction = "ADD";
                }

                //    NextAction = "EDIT";

                if (String.IsNullOrEmpty(Convert.ToString(LocCode)) || LocCode.Trim().Length == 0)
                {
                    ShowInformationMessage(PDMsg.NotEmpty("Location Code"));
                    //FocusButton = true;
                    Flag = true;
                    //System.Windows.MessageBox.Show("Location Code should be Entered", "SmartPD", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else if (String.IsNullOrEmpty(LocName) || LocName.Trim().Length == 0)
                {
                    ShowInformationMessage(PDMsg.NotEmpty("Location Name"));
                    // FocusButton = true;
                    Flag = true;
                    //System.Windows.MessageBox.Show("Location Name should be Entered", "SmartPD", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    Flag = false;
                    //Progress.ProcessingText = PDMsg.ProgressUpdateText;
                    //Progress.Start();
                    bool val = oLocMaster.AddNewLocationMaster(isActiveSave, LocCode, LocName, NextAction, ref _errMessage);
                    //Progress.End();
                    if (val)
                    {
                        ShowInformationMessage(_errMessage);
                        FocusButton = true;
                        //System.Windows.MessageBox.Show(_errMessage, "SmartPD", MessageBoxButton.OK, MessageBoxImage.Information);
                        //MessageBox.Show(_errMessage);
                        ClearOperMaster();
                    }
                    if (val == false)
                    {
                        if ((string)_errMessage != "")
                        {
                            ShowInformationMessage(_errMessage);
                        }
                        FocusButton = true;
                        //MessageBox.Show(_errMessage, "SmartPD", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }

                DtDataview = oLocMaster.GetLocationMaster();
                // FocusButton = true;
                if (Flag == true)
                {
                    if (AddEnable == true)
                    {
                        NextAction = "EDIT";
                        SetUserRights("EDIT");
                        ButtonEnable = Visibility.Visible;
                    }
                    else if (EditEnable == true)
                    {
                        NextAction = "ADD";
                        SetUserRights("ADD");
                        ButtonEnable = Visibility.Collapsed;
                    }
                }
                TxtReadOnly = (NextAction == "EDIT") ? true : false;
                //   LoadTableData();
            }
            catch (Exception ex)
            {
                Progress.End();
                throw ex.LogException();
            }
        }