/// <summary>
        /// 提交
        /// </summary>
        /// <param name="planid"></param>
        /// <param name="userid"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        public bool Submit(Guid planid, int userid, string username, string rolename, CurrentFlightPlanVM model)
        {
            //ActionWithTrans(() =>
            //{
            CurrentFlightPlan entity = new CurrentFlightPlan();

            entity.CurrentFlightPlanID = Guid.NewGuid();
            entity.FlightPlanID        = planid.ToString();
            entity.ActorID             = userid;
            entity.PlanState           = "";
            //entity.Pilot = model.Pilot;
            //entity.ContractWay = model.ContractWay;
            entity.AircraftNum     = model.AircraftNum;
            entity.ActualStartTime = model.ActualStartTime;
            entity.ActualEndTime   = model.ActualEndTime;
            entity.Creator         = userid;
            entity.CreatorName     = username;
            dal.Add(entity);

            var currPlanId = entity.CurrentFlightPlanID;

            wftbll.CreateWorkflowInstance((int)TWFTypeEnum.CurrentPlan, currPlanId, userid, username);
            instal.Submit(currPlanId, (int)TWFTypeEnum.CurrentPlan, userid, username, rolename, "", workPlan =>
            {
                dal.Update(new CurrentFlightPlan {
                    ActorName = workPlan.ActorName, PlanState = workPlan.PlanState, CurrentFlightPlanID = workPlan.PlanID
                }, "ActorID", "PlanState");
            });
            //});

            return(true);
        }
    private void Save()
    {
        AjaxResult result = new AjaxResult();

        result.IsSuccess = false;
        result.Msg       = "保存失败!";

        CurrentFlightPlan entity = null;
        var airlineworkText      = "";

        if (string.IsNullOrEmpty(Request.Form["id"]))//新增
        {
            entity = new CurrentFlightPlan();

            entity.GetEntitySearchPars <CurrentFlightPlan>(this.Context);
            //entity.SOBT = entity.SOBT.AddDays(1);
            //entity.SIBT = entity.SIBT.AddDays(1);
            entity.CurrentFlightPlanID = Guid.NewGuid();
            entity.PlanState           = "0";
            entity.CompanyCode3        = User.CompanyCode3 ?? "";
            entity.CompanyName         = User.CompanyName;
            entity.Creator             = User.ID;
            entity.CreatorName         = User.UserName;
            entity.ActorID             = User.ID;
            entity.CreateTime          = DateTime.Now;
            currPlanBll.AddCurrentPlanTempOther(Request.Form["AirlineText"], Request.Form["CWorkText"], Request.Form["PWorkText"], Request.Form["HWorkText"], entity.CurrentFlightPlanID.ToString(), Request.Form["id"], ref airlineworkText);

            entity.AirlineWorkText = airlineworkText;
            if (currPlanBll.Add(entity))
            {
                result.IsSuccess = true;
                result.Msg       = "增加成功!";
            }
        }
        else//编辑
        {
            entity = currPlanBll.GetCurrentFlightPlan(Guid.Parse(Request.Form["id"]));
            if (entity != null)
            {
                entity.GetEntitySearchPars <CurrentFlightPlan>(this.Context);

                currPlanBll.AddCurrentPlanTempOther(Request.Form["AirlineText"], Request.Form["CWorkText"], Request.Form["PWorkText"], Request.Form["HWorkText"], entity.FlightPlanID.ToString(), Request.Form["id"], ref airlineworkText);

                entity.AirlineWorkText = airlineworkText;
                if (currPlanBll.Update(entity))
                {
                    result.IsSuccess = true;
                    result.Msg       = "更新成功!";
                }
            }
        }

        Response.Clear();
        Response.Write(result.ToJsonString());
        Response.ContentType = "application/json";
        Response.End();
    }
 /// <summary>
 /// 更新某些字段
 /// </summary>
 /// <param name="model"></param>
 /// <param name="propertyNames"></param>
 /// <returns></returns>
 public bool Update(CurrentFlightPlan model, params string[] propertyNames)
 {
     return(dal.Update(model, propertyNames) > 0);
 }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(CurrentFlightPlan model)
 {
     return(dal.Update(model, false, "DeleteFlag") > 0);
 }
 public bool Add(CurrentFlightPlan model)
 {
     return(dal.Add(model) > 0);
 }
    private void AuditSubmit()
    {
        AjaxResult result = new AjaxResult();

        result.IsSuccess = false;
        result.Msg       = "提交失败!";
        var planid = Guid.Parse(Request.Form["id"]);
        var plan   = bll.Get(planid);

        if (plan != null)
        {
            var ControlDep = "";
            if (Request.Form["Auditresult"] == "0")
            {
                if (!string.IsNullOrEmpty(Request.Form["ControlDep"]))
                {
                    ControlDep = Request.Form["ControlDep"];
                }
                insdal.Submit(planid, (int)TWFTypeEnum.FlightPlan, User.ID, User.UserName, User.RoleName.First(), Request.Form["AuditComment"] ?? "", insdal.UpdateFlightPlan, ControlDep);
                var plan1 = bll.Get(planid);
                if (plan1 != null && plan1.PlanState == "end")
                {
                    #region 飞行计划审核完成后直接转到明天的当日动态,并提交
                    var entity = new CurrentFlightPlan();
                    //  entity.FillObject(plan);
                    entity.CurrentFlightPlanID = Guid.NewGuid();
                    entity.RepetPlanID         = plan.RepetPlanID;
                    entity.FlightPlanID        = plan.FlightPlanID.ToString();
                    entity.AircraftType        = plan.AircraftType;
                    entity.FlightType          = plan.FlightType;
                    // entity.AircraftNum =int.Parse(plan.AircraftNum);
                    entity.AirlineWorkText = plan.AirlineWorkText;
                    entity.AirportText     = plan.AirportText;
                    entity.ADEP            = plan.ADEP;
                    entity.ADES            = plan.ADES;
                    entity.SsrCode         = plan.SsrCode;
                    entity.CallSign        = plan.CallSign;
                    entity.Code            = plan.Code;
                    entity.PlanState       = "0";
                    entity.CompanyName     = plan.CompanyName;
                    entity.CompanyCode3    = plan.CompanyCode3;
                    entity.Creator         = plan.Creator.Value;
                    entity.CreatorName     = plan.CreatorName;
                    entity.ActorID         = plan.Creator.Value;
                    entity.Code            = plan.Code;
                    entity.CreateTime      = DateTime.Now.Date.AddDays(1);
                    if (currPlanBll.Add(entity))
                    {
                        wftbll.CreateWorkflowInstance((int)TWFTypeEnum.CurrentPlan, entity.CurrentFlightPlanID, entity.Creator, entity.CreatorName);
                        insdal.Submit(entity.CurrentFlightPlanID, (int)TWFTypeEnum.CurrentPlan, entity.Creator, entity.CreatorName, "", "", insdal.UpdateCurrentFlightPlan);
                    }
                    #endregion
                }
            }

            else
            {
                insdal.Terminate(planid, (int)TWFTypeEnum.FlightPlan, User.ID, User.UserName, User.RoleName.First(), Request.Form["AuditComment"] ?? "", insdal.UpdateFlightPlan);
            }
            result.IsSuccess = true;
            result.Msg       = "提交成功!";
        }
        Response.Clear();
        Response.Write(result.ToJsonString());
        Response.ContentType = "application/json";
        Response.End();
    }