Exemplo n.º 1
0
        public int AddPlan(MDTrain model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TAB_Plan_Train(");
            strSql.Append("strTrainPlanGUID,strTrainTypeName,strTrainNumber,strTrainNo,dtStartTime,dtRealStartTime,strTrainJiaoluGUID,strStartStation,strEndStation,nTrainmanTypeID,nPlanType,nDragType,nKehuoID,nRemarkType,strRemark,nPlanState,dtCreateTime,strCreateSiteGUID,strCreateUserGUID,dtFirstStartTime,dtChuQinTime,nNeedRest,dtArriveTime,dtCallTime,strBak1,strMainPlanGUID,strPlaceID)");
            strSql.Append(" values (");
            strSql.Append("@strTrainPlanGUID,@strTrainTypeName,@strTrainNumber,@strTrainNo,@dtStartTime,@dtRealStartTime,@strTrainJiaoluGUID,@strStartStation,@strEndStation,@nTrainmanTypeID,@nPlanType,@nDragType,@nKehuoID,@nRemarkType,@strRemark,@nPlanState,@dtCreateTime,@strCreateSiteGUID,@strCreateUserGUID,@dtFirstStartTime,@dtChuQinTime,@nNeedRest,@dtArriveTime,@dtCallTime,@strBak1,@strMainPlanGUID,@strPlaceID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@strTrainPlanGUID",   SqlDbType.VarChar,   50),
                new SqlParameter("@strTrainTypeName",   SqlDbType.VarChar,   50),
                new SqlParameter("@strTrainNumber",     SqlDbType.VarChar,   50),
                new SqlParameter("@strTrainNo",         SqlDbType.VarChar,   50),
                new SqlParameter("@dtStartTime",        SqlDbType.DateTime),
                new SqlParameter("@dtRealStartTime",    SqlDbType.DateTime),
                new SqlParameter("@strTrainJiaoluGUID", SqlDbType.VarChar,   50),
                new SqlParameter("@strStartStation",    SqlDbType.VarChar,   50),
                new SqlParameter("@strEndStation",      SqlDbType.VarChar,   50),
                new SqlParameter("@nTrainmanTypeID",    SqlDbType.Int,        4),
                new SqlParameter("@nPlanType",          SqlDbType.Int,        4),
                new SqlParameter("@nDragType",          SqlDbType.Int,        4),
                new SqlParameter("@nKehuoID",           SqlDbType.Int,        4),
                new SqlParameter("@nRemarkType",        SqlDbType.Int,        4),
                new SqlParameter("@strRemark",          SqlDbType.VarChar,   50),
                new SqlParameter("@nPlanState",         SqlDbType.Int,        4),
                new SqlParameter("@dtCreateTime",       SqlDbType.DateTime),
                new SqlParameter("@strCreateSiteGUID",  SqlDbType.VarChar,   50),
                new SqlParameter("@strCreateUserGUID",  SqlDbType.VarChar,   50),
                new SqlParameter("@dtFirstStartTime",   SqlDbType.DateTime),
                new SqlParameter("@dtChuQinTime",       SqlDbType.DateTime),
                new SqlParameter("@nNeedRest",          SqlDbType.Int,        4),
                new SqlParameter("@dtArriveTime",       SqlDbType.DateTime),
                new SqlParameter("@dtCallTime",         SqlDbType.DateTime),
                new SqlParameter("@strBak1",            SqlDbType.VarChar,   50),
                new SqlParameter("@strMainPlanGUID",    SqlDbType.VarChar,   50),
                new SqlParameter("@strPlaceID",         SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.strTrainPlanGUID;
            parameters[1].Value  = model.strTrainTypeName;
            parameters[2].Value  = model.strTrainNumber;
            parameters[3].Value  = model.strTrainNo;
            parameters[4].Value  = model.dtStartTime;
            parameters[5].Value  = model.dtRealStartTime;
            parameters[6].Value  = model.strTrainJiaoluGUID;
            parameters[7].Value  = model.strStartStation;
            parameters[8].Value  = model.strEndStation;
            parameters[9].Value  = model.nTrainmanTypeID;
            parameters[10].Value = model.nPlanType;
            parameters[11].Value = model.nDragType;
            parameters[12].Value = model.nKehuoID;
            parameters[13].Value = model.nRemarkType;
            parameters[14].Value = model.strRemark;
            parameters[15].Value = model.nPlanState;
            parameters[16].Value = model.dtCreateTime;
            parameters[17].Value = model.strCreateSiteGUID;
            parameters[18].Value = model.strCreateUserGUID;
            parameters[19].Value = model.dtFirstStartTime;
            parameters[20].Value = model.dtChuQinTime;
            parameters[21].Value = model.nNeedRest;
            parameters[22].Value = model.dtArriveTime;
            parameters[23].Value = model.dtCallTime;
            parameters[24].Value = model.strBak1;
            parameters[25].Value = model.strMainPlanGUID;
            parameters[26].Value = model.strPlaceID;
            object obj = SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 2
0
        public bool ProduceJDPlan(string SectionID, string SiteName, string SiteNumber, string TrainID, string JiaoluGUID, string SiteGUID, string UserGUID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select *  ");
            strSql.Append(" FROM TAB_TMIS_Train where train_id='" + TrainID + "' ");
            DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql.ToString()).Tables[0];

            if (dt.Rows.Count <= 0)
            {
                throw new Exception("未在TAB_TMIS_Train 表中找到train_id为" + TrainID + "的数据");
            }
            else
            {
                MDTrain model = new MDTrain();
                model.strTrainNo = ObjectConvertClass.static_ext_string(dt.Rows[0]["train_code"]);

                //通过出勤规则,计划开车时间计算出计划出勤时间
                int      minutes     = GetPlanTimes(1, "2200004");
                DateTime dtStartTime = ObjectConvertClass.static_ext_Date(dt.Rows[0]["time_deptart"]).AddMinutes(-minutes);
                model.dtStartTime = dtStartTime;

                model.strStartStation    = getStationGUIDByName(ObjectConvertClass.static_ext_string(dt.Rows[0]["station_deptart"]));
                model.strEndStation      = getStationGUIDByName(ObjectConvertClass.static_ext_string(dt.Rows[0]["station_arrived"]));
                model.strTrainPlanGUID   = Guid.NewGuid().ToString();
                model.strTrainTypeName   = "";
                model.strTrainNumber     = "";
                model.dtRealStartTime    = Convert.ToDateTime("2000-01-01 00:00:00");
                model.strTrainJiaoluGUID = JiaoluGUID;
                model.nTrainmanTypeID    = 1;
                model.nPlanType          = 1;
                model.nDragType          = 2;
                TF.RunSafty.Utility.TGlobalDM d = new Utility.TGlobalDM();
                string remark = "";
                model.nKehuoID = Convert.ToInt32(d.getKeHuoByTrainNo(model.strTrainNo, ref remark));
                TF.CommonUtility.LogClass.log("获取客货类型----车次:" + model.strTrainNo + "客货类型:" + model.nKehuoID + "备注:" + remark);

                model.nRemarkType       = 1;
                model.strRemark         = "";
                model.nPlanState        = 1;
                model.dtCreateTime      = DateTime.Now;
                model.strCreateSiteGUID = SiteGUID;
                model.strCreateUserGUID = UserGUID;
                model.dtFirstStartTime  = Convert.ToDateTime("2000-01-01 00:00:00");
                model.dtChuQinTime      = ObjectConvertClass.static_ext_Date(dt.Rows[0]["time_deptart"]);
                model.nNeedRest         = 0;
                model.dtArriveTime      = Convert.ToDateTime("2000-01-01 00:00:00");
                model.dtCallTime        = Convert.ToDateTime("2000-01-01 00:00:00");
                model.strBak1           = "";
                model.strMainPlanGUID   = "";
                model.strPlaceID        = getPlaceIDByTJLGUID(JiaoluGUID);

                if (this.AddPlan(model) >= 1)
                {
                    string         sql   = "update TAB_TMIS_Train set strTrainPlanGUID = @strTrainPlanGUID where train_id='" + TrainID + "'";
                    SqlParameter[] param =
                    {
                        new SqlParameter("strTrainPlanGUID", model.strTrainPlanGUID)
                    };
                    SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, sql, param);
                    return(true);
                }
            }
            return(false);
        }