public void CreateCr()
    {
        MessageContent.InnerHtml = "";

        if (String.IsNullOrEmpty(txtShipNM.Text.Trim()) || String.IsNullOrEmpty(txtDestination.Text.Trim()) || String.IsNullOrEmpty(txtDays.Text.Trim()) || String.IsNullOrEmpty(txtPort.Text.Trim()))
        {
            MessageContent.InnerHtml = "航线基础信息保存 *号位必填字段,请修改!";
            return;
        }

        _cruiseinfoEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _commonEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _cruiseinfoEntity.LogMessages.Userid = UserSession.Current.UserAccount;
        _cruiseinfoEntity.LogMessages.Username = UserSession.Current.UserDspName;
        _cruiseinfoEntity.LogMessages.IpAddress = UserSession.Current.UserIP;

        _cruiseinfoEntity.CruiseInfoDBEntity = new List<CruiseInfoDBEntity>();
        CruiseInfoDBEntity cruiseInfoDBEntity = new CruiseInfoDBEntity();

        cruiseInfoDBEntity.CruiseID = hidCruiseID.Value.ToString();
        cruiseInfoDBEntity.ShipNM = txtShipNM.Text.Trim();
        cruiseInfoDBEntity.Destination = txtDestination.Text.Trim();
        cruiseInfoDBEntity.Days = txtDays.Text.Trim();
        cruiseInfoDBEntity.Port = txtPort.Text.Trim();

        _cruiseinfoEntity.CruiseInfoDBEntity.Add(cruiseInfoDBEntity);
        _cruiseinfoEntity = CruiseInfoBP.SaveCruiseInfo(_cruiseinfoEntity);
        int iResult = _cruiseinfoEntity.Result;
        string HotelID = _cruiseinfoEntity.ErrorMSG;
        _commonEntity.LogMessages = _cruiseinfoEntity.LogMessages;
        _commonEntity.CommonDBEntity = new List<CommonDBEntity>();
        CommonDBEntity commonDBEntity = new CommonDBEntity();

        commonDBEntity.Event_Type = "航线基础信息-保存";
        commonDBEntity.Event_ID = HotelID;
        string conTent = GetLocalResourceObject("EventSaveMessage").ToString();

        conTent = string.Format(conTent, HotelID, cruiseInfoDBEntity.ShipNM, cruiseInfoDBEntity.Destination, cruiseInfoDBEntity.Days, cruiseInfoDBEntity.Port);
        commonDBEntity.Event_Content = conTent;

        if (iResult == 1)
        {
            commonDBEntity.Event_Result = string.Format(GetLocalResourceObject("SaveSuccess").ToString(), HotelID);
            MessageContent.InnerHtml = string.Format(GetLocalResourceObject("SaveSuccess").ToString(), HotelID);
        }
        else
        {
            commonDBEntity.Event_Result = GetLocalResourceObject("SaveError").ToString();
            MessageContent.InnerHtml = GetLocalResourceObject("SaveError").ToString();
        }
        _commonEntity.CommonDBEntity.Add(commonDBEntity);
        CommonBP.InsertEventHistory(_commonEntity);
    }
    public static string CrCruisePlan(string Action, string BoatID, string CreateStart, string PlanNumer)
    {
        CruiseInfoEntity _cruiseinfoEntity = new CruiseInfoEntity();
        CommonEntity _commonEntity = new CommonEntity();
        _cruiseinfoEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _commonEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _cruiseinfoEntity.LogMessages.Userid = UserSession.Current.UserAccount;
        _cruiseinfoEntity.LogMessages.Username = UserSession.Current.UserDspName;
        _cruiseinfoEntity.LogMessages.IpAddress = UserSession.Current.UserIP;

        _cruiseinfoEntity.CruiseInfoDBEntity = new List<CruiseInfoDBEntity>();
        CruiseInfoDBEntity cruiseInfoDBEntity = new CruiseInfoDBEntity();

        cruiseInfoDBEntity.Action = Action;
        cruiseInfoDBEntity.BoatID = BoatID;
        cruiseInfoDBEntity.CreateStart = CreateStart;
        cruiseInfoDBEntity.PlanNumer = PlanNumer;

        _cruiseinfoEntity.CruiseInfoDBEntity.Add(cruiseInfoDBEntity);
        _cruiseinfoEntity = CruiseInfoBP.SaveCruisePlanList(_cruiseinfoEntity);
        int iResult = _cruiseinfoEntity.Result;
        //_commonEntity.LogMessages = _cruiseinfoEntity.LogMessages;
        //_commonEntity.CommonDBEntity = new List<CommonDBEntity>();
        //CommonDBEntity commonDBEntity = new CommonDBEntity();

        //commonDBEntity.Event_Type = "游轮库存-保存";
        //commonDBEntity.Event_ID = cruiseInfoDBEntity.PlanID;
        //string conTent = "库存保存 - 原库存:{0}  修改后库存:{1}";

        //conTent = string.Format(conTent, PlanNumer);
        //commonDBEntity.Event_Content = conTent;

        if (iResult == 1)
        {
            //commonDBEntity.Event_Result = "库存保存成功!"; ;
            //MessageContent.InnerHtml = string.Format(GetLocalResourceObject("SaveSuccess").ToString(), HotelID);
        }
        else
        {
            //commonDBEntity.Event_Result = GetLocalResourceObject("SaveError").ToString();
            //MessageContent.InnerHtml = GetLocalResourceObject("SaveError").ToString();
        }
        //_commonEntity.CommonDBEntity.Add(commonDBEntity);
        //CommonBP.InsertEventHistory(_commonEntity);
        return "库存保存成功!";
    }
        public static CruiseInfoEntity SaveCruisePlanList(CruiseInfoEntity cruiseInfoEntity)
        {
            //cruiseInfoEntity.LogMessages.MsgType = MessageType.INFO;
            //cruiseInfoEntity.LogMessages.Content = _nameSpaceClass + "SaveCruiseInfo";
            //LoggerHelper.LogWriter(cruiseInfoEntity.LogMessages);

            try
            {
                return CruiseInfoDA.SaveCruisePlanList(cruiseInfoEntity);
            }
            catch (Exception ex)
            {
                //cruiseInfoEntity.LogMessages.MsgType = MessageType.ERROR;
                //cruiseInfoEntity.LogMessages.Content = _nameSpaceClass + "SaveCruiseInfo  Error: " + ex.Message;
                //LoggerHelper.LogWriter(cruiseInfoEntity.LogMessages);
                throw ex;
            }
        }
        public static CruiseInfoEntity SaveCruisePlanList(CruiseInfoEntity cruiseInfoEntity)
        {
            CruiseInfoDBEntity dbParm = (cruiseInfoEntity.CruiseInfoDBEntity.Count > 0) ? cruiseInfoEntity.CruiseInfoDBEntity[0] : new CruiseInfoDBEntity();

            if ("0".Equals(dbParm.Action))
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("CShipPlanInfo");

                cmd.SetParameterValue("@BoatID", dbParm.BoatID);
                cmd.SetParameterValue("@PlanDT", dbParm.CreateStart);
                cmd.SetParameterValue("@PlanNum", dbParm.PlanNumer.TrimEnd(','));
                cmd.SetParameterValue("@CUser", cruiseInfoEntity.LogMessages.Username);
                cmd.ExecuteNonQuery();
                cruiseInfoEntity.CruiseInfoDBEntity[0].PlanID = cmd.GetParameterValue("@PlanID").ToString();

                string[] strRooms = dbParm.PlanNumer.TrimEnd(',').Split(',');
                for (int i =0;i < strRooms.Count(); i++)
                {
                    CommonEntity _commonEntity = new CommonEntity();
                    _commonEntity.LogMessages = cruiseInfoEntity.LogMessages;
                    _commonEntity.CommonDBEntity = new List<CommonDBEntity>();
                    CommonDBEntity commonDBEntity = new CommonDBEntity();

                    commonDBEntity.Event_Type = "游轮库存-保存";
                    commonDBEntity.Event_ID = cruiseInfoEntity.CruiseInfoDBEntity[0].PlanID + "-" + i.ToString();
                    string conTent = "库存保存 - 初始化库存:{0}";

                    conTent = string.Format(conTent, strRooms[i].ToString());
                    commonDBEntity.Event_Content = conTent;
                    _commonEntity.CommonDBEntity.Add(commonDBEntity);
                    CommonDA.InsertEventHistory(_commonEntity);
                }
            }
            else
            {
                //DataCommand cmd = DataCommandManager.GetDataCommand("UCruisePlanInfo");

                //cmd.SetParameterValue("@PlanID", dbParm.PlanID);
                //cmd.SetParameterValue("@PlanNumer", dbParm.PlanNumer);
                //cmd.SetParameterValue("@UUser", cruiseInfoEntity.LogMessages.Username);
                //cmd.ExecuteNonQuery();
            }
            cruiseInfoEntity.Result = 1;
            return cruiseInfoEntity;
        }
        public static CruiseInfoEntity SaveCruisePlanInfo(CruiseInfoEntity cruiseInfoEntity)
        {
            //CruiseInfoDBEntity dbParm = (cruiseInfoEntity.CruiseInfoDBEntity.Count > 0) ? cruiseInfoEntity.CruiseInfoDBEntity[0] : new CruiseInfoDBEntity();

            //if (String.IsNullOrEmpty(dbParm.PlanID))
            //{
            //    DataCommand cmd = DataCommandManager.GetDataCommand("CCruisePlanInfo");
            //    cmd.SetParameterValue("@RouteID", dbParm.CruiseID);
            //    cmd.SetParameterValue("@PlanDTime", dbParm.PlanDTime);
            //    cmd.SetParameterValue("@PlanNumer", dbParm.PlanNumer);
            //    cmd.SetParameterValue("@CUser", cruiseInfoEntity.LogMessages.Username);
            //    cmd.ExecuteNonQuery();
            //    cruiseInfoEntity.CruiseInfoDBEntity[0].PlanID = cmd.GetParameterValue("@PlanID").ToString();
            //}
            //else
            //{
            //    DataCommand cmd = DataCommandManager.GetDataCommand("UCruisePlanInfo");

            //    cmd.SetParameterValue("@PlanID", dbParm.PlanID);
            //    cmd.SetParameterValue("@PlanNumer", dbParm.PlanNumer);
            //    cmd.SetParameterValue("@UUser", cruiseInfoEntity.LogMessages.Username);
            //    cmd.ExecuteNonQuery();
            //}
            //cruiseInfoEntity.Result = 1;
            //return cruiseInfoEntity;

            CruiseInfoDBEntity dbParm = (cruiseInfoEntity.CruiseInfoDBEntity.Count > 0) ? cruiseInfoEntity.CruiseInfoDBEntity[0] : new CruiseInfoDBEntity();

            DataCommand icmd = DataCommandManager.GetDataCommand("GetShipPlanInfo");
            icmd.SetParameterValue("@ShipPlanID", dbParm.PlanID.Split('-')[0].ToString());
            DataSet dsinfo = icmd.ExecuteDataSet();

            if (dsinfo.Tables[0].Rows.Count == 0)
            {
                cruiseInfoEntity.Result = 0;
                return cruiseInfoEntity;
            }

            string strNum = dsinfo.Tables[0].Rows[0]["PlanNum"].ToString();

            string[] numlist = strNum.Split(',');
            int i = int.Parse(dbParm.PlanID.Split('-')[1].ToString());
            numlist[i] = dbParm.PlanNumer;
            strNum = "";
            for (int j = 0; j < numlist.Count(); j++ )
            {
                strNum = strNum + numlist[j].ToString() + ",";
            }
            strNum = strNum.TrimEnd(',');

            DataCommand cmd = DataCommandManager.GetDataCommand("UShipPlanInfo");
            cmd.SetParameterValue("@ShipPlanID", dbParm.PlanID.Split('-')[0].ToString());
            cmd.SetParameterValue("@PlanNum", strNum);
            cmd.SetParameterValue("@UUser", cruiseInfoEntity.LogMessages.Username);
            cmd.ExecuteNonQuery();

            cruiseInfoEntity.Result = 1;
            return cruiseInfoEntity;
        }
        public static CruiseInfoEntity SaveCruiseInfo(CruiseInfoEntity cruiseInfoEntity)
        {
            CruiseInfoDBEntity dbParm = (cruiseInfoEntity.CruiseInfoDBEntity.Count > 0) ? cruiseInfoEntity.CruiseInfoDBEntity[0] : new CruiseInfoDBEntity();

            if (String.IsNullOrEmpty(dbParm.CruiseID))
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("CCruiseDataInfo");
                cmd.SetParameterValue("@ShipNM", dbParm.ShipNM);
                cmd.SetParameterValue("@Destination", dbParm.Destination);
                cmd.SetParameterValue("@Days", dbParm.Days);
                cmd.SetParameterValue("@Port", dbParm.Port);
                cmd.SetParameterValue("@CUser", cruiseInfoEntity.LogMessages.Username);
                cmd.ExecuteNonQuery();
            }
            else
            {
                DataCommand cmd = DataCommandManager.GetDataCommand("UCruiseDataInfo");
                string CruiseID = dbParm.CruiseID.Substring((dbParm.CruiseID.IndexOf('[') + 1), (dbParm.CruiseID.IndexOf(']') - 1));

                cmd.SetParameterValue("@CruiseID", CruiseID);
                cmd.SetParameterValue("@ShipNM", dbParm.ShipNM);
                cmd.SetParameterValue("@Destination", dbParm.Destination);
                cmd.SetParameterValue("@Days", dbParm.Days);
                cmd.SetParameterValue("@Port", dbParm.Port);
                cmd.SetParameterValue("@UUser", cruiseInfoEntity.LogMessages.Username);
                cmd.ExecuteNonQuery();
            }
            cruiseInfoEntity.Result = 1;
            return cruiseInfoEntity;
        }
    public static string SaveCruisePlan(string PlanID, string PlanDTime, string RouteID, string PlanNumer, string OPlanNumer)
    {
        CruiseInfoEntity _cruiseinfoEntity = new CruiseInfoEntity();
        CommonEntity _commonEntity = new CommonEntity();
        _cruiseinfoEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _commonEntity.LogMessages = new HotelVp.Common.Logger.LogMessage();
        _cruiseinfoEntity.LogMessages.Userid = UserSession.Current.UserAccount;
        _cruiseinfoEntity.LogMessages.Username = UserSession.Current.UserDspName;
        _cruiseinfoEntity.LogMessages.IpAddress = UserSession.Current.UserIP;

        _cruiseinfoEntity.CruiseInfoDBEntity = new List<CruiseInfoDBEntity>();
        CruiseInfoDBEntity cruiseInfoDBEntity = new CruiseInfoDBEntity();

        cruiseInfoDBEntity.PlanID = PlanID;
        cruiseInfoDBEntity.PlanDTime = PlanDTime;
        cruiseInfoDBEntity.CruiseID = RouteID;
        cruiseInfoDBEntity.PlanNumer = PlanNumer;
        cruiseInfoDBEntity.OPlanNumer = OPlanNumer;

        _cruiseinfoEntity.CruiseInfoDBEntity.Add(cruiseInfoDBEntity);
        _cruiseinfoEntity = CruiseInfoBP.SaveCruisePlanInfo(_cruiseinfoEntity);
        int iResult = _cruiseinfoEntity.Result;
        _commonEntity.LogMessages = _cruiseinfoEntity.LogMessages;
        _commonEntity.CommonDBEntity = new List<CommonDBEntity>();
        CommonDBEntity commonDBEntity = new CommonDBEntity();

        commonDBEntity.Event_Type = "游轮库存-保存";
        commonDBEntity.Event_ID = RouteID + "-" + cruiseInfoDBEntity.PlanID;
        string conTent = "库存保存 - 原库存:{0}  修改后库存:{1}";

        conTent = string.Format(conTent, OPlanNumer, PlanNumer);
        commonDBEntity.Event_Content = conTent;

        if (iResult == 1)
        {
            commonDBEntity.Event_Result = "库存保存成功!"; ;
            //MessageContent.InnerHtml = string.Format(GetLocalResourceObject("SaveSuccess").ToString(), HotelID);
        }
        else
        {
            //commonDBEntity.Event_Result = GetLocalResourceObject("SaveError").ToString();
            //MessageContent.InnerHtml = GetLocalResourceObject("SaveError").ToString();
        }
        _commonEntity.CommonDBEntity.Add(commonDBEntity);
        CommonBP.InsertEventHistory(_commonEntity);
        return "库存保存成功!";
    }