Exemplo n.º 1
0
        public void UpdateTrainJiaoLu(TmOrg input, DBTrainman.Tm tm)
        {
            if (string.IsNullOrEmpty(input.TrainmanNumber))
            {
                throw new Exception("传入人员工号为空,无法修改");
            }
            DBTrainman db = new DBTrainman();

            //判断是否在牌  如果在牌 则需要移除
            if (!db.CheckIsCanUpdata(tm.strTrainmanGUID))
            {
                throw new Exception("请将该人员移除名牌后,再进行修改操作!");
            }
            //执行修改操作
            if (!db.UpdateTrainJiaolu(tm.strTrainmanGUID, input.TrainJiaoluGUID))
            {
                throw new Exception("未找到待修改的人员!");
            }
            //添加名牌变动日志
            db.addLog4UpdateTrainmanJiaolu(tm, input.TrainJiaoluGUID, input.DutyUserGUID, input.DutyUserNumber, input.DutyUserName);
        }
Exemplo n.º 2
0
        public InterfaceRet UpdateTMOrg(string data)
        {
            InterfaceRet _ret = new InterfaceRet();

            _ret.Clear();
            DBTrainman db    = new DBTrainman();
            TmOrg      input = Newtonsoft.Json.JsonConvert.DeserializeObject <TmOrg>(data);

            try
            {
                DBTrainman.Tm tm = db.getTm(input.TrainmanNumber);
                if (tm == null)
                {
                    throw new Exception("找不到该司机,请从新输入工号");
                }

                //判断所传机务段是否是空,如果是空直接停止修改
                //if (!string.IsNullOrEmpty(input.AreaGUID))
                //{
                //if (tm.strJiWuDuanGUID != input.AreaGUID) 暂时先不检测
                UpdateArea(input, tm);
                // }

                //判断所传车间是否是空
                if (!string.IsNullOrEmpty(input.WorkShopGUID))
                {
                    if (tm.strWorkShopGUID != input.WorkShopGUID)
                    {
                        UpdateWorkShop(input, tm);

                        ////判断车间是否位于机务段下
                        //if (db.checkWorkShopInArea(input.AreaGUID, input.WorkShopGUID))

                        //else
                        //    throw new Exception("所选车间不属于所选机务段内!");
                    }
                }
                else
                {
                    UpdateWorkShop(input, tm);
                }

                //判断所传区段是否是空,如果是空直接停止修改
                if (!string.IsNullOrEmpty(input.TrainJiaoluGUID))
                {
                    if (tm.strTrainJiaoluGUID != input.TrainJiaoluGUID)
                    {
                        //判断车间是否位于机务段下
                        if (db.checkJiaoluInWorkShop(input.WorkShopGUID, input.TrainJiaoluGUID))
                        {
                            UpdateTrainJiaoLu(input, tm);
                        }
                        else
                        {
                            throw new Exception("所选区段不在所选车间内!");
                        }
                    }
                }
                else
                {
                    UpdateTrainJiaoLu(input, tm);
                }
                return(_ret);
            }
            catch (Exception ex)
            {
                _ret.resultStr = ex.Message;
                _ret.result    = 1;
            }
            return(_ret);
        }