Example #1
0
        protected void btnClone_Click(object sender, EventArgs e)
        {
            BookingRepository bRepo    = new BookingRepository();
            double            giffiRef = -1;

            //clone data

            if (!double.TryParse(txtGiffRef.Text, out giffiRef))
            {
                this.Page.AlertMessage(GetType(), string.Format("INVALID GiffiRefId={0}", giffiRef));
                return;
            }

            try
            {
                int bookingId = DataUtil.GetBookingIdFromGiffiId(giffiRef);
                //popular with new giffiId
                int    newBookingId = -1;
                string newGiffiId   = string.Empty;
                if (bRepo.CloneBooking(bookingId, out newBookingId, out newGiffiId))
                {
                    txtGiffRef.Text = newGiffiId;
                    txtGiffRef.DataBind();

                    PopulateData(newBookingId);

                    this.Page.AlertMessage(GetType(), string.Format("Successfully clone booking data to new GiffiRef={0}.", giffiRef.ToString("R")));

                    btnClone.Visible         = false;
                    btnSubmitBooking.Visible = true;
                    btnNext.Visible          = true;
                    btnClose.Visible         = true;
                }
                else
                {
                    this.Page.AlertMessage(GetType(), "Failed to Clone existing record!!!");
                }
            }
            catch (SqlException se)
            {
                this.Page.AlertMessage(GetType(), string.Format("Failed to Clone existing record!!! With SQLError={0}", se.Message));
            }
            catch (Exception ex)
            {
                this.Page.AlertMessage(GetType(), string.Format("Failed to Clone existing record!!! Error={0}", ex.Message));
            }
        }