void AddContainers()
        {
            Containers = (List <IBookingContainer>)ViewState["BookingCntr"];
            if (Containers == null)
            {
                Containers = new List <IBookingContainer>();
            }
            oBookingBll = new LeaseBLL();

            oBookingBll.DeactivateAllContainersAgainstLeaseId(Convert.ToInt32(hdnLeaseID.Value));

            foreach (IBookingContainer Container in Containers)
            {
                Container.BookingID = Convert.ToInt32(hdnLeaseID.Value);
                oBookingBll.AddEditLeaseContainer(Container);
            }
        }
        protected void btnSave_Click1(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                //if (Convert.ToDecimal(txtWFrom.Text) > Convert.ToDecimal(txtWTo.Text))
                //{
                //    ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('" + ResourceManager.GetStringWithoutName("ERR00077") + "');</script>", false);
                //    return;
                //}


                if (ViewState["BookingCntr"] != null)
                {
                    Containers = (List <IBookingContainer>)ViewState["BookingCntr"];
                }

                oBookingBll    = new LeaseBLL();
                oBookingEntity = new LeaseEntity();
                if (hdnLeaseID.Value == "0" || hdnLeaseID.Value == string.Empty)
                {
                    if (oBookingBll.CheckForDuplicateLease(txtLeaseNo.Text) != 0)
                    {
                        lblError.Text = "Duplicate Lease No. Entry rejected";
                        return;
                    }
                }


                //oUserEntity = (UserEntity)Session[Constants.SESSION_USER_INFO]; // This section has been commented temporarily

                oBookingEntity.LinerID        = ddlNvocc.SelectedValue.ToInt();
                oBookingEntity.LocationID     = ddlLocation.SelectedValue.ToInt();
                oBookingEntity.LeaseID        = Convert.ToInt32(hdnLeaseID.Value);
                oBookingEntity.LeaseNo        = Convert.ToString(txtLeaseNo.Text);
                oBookingEntity.LeaseValidTill = Convert.ToDateTime(txtLeaseValidity.Text);
                oBookingEntity.LeaseCompany   = txtLeaseCompany.Text.ToString();
                oBookingEntity.LeaseDate      = txtLeaseDate.Text.ToDateTime();
                oBookingEntity.fk_EmptyYardID = ddlEmptyYard.SelectedValue.ToInt();


                if (hdnLeaseID.Value == "0")             // Insert
                {
                    oBookingEntity.CreatedBy  = _userId; // oUserEntity.Id;
                    oBookingEntity.CreatedOn  = DateTime.Today.Date;
                    oBookingEntity.ModifiedBy = _userId; // oUserEntity.Id;
                    oBookingEntity.ModifiedOn = DateTime.Today.Date;
                    int outLeaseId = 0;
                    switch (oBookingBll.AddEditLease(oBookingEntity, _CompanyId, ref outLeaseId))
                    {
                    case -1: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00076");
                        break;

                    case 0: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00011");
                        ClearAll();
                        break;

                    case 1:
                        oBookingBll.DeactivateAllContainersAgainstLeaseId(outLeaseId);
                        switch (AddContainers(outLeaseId))
                        {
                        case -1: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00076");
                            break;

                        case 0: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00011");
                            ClearAll();
                            break;

                        case 1: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00009");
                            ClearAll();
                            break;
                        }
                        break;
                    }
                }
                else // Update
                {
                    oBookingEntity.LeaseID    = Convert.ToInt32(hdnLeaseID.Value);
                    oBookingEntity.ModifiedBy = _userId;// oUserEntity.Id;
                    oBookingEntity.ModifiedOn = DateTime.Today.Date;
                    oBookingEntity.Action     = true;
                    //
                    int outLeaseId = 0;
                    switch (oBookingBll.AddEditLease(oBookingEntity, _CompanyId, ref outLeaseId))
                    {
                    case -1: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00076");
                        break;

                    case 0: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00011");
                        break;

                    case 1:
                        oBookingBll.DeactivateAllContainersAgainstLeaseId(outLeaseId);
                        switch (AddContainers(outLeaseId))
                        {
                        case -1: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00076");
                            break;

                        case 0: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00011");
                            ClearAll();
                            break;

                        case 1: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00009");
                            ClearAll();
                            break;
                        }
                        break;
                    }
                }
                Response.Redirect("~/Equipment/LeaseReference.aspx");
            }
        }