Example #1
0
        /// <summary>
        /// 通过工号获取人员信息
        /// </summary>
        /// <param name="tmid"></param>
        /// <param name="trainman"></param>
        /// <returns></returns>
        public static Boolean GetTrainman(string tmid, Trainman trainman)
        {
            string sql = @"select top 1 TAB_Org_Trainman.strTrainmanGUID,TAB_Org_Trainman.strTrainmanNumber,
            TAB_Org_Trainman.strTrainmanName,TAB_Org_Trainman.strWorkShopGUID,TAB_Org_WorkShop.strWorkShopName 
            from TAB_Org_Trainman left join TAB_Org_WorkShop on TAB_Org_Trainman.strWorkShopGUID = TAB_Org_WorkShop.strWorkShopGUID  
            where TAB_Org_Trainman.strTrainmanNumber = '" + tmid + "'";

            DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, sql).Tables[0];

            if (dt.Rows.Count > 0)
            {
                trainman.tmGUID       = dt.Rows[0]["strTrainmanGUID"].ToString();
                trainman.tmid         = dt.Rows[0]["strTrainmanNumber"].ToString();
                trainman.tmname       = dt.Rows[0]["strTrainmanName"].ToString();
                trainman.workShopID   = dt.Rows[0]["strWorkShopGUID"].ToString();
                trainman.workShopName = dt.Rows[0]["strWorkShopName"].ToString();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        private void SubmitInOutRoomRecord(string planGUID, SubmitInOutRoom Rec, int trainmanIndex, int EventID, Trainman trainman)
        {
            if (trainmanIndex < 1 || trainmanIndex > 4)
            {
                return;
            }

            //获取事件地点
            string siteName;
            string sql         = @"select top 1 strStationName from TAB_Base_Station where strStationNumber = '" + Rec.stmis + "'";
            object objSiteName = SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, sql);

            if (objSiteName == null)
            {
                siteName = "";
            }
            else
            {
                siteName = objSiteName.ToString();
            }


            //如果没有记录则插入新记录
            sql = @"if not Exists(select top 1 * from TAB_Plan_RunEvent_SiteInOut where strTrainPlanGUID = @planid)
	        insert into TAB_Plan_RunEvent_SiteInOut(strTrainPlanGUID,strSiteTMIS,strSiteName)
		    values(@planid,@tmis,@siteName)"        ;

            SqlParameter[] sqlparams =
            {
                new SqlParameter("@planid",   planGUID),
                new SqlParameter("@tmis",     Rec.stmis),
                new SqlParameter("@siteName", siteName)
            };
            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, sql, sqlparams);

            //更新人员信息
            switch (EventID)
            {
            case eteInRoom:
                sql = @"update TAB_Plan_RunEvent_SiteInOut set strTrainmanGUID{0} = @tmguid,
                    strTrainmanName{0} = @tmname,
                    strTrainmanNumber{0} = @tmid,
                    strInBrief{0} = @brief,
                    dtInRoomTime{0} = @etime,
                    strInRoomSourceID{0} = @worid where strTrainPlanGUID = @planid";
                break;;

            case eteOutRoom:
                sql = @"update TAB_Plan_RunEvent_SiteInOut set strTrainmanGUID{0} = @tmguid,
                    strTrainmanName{0} = @tmname,
                    strTrainmanNumber{0} = @tmid,
                    strOutBrief{0} = @brief,
                    dtOutRoomTime{0} = @etime,
                    strOutRoomSourceID{0} = @worid where strTrainPlanGUID = @planid";
                break;;

            default:
                throw new Exception("更新出入寓记录失败(错误的事件类型)");
            }


            sql = string.Format(sql, trainmanIndex);

            SqlParameter[] uparams =
            {
                new SqlParameter("@planid", planGUID),
                new SqlParameter("@tmguid", trainman.tmGUID),
                new SqlParameter("@tmname", trainman.tmname),
                new SqlParameter("@tmid",   trainman.tmid),
                new SqlParameter("@brief",  Rec.strResult.ResultToString()),
                new SqlParameter("@etime",  Rec.etime),
                new SqlParameter("@worid",  Rec.workid)
            };

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, sql, uparams);
        }
Example #3
0
        public void SubmitInOutRoomEvent(SubmitInOutRoom Rec, int EventID)
        {
            int    tmindex;
            int    ErrCode   = 0;
            string ErrInfo   = "";
            string eventGUID = Guid.NewGuid().ToString();

            TrainmanPlan plan     = new TrainmanPlan();
            Trainman     trainman = new Trainman();



            if (DBPlan.GetTrainPlanBriefByRange(Rec.tmid, Rec.etime, plan, out tmindex))
            {
                if (DBDictionary.GetTrainman(Rec.tmid, trainman))
                {
                    SubmitTrainmanEvent(Rec, EventID, plan, tmindex, ref ErrInfo, ref ErrCode, ref eventGUID);

                    SubmitInOutRoomRecord(plan.trainPlan.planID, Rec, tmindex, EventID, trainman);
                }
                else
                {
                    ErrCode = 1;
                    ErrInfo = string.Format("没有找到工号为[{0}]的乘务员!", Rec.tmid);
                }
            }
            else
            {
                ErrCode = 1;
                ErrInfo = "没有指定乘务员的计划或机组信息";
            }


            if (ErrCode == 0)
            {
                ErrInfo = "添加成功";
            }



            EventParam eventParam = new EventParam();

            eventParam.eventGUID    = eventGUID;
            eventParam.eventID      = EventID;
            eventParam.ntmis        = Convert.ToInt32(Rec.stmis);
            eventParam.submitRemark = ErrInfo;
            eventParam.submitResult = ErrCode;
            eventParam.strResult    = Rec.strResult.ResultToString();
            eventParam.nresult      = Rec.nresult;
            eventParam.tmid         = Rec.tmid;
            eventParam.etime        = Rec.etime;

            eventParam.strTrainType    = Rec.strTrainType;
            eventParam.strTrainNum     = Rec.strTrainNum;
            eventParam.strCheCi        = Rec.strCheCi;
            eventParam.nLoginType      = Rec.nLoginType;
            eventParam.PhotoID         = Rec.PhotoID;
            eventParam.IsLackOfRest    = Rec.IsLackOfRest;
            eventParam.LackReason      = Rec.LackReason;
            eventParam.ShenHeNumber    = Rec.ShenHeNumber;
            eventParam.ShenHeName      = Rec.ShenHeName;
            eventParam.ShenHeLoginType = Rec.ShenHeLoginType;
            eventParam.ShenHePhotoID   = Rec.ShenHePhotoID;
            eventParam.InRoomTime      = Rec.strResult.InRoomTime;

            //向TAB_Plan_RunEvent_Site中插入数据
            SubmitEventLog(eventParam);
        }
Example #4
0
        public static void InsertDrinkRecord(SubmitDrinkRec Rec, SqlTransaction trans)
        {
            string placeName = DBDictionary.GetDutyPlaceID(Rec.stmis);

            Trainman trainman = new Trainman();

            DBDictionary.GetTrainman(Rec.tmid, trainman);


            #region 添加测酒记录
            MDDrink MDDr = new MDDrink();
            TF.Runsafty.Plan.DB.DBDrink DBDr = new Runsafty.Plan.DB.DBDrink();
            //职位信息----- 开始----------
            DBDrinkLogic dbdl = new DBDrinkLogic();
            MDDrinkLogic mddl = new MDDrinkLogic();
            mddl = dbdl.GetDrinkCadreEntity(Rec.tmid);
            if (mddl != null)
            {
                MDDr.strDepartmentID   = mddl.strDepartmentID;
                MDDr.strDepartmentName = mddl.strDepartmentName;
                MDDr.nCadreTypeID      = mddl.nCadreTypeID;
                MDDr.strCadreTypeName  = mddl.strCadreTypeName;
            }
            //职位信息----- 结束----------

            //是否是本段
            MDDr.nLocalAreaTrainman = 0;
            MDDr.trainmanID         = trainman.tmGUID;
            MDDr.createTime         = DateTime.Now.ToString();
            MDDr.verifyID           = 0;
            MDDr.oPlaceId           = "";
            MDDr.strGuid            = Guid.NewGuid().ToString();
            MDDr.drinkResult        = Rec.nresult.ToString();
            MDDr.strAreaGUID        = "";
            MDDr.dutyUserID         = "";
            MDDr.strTrainmanName    = trainman.tmname;
            MDDr.strTrainmanNumber  = Rec.tmid;
            MDDr.strTrainNo         = "";
            MDDr.strTrainNumber     = "";
            MDDr.strTrainTypeName   = "";
            MDDr.strWorkShopGUID    = trainman.workShopID;
            MDDr.strWorkShopName    = trainman.workShopName;
            MDDr.strPlaceID         = Rec.stmis;
            MDDr.strPlaceName       = placeName;
            MDDr.strSiteGUID        = "";
            MDDr.strSiteName        = "";
            MDDr.dwAlcoholicity     = "";
            MDDr.strWorkID          = "";
            MDDr.nWorkTypeID        = Rec.workType;//工作类型为退勤
            MDDr.imagePath          = CreateImgPath(Rec);
            SqlTrans sqltrans = new SqlTrans();
            sqltrans.Begin();
            try
            {
                DBDr.SubmitDrink(MDDr, sqltrans.trans);
                sqltrans.Commit();
            }
            catch (Exception ex)
            {
                sqltrans.RollBack();
                throw ex;
            }
            #endregion
        }