private void RefreshGrid()
    {
        int AccomodationId = Convert.ToInt32(ddlAccomodation.SelectedValue);
        AccomodationContactsMaster oAccomodationContactMaster;

        AccomContactDTO[] oAccomodationContactData;
        oAccomodationContactMaster = new AccomodationContactsMaster();
        oAccomodationContactData   = oAccomodationContactMaster.GetAccomodationContacts(AccomodationId);
        if (oAccomodationContactData != null)
        {
            if (oAccomodationContactData.Length > 0)
            {
                dgAccomodationContacts.DataSource = oAccomodationContactData;
                dgAccomodationContacts.DataBind();
            }
        }
        else
        {
            dgAccomodationContacts.DataSource = null;
            dgAccomodationContacts.DataBind();
        }
        ClearPageControls();
        oAccomodationContactMaster = null;
        oAccomodationContactData   = null;
    }
    private void Save()
    {
        if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Add))
        {
            return;
        }

        if (ValidateValues() == false)
        {
            return;
        }

        bool bActionCompleted = false;

        AccomContactDTO oAccomodationContactData = MapControlsToObject();

        AccomodationContactsMaster oAccomodationContactMaster = new AccomodationContactsMaster();

        bActionCompleted = oAccomodationContactMaster.Insert(oAccomodationContactData);
        if (bActionCompleted == true)
        {
            base.DisplayAlert("The record has been inserted successfully");
            ClearPageControls();
            lblStatus.Text = "Saved";
        }
        else
        {
            lblStatus.Text = "Error Occured while insertion: Please refer to the error log.";
        }

        oAccomodationContactData   = null;
        oAccomodationContactMaster = null;
    }
    protected void btnCopyContacts_Click(object sender, EventArgs e)
    {
        if (ddlAccomodation.SelectedItem.Text == "Choose Accomodation")
        {
            base.DisplayAlert("Please choose the accomodation.");
            return;
        }

        if (ddlDestinationAccomodation.SelectedItem.Text == "Choose Accomodation")
        {
            base.DisplayAlert("Please choose the destination.");
            return;
        }

        if (ddlAccomodation.SelectedItem.Text == ddlDestinationAccomodation.SelectedItem.Text)
        {
            base.DisplayAlert("Source and destination cannot be same.");
            return;
        }
        int SourceAccomodationId, DestinationAccomodationId;

        int.TryParse(ddlAccomodation.SelectedItem.Value, out SourceAccomodationId);
        int.TryParse(ddlDestinationAccomodation.SelectedItem.Value, out DestinationAccomodationId);

        AccomodationContactsMaster objAccomodationContactsMaster = new AccomodationContactsMaster();

        objAccomodationContactsMaster.CopyContacts(SourceAccomodationId, DestinationAccomodationId);
        base.DisplayAlert("Contacts are copied.");
        return;
    }
    private void Delete()
    {
        if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Delete))
        {
            return;
        }

        if (ValidateValues() == false)
        {
            return;
        }
        bool bActionCompleted = false;
        int  Id = 0;

        int.TryParse(hfId.Value, out Id);
        if (Id == 0)
        {
            lblStatus.Text = "Please click on edit button again.";
            return;
        }

        AccomContactDTO oAccomodationContactData = new AccomContactDTO();

        oAccomodationContactData.ContactId = Id;
        AccomodationContactsMaster oAccomodationContactMaster = new AccomodationContactsMaster();

        /*
         * ADDED BY VIJAY
         * CHECK IF THE AccomodationContact WHICH IS TO BE DELETED HAS ANY ASSOCIATED RECORDS...IF YES, MOVE OUT OF THE FUNCTION ELSE PROCEED
         * IF THE OUTPUT OF sMessage IS "", THEN RECORD CAN BE DELETED, ELSE NOT
         *
         */
        string sMessage = "";

        GF.HasRecords(Convert.ToString(Id), "tblAccomodationContactsMaster", out sMessage);
        if (sMessage != "")
        {
            base.DisplayAlert(sMessage);
            btnDelete.Enabled = true;
        }
        else
        {
            bActionCompleted = oAccomodationContactMaster.Delete(oAccomodationContactData);

            if (bActionCompleted == true)
            {
                base.DisplayAlert("The record has been deleted successfully");
                ClearPageControls();
                //lblStatus.Text = "Deleted";
                RefreshGrid();
            }
            else
            {
                base.DisplayAlert("Error Occured while deletion: Please refer to the error log.");
            }
        }
        oAccomodationContactData   = null;
        oAccomodationContactMaster = null;
    }
Пример #5
0
        private static EmailIdDTO GetAccomodationContact(int BookingId)
        {
            EmailIdDTO emailIdDTO = null;
            AccomodationContactsMaster accomodationContactsMaster = new AccomodationContactsMaster();

            AccomContactDTO[] accomContactDTO = accomodationContactsMaster.GetAccomodationContactsOfBooking(BookingId);

            if (accomContactDTO != null && accomContactDTO.Length > 0)
            {
                emailIdDTO = new EmailIdDTO();
                emailIdDTO.ContactPerson = accomContactDTO[0].ContactName;
                emailIdDTO.TOs           = accomContactDTO[0].ToId;
                emailIdDTO.CCs           = accomContactDTO[0].CCId;
                emailIdDTO.BCCs          = accomContactDTO[0].BCCId;
            }
            return(emailIdDTO);
        }
    private void Update()
    {
        if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Update))
        {
            return;
        }

        if (ValidateValues() == false)
        {
            return;
        }

        bool bActionCompleted = false;
        int  Id = 0;

        int.TryParse(hfId.Value, out Id);
        if (Id == 0)
        {
            lblStatus.Text = "Please click on edit button again.";
            return;
        }
        AccomContactDTO oAccomodationContactData = new AccomContactDTO();

        oAccomodationContactData.ContactId      = Id;
        oAccomodationContactData.AccomodationId = Convert.ToInt32(ddlAccomodation.SelectedValue);
        oAccomodationContactData.ContactName    = txtContactName.Text.ToString();
        oAccomodationContactData.ToId           = txtToIds.Text;
        oAccomodationContactData.CCId           = txtCCIds.Text;
        oAccomodationContactData.BCCId          = txtBCCIds.Text;

        oAccomodationContactData.MailOnBooking = false;
        if (rdBookingYes.Checked)
        {
            oAccomodationContactData.MailOnBooking = true;
        }

        oAccomodationContactData.MailOnBookingUpdate = false;
        if (rdBookingUpdatYes.Checked)
        {
            oAccomodationContactData.MailOnBookingUpdate = true;
        }

        oAccomodationContactData.MailOnBookingConfirmation = false;
        if (rdConfirmationYes.Checked)
        {
            oAccomodationContactData.MailOnBookingConfirmation = true;
        }

        oAccomodationContactData.MailOnBookingConfirmationUpdate = false;
        if (rdConfirmationUpdateYes.Checked)
        {
            oAccomodationContactData.MailOnBookingConfirmationUpdate = true;
        }

        oAccomodationContactData.MailOnCancellation = false;
        if (rdCancellationYes.Checked)
        {
            oAccomodationContactData.MailOnCancellation = true;
        }

        oAccomodationContactData.MailOnDeletion = false;
        if (rdDeletionYes.Checked)
        {
            oAccomodationContactData.MailOnDeletion = true;
        }

        AccomodationContactsMaster oAccomodationContactMaster = new AccomodationContactsMaster();

        bActionCompleted = oAccomodationContactMaster.Update(oAccomodationContactData);
        if (bActionCompleted == true)
        {
            base.DisplayAlert("The record has been updated successfully");
            txtContactName.Text = "";
            lblStatus.Text      = "Updated";
        }
        else
        {
            lblStatus.Text = "Error Occured while updation: Please refer to the error log.";
        }
        oAccomodationContactData   = null;
        oAccomodationContactMaster = null;
    }
    protected void dgAccomodationContacts_SelectedIndexChanged(object sender, EventArgs e)
    {
        int iContactID = 0;

        int.TryParse(Convert.ToString(dgAccomodationContacts.DataKeys[dgAccomodationContacts.SelectedIndex]), out iContactID);
        hfId.Value = iContactID.ToString();

        AccomodationContactsMaster oAccomodationContactMaster = new AccomodationContactsMaster();

        AccomContactDTO[] oAccomodationContactData = oAccomodationContactMaster.GetAccomodationContacts(0, iContactID);
        if (oAccomodationContactData.Length > 0)
        {
            ddlAccomodation.SelectedIndex = oAccomodationContactData[0].AccomodationId;
            txtContactName.Text           = oAccomodationContactData[0].ContactName;
            txtToIds.Text  = oAccomodationContactData[0].ToId;
            txtCCIds.Text  = oAccomodationContactData[0].CCId;
            txtBCCIds.Text = oAccomodationContactData[0].BCCId;

            if (oAccomodationContactData[0].MailOnBooking)
            {
                rdBookingYes.Checked = true;
            }
            else
            {
                rdBookingNo.Checked = true;
            }

            if (oAccomodationContactData[0].MailOnBookingUpdate)
            {
                rdBookingUpdatYes.Checked = true;
            }
            else
            {
                rdBookingUpdatNo.Checked = true;
            }

            if (oAccomodationContactData[0].MailOnBookingConfirmation)
            {
                rdConfirmationYes.Checked = true;
            }
            else
            {
                rdConfirmationNo.Checked = true;
            }

            if (oAccomodationContactData[0].MailOnBookingConfirmationUpdate)
            {
                rdConfirmationUpdateYes.Checked = true;
            }
            else
            {
                rdConfirmationUpdateNo.Checked = true;
            }

            if (oAccomodationContactData[0].MailOnCancellation)
            {
                rdCancellationYes.Checked = true;
            }
            else
            {
                rdCancellationNo.Checked = true;
            }

            if (oAccomodationContactData[0].MailOnDeletion)
            {
                rdDeletionYes.Checked = true;
            }
            else
            {
                rdDeletionNo.Checked = true;
            }
        }
        oAccomodationContactMaster = null;
        oAccomodationContactData   = null;

        btnAddNew.Enabled = false;
        btnCancel.Enabled = true;
        btnDelete.Enabled = true;
        //btnEdit.Text = "Update";
        btnSave.Text    = "Update";
        btnSave.Enabled = true;
        //btnEdit.Enabled = true;
        //btnSave.Enabled = false;
        lblStatus.Text = "";
    }