protected void GridOpenDates_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Select")
            {
                ViewState["flag"] = "1";
                LinkButton  lnk  = (LinkButton)e.CommandSource;
                GridViewRow grow = (GridViewRow)lnk.NamingContainer;
                int         id   = Convert.ToInt32(GridOpenDates.DataKeys[grow.RowIndex].Value);

                hfid.Value = id.ToString();

                blOpenDates._Action = "GetOpenDatesbyId";
                blOpenDates.Id      = id;
                dtGetReturnedData   = new DataTable();
                dtGetReturnedData   = dlOpenDates.getOpenDatesbyId(blOpenDates);
                if (dtGetReturnedData != null)
                {
                    bindrivers(Convert.ToInt32(dtGetReturnedData.Rows[0]["CountryId"].ToString()));
                    sethiddenfieldnights(dtGetReturnedData.Rows[0]["packageId"].ToString());
                    txtBoardingDate.Text     = Convert.ToDateTime(dtGetReturnedData.Rows[0]["CheckInDate"]).ToString("MM/dd/yyyy");
                    txtDeBordingDate.Text    = Convert.ToDateTime(dtGetReturnedData.Rows[0]["CheckOutDate"]).ToString("MM/dd/yyyy");
                    ddlAccom.SelectedValue   = dtGetReturnedData.Rows[0]["AccomId"].ToString();
                    ddlCountry.SelectedValue = dtGetReturnedData.Rows[0]["CountryId"].ToString();
                    ddlpackage.SelectedValue = dtGetReturnedData.Rows[0]["packageId"].ToString();
                    ddlRiver.SelectedValue   = dtGetReturnedData.Rows[0]["RiverId"].ToString();
                    btnAdd.Text = "Update";
                }
                else
                {
                    txtBoardingDate.Text     = "";
                    txtDeBordingDate.Text    = "";
                    ddlAccom.SelectedIndex   = 0;
                    ddlCountry.SelectedIndex = 0;
                    ddlpackage.SelectedIndex = 0;
                    ddlRiver.SelectedIndex   = 0;
                }
            }
            if (e.CommandName == "Open")
            {
                int getid = Convert.ToInt32(e.CommandArgument.ToString());
                blOpenDates.Id      = getid;
                blOpenDates._Action = "GetOpenDatesbyId";
                DataTable dt          = dlOpenDates.getOpenDatesbyId(blOpenDates);
                DataTable getavialabl = bindroomddl(getid, dt.Rows[0]["packageId"].ToString());
                DataView  dv          = new DataView();
                dv = new DataView(getavialabl, "BookedStatus='Not Available'", "BookedStatus", DataViewRowState.CurrentRows);
                DataTable dt2   = dv.ToTable();
                bool      check = Convert.ToBoolean(dt.Rows[0]["Openclose"]);
                if (dt2 != null && dt2.Rows.Count > 0 && check != true)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "QuoteFull", "javascript:alert('Close can only happen if there is no booking on those departures')", true);
                    return;
                }
                else
                {
                    blsr.action    = "getchilid";
                    blsr.PackageId = dt.Rows[0]["packageId"].ToString();
                    DataTable dtchild = dlsr.getchilid(blsr);
                    if (dtchild != null && dtchild.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtchild.Rows.Count; i++)
                        {
                            blsr.action       = "getdepartureid";
                            blsr.PackageId    = dtchild.Rows[i]["PackageId"].ToString();
                            blsr._dtStartDate = Convert.ToDateTime(dt.Rows[0]["CheckInDate"].ToString());
                            blsr._dtEndDate   = Convert.ToDateTime(dt.Rows[0]["CheckOutDate"].ToString());
                            DataTable dtgetdepurtureid = dlsr.getdepartureid(blsr);
                            if (dtgetdepurtureid != null && dtgetdepurtureid.Rows.Count > 0)
                            {
                                blsr.action      = "GetcruiseRooms";
                                blsr.DepartureId = Convert.ToInt32(dtgetdepurtureid.Rows[0]["Id"].ToString());
                                DataTable dtgetchild = dlsr.GetCruiseRooms(blsr);
                                DataView  dvgetchild = new DataView();
                                dvgetchild = new DataView(dtgetchild, "BookedStatus='Not Available'", "BookedStatus", DataViewRowState.CurrentRows);
                                dtgetchild = dvgetchild.ToTable();
                                if (dtgetchild != null && dtgetchild.Rows.Count > 0)
                                {
                                    Session["set"] = null;
                                }
                                else
                                {
                                    Session["set"] = 1;
                                }
                            }
                            else
                            {
                                Session["set"] = 1;
                            }
                        }
                    }
                    else
                    {
                        blsr.action       = "getdepartureid";
                        blsr.PackageId    = dt.Rows[0]["PackageId"].ToString();
                        blsr._dtStartDate = Convert.ToDateTime(dt.Rows[0]["CheckInDate"].ToString());
                        blsr._dtEndDate   = Convert.ToDateTime(dt.Rows[0]["CheckOutDate"].ToString());
                        DataTable dtgetdepurtureid = dlsr.getdepartureid(blsr);
                        if (dtgetdepurtureid != null && dtgetdepurtureid.Rows.Count > 0)
                        {
                            blsr.action      = "GetcruiseRooms";
                            blsr.DepartureId = Convert.ToInt32(dtgetdepurtureid.Rows[0]["Id"].ToString());
                            DataTable dtgetchild = dlsr.GetCruiseRooms(blsr);
                            DataView  dvgetchild = new DataView();
                            dvgetchild = new DataView(dtgetchild, "BookedStatus='Not Available'", "BookedStatus", DataViewRowState.CurrentRows);
                            dtgetchild = dvgetchild.ToTable();
                            if (dtgetchild != null && dtgetchild.Rows.Count > 0)
                            {
                                Session["set"] = null;
                            }
                            else
                            {
                                Session["set"] = 1;
                            }
                        }
                    }
                    if (Session["set"] != null || check == true)
                    {
                        int n = dalp.updateopenclose(getid);
                        if (n == 1)
                        {
                            for (int i = 0; i < dtchild.Rows.Count; i++)
                            {
                                blsr.action       = "getdepartureid";
                                blsr.PackageId    = dtchild.Rows[i]["PackageId"].ToString();
                                blsr._dtStartDate = Convert.ToDateTime(dt.Rows[0]["CheckInDate"].ToString());
                                blsr._dtEndDate   = Convert.ToDateTime(dt.Rows[0]["CheckOutDate"].ToString());
                                DataTable dtgetdepurtureid = dlsr.getdepartureid(blsr);
                                try
                                {
                                    int n1 = dalp.updateopenclosebydate(Convert.ToInt32(dtgetdepurtureid.Rows[0]["Id"].ToString()));
                                    if (n1 == 1)
                                    {
                                    }
                                }
                                catch (Exception ex) { }
                            }
                            Session["set"] = null;
                            Button1_Click(this, e);
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "QuoteFull", "javascript:alert('Update Successfully')", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "QuoteFull", "javascript:alert('Please try again')", true);
                            return;
                        }
                    }
                }
            }
                << << << < HEAD
                == == == =
                    if (e.CommandName == "Open")
                    {
                    int getid = Convert.ToInt32(e.CommandArgument.ToString());
                    blOpenDates.Id      = getid;
                    blOpenDates._Action = "GetOpenDatesbyId";
                    DataTable dt          = dlOpenDates.getOpenDatesbyId(blOpenDates);
                    DataTable getavialabl = bindroomddl(getid, dt.Rows[0]["packageId"].ToString());
                    DataView  dv          = new DataView();
                    dv = new DataView(getavialabl, "BookedStatus='Not Available'", "BookedStatus", DataViewRowState.CurrentRows);
                    DataTable dt2   = dv.ToTable();
                    bool      check = Convert.ToBoolean(dt.Rows[0]["Openclose"]);
                    if (dt2 != null && dt2.Rows.Count > 0 && check != true)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "QuoteFull", "javascript:alert('Close can only happen if there is no booking on those departures')", true);
                        return;
                    }
                    else
                    {
                        blsr.action    = "getchilid";
                        blsr.PackageId = dt.Rows[0]["packageId"].ToString();
                        DataTable dtchild = dlsr.getchilid(blsr);
                        if (dtchild != null && dtchild.Rows.Count > 0)
                        {
                            for (int i = 0; i < dtchild.Rows.Count; i++)
                            {
                                blsr.action       = "getdepartureid";
                                blsr.PackageId    = dtchild.Rows[i]["PackageId"].ToString();
                                blsr._dtStartDate = Convert.ToDateTime(dt.Rows[0]["CheckInDate"].ToString());
                                blsr._dtEndDate   = Convert.ToDateTime(dt.Rows[0]["CheckOutDate"].ToString());
                                DataTable dtgetdepurtureid = dlsr.getdepartureid(blsr);
                                if (dtgetdepurtureid != null && dtgetdepurtureid.Rows.Count > 0)
                                {
                                    blsr.action      = "GetcruiseRooms";
                                    blsr.DepartureId = Convert.ToInt32(dtgetdepurtureid.Rows[0]["Id"].ToString());
                                    DataTable dtgetchild = dlsr.GetCruiseRooms(blsr);
                                    DataView  dvgetchild = new DataView();
                                    dvgetchild = new DataView(dtgetchild, "BookedStatus='Not Available'", "BookedStatus", DataViewRowState.CurrentRows);
                                    dtgetchild = dvgetchild.ToTable();
                                    if (dtgetchild != null && dtgetchild.Rows.Count > 0)
                                    {
                                        Session["set"] = null;
                                    }
                                    else
                                    {
                                        Session["set"] = 1;
                                    }
                                }
                            }
                        }
                        else
                        {
                            blsr.action       = "getdepartureid";
                            blsr.PackageId    = dt.Rows[0]["PackageId"].ToString();
                            blsr._dtStartDate = Convert.ToDateTime(dt.Rows[0]["CheckInDate"].ToString());
                            blsr._dtEndDate   = Convert.ToDateTime(dt.Rows[0]["CheckOutDate"].ToString());
                            DataTable dtgetdepurtureid = dlsr.getdepartureid(blsr);
                            if (dtgetdepurtureid != null && dtgetdepurtureid.Rows.Count > 0)
                            {
                                blsr.action      = "GetcruiseRooms";
                                blsr.DepartureId = Convert.ToInt32(dtgetdepurtureid.Rows[0]["Id"].ToString());
                                DataTable dtgetchild = dlsr.GetCruiseRooms(blsr);
                                DataView  dvgetchild = new DataView();
                                dvgetchild = new DataView(dtgetchild, "BookedStatus='Not Available'", "BookedStatus", DataViewRowState.CurrentRows);
                                dtgetchild = dvgetchild.ToTable();
                                if (dtgetchild != null && dtgetchild.Rows.Count > 0)
                                {
                                    Session["set"] = null;
                                }
                                else
                                {
                                    Session["set"] = 1;
                                }
                            }
                        }
                        if (Session["set"] != null)
                        {
                            int n = dalp.updateopenclose(getid);
                            if (n == 1)
                            {
                                for (int i = 0; i < dtchild.Rows.Count; i++)
                                {
                                    blsr.action       = "getdepartureid";
                                    blsr.PackageId    = dtchild.Rows[i]["PackageId"].ToString();
                                    blsr._dtStartDate = Convert.ToDateTime(dt.Rows[0]["CheckInDate"].ToString());
                                    blsr._dtEndDate   = Convert.ToDateTime(dt.Rows[0]["CheckOutDate"].ToString());
                                    DataTable dtgetdepurtureid = dlsr.getdepartureid(blsr);
                                    try
                                    {
                                        int n1 = dalp.updateopenclosebydate(Convert.ToInt32(dtgetdepurtureid.Rows[0]["Id"].ToString()));
                                        if (n1 == 1)
                                        {
                                        }
                                    }
                                    catch (Exception ex) { }
                                }
                                Session["set"] = null;
                                Button1_Click(this, e);
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "QuoteFull", "javascript:alert('Update Successfully')", true);
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "QuoteFull", "javascript:alert('Please try again')", true);
                                return;
                            }
                        }
                    }
                }