Exemple #1
0
        public bool UpdateSelfRepairPlan(SelfRepairPlan selfRepairPlan, int planId)
        {
            bool result = false;

            using (var client = DbConfig.GetInstance())
            {
                client.BeginTran();
                client.CommandTimeOut = 30000;
                //更新gzsq中的当前状态
                client.Update <RepairApplication>(
                    new
                {
                    Status = CurrentStatus.自修方案待审.ToString()
                }, it => it.SelfRepairPlanID == planId);
                //更新SelfRepairPlan
                client.DisableUpdateColumns = new string[] { "ID" };//id不更新
                client.Update <SelfRepairPlan>(selfRepairPlan, it => it.Id == planId);
                try
                {
                    client.CommitTran();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
Exemple #2
0
        public bool InsertNewSelfRepairPlan(SelfRepairPlan selfRepairPlan, int appId, out int selfPlanId)
        {
            bool result = false;

            using (var client = DbConfig.GetInstance())
            {
                try
                {
                    client.BeginTran();
                    client.CommandTimeOut = 30000;
                    //插入新的自修方案 SelfRepairPlan
                    client.Insert <SelfRepairPlan>(selfRepairPlan);
                    var planId = client.Queryable <SelfRepairPlan>().Max(it => it.Id).ObjToInt();
                    selfPlanId = planId;
                    //更改申请记录的状态 RepairApplication
                    client.Update <RepairApplication>(
                        new
                    {
                        Status           = CurrentStatus.自修方案待审.ToString(),
                        SelfRepairPlanID = planId,
                        MethodCategory   = MethodCategory.自修.ToString()
                    }, it => it.Id == appId);
                    client.CommitTran();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
Exemple #3
0
 public SelfRepairPlan SelfRepairPlanByAppId(int selfRepairPlanId)
 {
     using (var client = DbConfig.GetInstance())
     {
         SelfRepairPlan selfRepairPlan = client.Queryable <SelfRepairPlan>().Single(it => it.Id == selfRepairPlanId);
         return(selfRepairPlan);
     }
 }
Exemple #4
0
        public ActionResult GetSelfRepairPlanByAppId(int selfRepairPlanId)
        {
            SelfRepairPlan    resultM   = repairDAL.SelfRepairPlanByAppId(selfRepairPlanId);
            SelfRepairPlanDto resultDto = Mapper.Map <SelfRepairPlan, SelfRepairPlanDto>(resultM);

            if (resultDto != null)
            {
                return(Content(new { msg = "找到方案", status = "success", data = resultDto }.ToJsonString()));
            }
            else
            {
                return(Content(new { msg = "未找到方案", status = "failed" }.ToJsonString()));
            }
        }
Exemple #5
0
        public ActionResult ShowAllInOne(int appId, string type)
        {
            SummarizeDto SummarizeVM = new SummarizeDto();

            if (String.Equals(type, "自修"))
            {
                Dispatch          dispatchSheet  = new Dispatch();
                SelfRepairPlan    selfRepairPlan = new SelfRepairPlan();
                string            dispatherName  = string.Empty;
                string            engineerName   = string.Empty;
                RepairApplication application    = repairDAL.AllInfo(appId, ref dispatchSheet, ref selfRepairPlan, ref dispatherName, ref engineerName);
                SummarizeVM.Instruction    = dispatchSheet.Instruction;
                SummarizeVM.DispatchTime   = dispatchSheet.CreatTime;
                SummarizeVM.Dispatcher     = dispatherName;
                SummarizeVM.Engineer       = engineerName;
                SummarizeVM.ApplicationDto = Mapper.Map <RepairApplication, ApplicationDto>(application);
                SummarizeVM.SelfRepairDto  = Mapper.Map <SelfRepairPlan, SelfRepairPlanDto>(selfRepairPlan);
            }
            return(View(SummarizeVM));
        }
Exemple #6
0
        public bool Finish(RepairApplication application, SelfRepairPlan selfRepairPlan)
        {
            bool result = false;

            using (var client = DbConfig.GetInstance())
            {
                client.BeginTran();
                client.CommandTimeOut = 30000;
                client.Update <RepairApplication>(
                    new
                {
                    FirstLocation      = application.FirstLocation,
                    SecondLocation     = application.SecondLocation,
                    ThirdLocation      = application.ThirdLocation,
                    FailureAppearance  = application.FailureAppearance,
                    FailureDescription = application.FailureDescription,
                    Status             = CurrentStatus.已总结.ToString(),
                    SummarizeTime      = DateTime.Now
                }, it => it.Id == application.Id);
                client.Update <SelfRepairPlan>(
                    new
                {
                    StartTime       = selfRepairPlan.StartTime,
                    TimeCost        = selfRepairPlan.TimeCost,
                    IsUseSpareParts = selfRepairPlan.IsUseSpareParts,
                    Step            = selfRepairPlan.Step,
                    Tool            = selfRepairPlan.Tool,
                    SparePartsInfo  = selfRepairPlan.SparePartsInfo,
                }, it => it.Id == selfRepairPlan.Id);
                try
                {
                    client.CommitTran();
                    result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(result);
        }
Exemple #7
0
 public RepairApplication AllInfo(int appId, ref Dispatch dispatchSheet, ref SelfRepairPlan selfRepairPlan, ref string dispatherName, ref string engineerName)
 {
     using (var client = DbConfig.GetInstance())
     {
         var app        = client.Queryable <RepairApplication>().SingleOrDefault(it => it.Id == appId);
         var dispatch   = client.Queryable <Dispatch>().SingleOrDefault(it => it.Id == app.DispatchSheetID);
         var dispather  = client.Queryable <Users>().SingleOrDefault(it => it.Id == dispatch.Dispatcher);
         var engineer   = client.Queryable <Users>().SingleOrDefault(it => it.Id == dispatch.Engineer);
         var repairPlan = client.Queryable <SelfRepairPlan>().Single(it => it.Id == app.SelfRepairPlanID);
         selfRepairPlan = repairPlan;
         if (dispather != null)
         {
             dispatherName = dispather.Name;
         }
         if (engineer != null)
         {
             engineerName = engineer.Name;
         }
         dispatchSheet = dispatch;
         return(app);
     }
 }