Example #1
0
        /// <summary>
        /// Function AddLocation to create the new location
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>NA</returns>
        /// <createdBy></createdBy>
        /// <createdOn>May-27,2016</createdOn>
        private void UpdateLocation(object obj)
        {
            try
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                AppWorksService.Properties.LocationList objUpdateLocationProp = new AppWorksService.Properties.LocationList();
                objUpdateLocationProp.LocationID           = (int)LocationId;
                objUpdateLocationProp.LocationName         = LocationName;
                objUpdateLocationProp.LocationShortName    = LocationShortName;
                objUpdateLocationProp.LocationType         = DescriptionLocType;
                objUpdateLocationProp.LocationSubType      = DescriptionLocSubType;
                objUpdateLocationProp.CustomerLocationCode = string.Empty;
                objUpdateLocationProp.AddressLine1         = AddressLine1;
                objUpdateLocationProp.AddressLine2         = AddressLine2;
                objUpdateLocationProp.City      = City;
                objUpdateLocationProp.State     = State;
                objUpdateLocationProp.Zip       = Zip;
                objUpdateLocationProp.Country   = Country;
                objUpdateLocationProp.MainPhone = MainPhone;
                objUpdateLocationProp.FaxNumber = FaxNumber;
                objUpdateLocationProp.PrimaryContactFirstName = FirstName;
                objUpdateLocationProp.PrimaryContactLastName  = LastName;
                objUpdateLocationProp.PrimaryContactPhone     = Phone;
                objUpdateLocationProp.PrimaryContactExtension = Extension;
                objUpdateLocationProp.PrimaryContactCellPhone = ContactCellPhone;
                objUpdateLocationProp.PrimaryContactEmail     = Email;

                objUpdateLocationProp.AlternateContactFirstName = AlternateContactFirstName;
                objUpdateLocationProp.AlternateContactLastName  = AlternateContactLastName;
                objUpdateLocationProp.AlternateContactPhone     = AlternateContactPhone;
                objUpdateLocationProp.AlternateContactExtension = OtherContactExtension;
                objUpdateLocationProp.AlternateContactCellPhone = AlternateContactCellPhone;
                objUpdateLocationProp.AlternateContactEmail     = AlternateContactEmail;
                objUpdateLocationProp.OtherPhone1Description    = OtherPhone1Description;

                objUpdateLocationProp.OtherPhone1            = OtherPhone1;
                objUpdateLocationProp.OtherPhone2Description = OtherPhone2Description;
                objUpdateLocationProp.OtherPhone2            = OtherPhone2;
                objUpdateLocationProp.RecordStatus           = RecordStatus;
                objUpdateLocationProp.CreationDate           = CreationDate;
                objUpdateLocationProp.CreatedBy   = CreatedBy;
                objUpdateLocationProp.UpdatedDate = DateTime.Now;
                objUpdateLocationProp.UpdatedBy   = updatedBy;
                objUpdateLocationProp.UpdatedBy   = InternalId;

                // Call service function to add a new location
                bool data = _serviceInstance.UpdateLocation(objUpdateLocationProp);
                if (data)
                {
                    if (!AddressType.Equals(null))
                    {
                        //bool isSuccess = objService.UpdateCustomerAddredss(AddressType, CustomerID, objUpdateLocationProp.LocationID);
                        //if (isSuccess)
                        //{
                        //ObservableCollection<LocationModel> LocationModel = new ObservableCollection<Model.LocationModel>();
                        //LocationModel=ObservableCollection<LocationModel>()
                        //LocationDeligate.SetValueLocationListMethod(GetLocationList);

                        //LocationDeligate.OnSetLocationListValueEvt += new LocationDeligate.SetLocationListValue(ObservableCollection<LocationModel> location);
                        // CustomerAdminDeligate.OnSetCustomerAdminPropertiesValueEvt += new CustomerAdminDeligate.SetCustomerAdminPropertiesValue(NotificationCmdReceived);
                        LocationDeligate.SetValueMethodUpdateCmd("UpdateList");
                        MessageBox.Show(Resources.msgUpdatedSuccessfully);
                        //AddLocation objAddLocation = new AddLocation();


                        //}
                        //else
                        //    MessageBox.Show("Data Updated Successfully but unable to set Address!");
                    }

                    var window = obj as Window;
                    if (window != null)
                    {
                        window.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }

            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }
Example #2
0
        /// <summary>
        /// Function AddLocation to create the new location
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>NA</returns>
        /// <createdBy></createdBy>
        /// <createdOn>May-27,2016</createdOn>
        private void AddLocation(object obj)
        {
            try
            {
                string errMsg = string.Empty;
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                if (!string.IsNullOrEmpty(LocationName) && (!string.IsNullOrEmpty(LocationName)))
                {
                    if (!string.IsNullOrEmpty(DescriptionLocType) && (!string.IsNullOrEmpty(DescriptionLocType)))
                    {
                        if (!string.IsNullOrEmpty(DescriptionLocSubType) && (!string.IsNullOrEmpty(DescriptionLocSubType)))
                        {
                            if (!string.IsNullOrEmpty(Zip) && (!string.IsNullOrEmpty(Zip)))
                            {
                                ValidateEmail emailValidation = new ValidateEmail();
                                bool          isValid         = emailValidation.IsValidEmail(Email);
                                if (isValid || string.IsNullOrEmpty(Email))
                                {
                                    // creating the object of service property and setting the values
                                    AppWorksService.Properties.LocationList objAddLocationProp = new AppWorksService.Properties.LocationList();

                                    objAddLocationProp.ParentRecordID       = Convert.ToInt32(Application.Current.Resources["CustomerAdminID"]);
                                    objAddLocationProp.ParentRecordTable    = "Customer";
                                    objAddLocationProp.LocationName         = LocationName;
                                    objAddLocationProp.LocationShortName    = LocationShortName;
                                    objAddLocationProp.LocationType         = DescriptionLocType;
                                    objAddLocationProp.LocationSubType      = DescriptionLocSubType;
                                    objAddLocationProp.CustomerLocationCode = string.Empty;
                                    objAddLocationProp.AddressLine1         = AddressLine1;
                                    objAddLocationProp.AddressLine2         = AddressLine2;
                                    objAddLocationProp.City      = City;
                                    objAddLocationProp.State     = State;
                                    objAddLocationProp.Zip       = Zip;
                                    objAddLocationProp.Country   = Country;
                                    objAddLocationProp.MainPhone = MainPhone;
                                    objAddLocationProp.FaxNumber = FaxNumber;
                                    objAddLocationProp.PrimaryContactFirstName = FirstName;
                                    objAddLocationProp.PrimaryContactLastName  = LastName;
                                    objAddLocationProp.PrimaryContactPhone     = Phone;
                                    objAddLocationProp.PrimaryContactExtension = Extension;
                                    objAddLocationProp.PrimaryContactCellPhone = ContactCellPhone;
                                    objAddLocationProp.PrimaryContactEmail     = Email;

                                    objAddLocationProp.AlternateContactFirstName = AlternateContactFirstName;
                                    objAddLocationProp.AlternateContactLastName  = AlternateContactLastName;
                                    objAddLocationProp.AlternateContactPhone     = AlternateContactPhone;
                                    objAddLocationProp.AlternateContactExtension = OtherContactExtension;
                                    objAddLocationProp.AlternateContactCellPhone = AlternateContactCellPhone;
                                    objAddLocationProp.AlternateContactEmail     = AlternateContactEmail;
                                    objAddLocationProp.OtherPhone1Description    = OtherPhone1Description;

                                    objAddLocationProp.OtherPhone1            = OtherPhone1;
                                    objAddLocationProp.OtherPhone2Description = OtherPhone2Description;
                                    objAddLocationProp.OtherPhone2            = OtherPhone2;
                                    objAddLocationProp.RecordStatus           = RecordStatus;
                                    objAddLocationProp.CreationDate           = CreationDate;
                                    objAddLocationProp.CreatedBy   = CreatedBy;
                                    objAddLocationProp.UpdatedDate = UpdatedDate;
                                    objAddLocationProp.UpdatedBy   = updatedBy;
                                    objAddLocationProp.UpdatedBy   = InternalId;

                                    // Call service function to add a new location
                                    int data = _serviceInstance.AddLocation(objAddLocationProp);

                                    if (data > 0)
                                    {
                                        LocationId = data;
                                        LocationDeligate.SetValueMethodUpdateCmd("UpdateList");
                                        MessageBox.Show(Resources.msgInsertedSuccessfully);
                                        var window = obj as Window;
                                        if (window != null)
                                        {
                                            window.Close();
                                        }
                                    }
                                }
                                else
                                {
                                    //ClsValidationPopUp.ErrMsgUserPin = Resources.ErrorEmptyPin
                                    errMsg = Resources.ErrorEmail;
                                    AutoLogOffPopup objAutoLogOffPopup = new AutoLogOffPopup(errMsg);
                                    objAutoLogOffPopup.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                                    objAutoLogOffPopup.ShowDialog();
                                }
                            }
                            else
                            {
                                MessageBox.Show(Resources.msgLocationZipReq);
                            }
                        }
                        else
                        {
                            MessageBox.Show(Resources.msgLocationSubTypeReq);
                        }
                    }
                    else
                    {
                        MessageBox.Show(Resources.msgLocationTypeReq);
                    }
                }
                else
                {
                    MessageBox.Show(Resources.msgLocationNameReq);
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }

            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }