public bool UpdateByParamModel(TF.RunSafty.Model.InterfaceModel.PlanRestModel paramModel, string IsOrNotIndexes) { TF.RunSafty.Model.TAB_Plan_Rest Plan_Rest = this.GetModel(paramModel.data.strguid); SetModelValue(paramModel, Plan_Rest); if (IsOrNotIndexes == "") { return(this.Update(Plan_Rest)); } else { return(this.UpdateAndFirst(Plan_Rest, Plan_Rest.strTrainJiaoLuGUID)); } }
/// <summary> /// 更新一条数据 /// </summary> public int UpdatePlan(TF.RunSafty.Model.TAB_Plan_Rest model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TAB_Plan_Sign set "); strSql.Append("dtArriveTime=@dtArriveTime,"); strSql.Append("dtCallTime=@dtCallTime,"); strSql.Append("strTrainNo=@strTrainNo,"); strSql.Append("dtChuQinTime=@dtChuQinTime,"); strSql.Append("strTrainJiaoLuGUID=@strTrainJiaoLuGUID,"); strSql.Append("nNeedRest=@nNeedRest,"); strSql.Append("dtStartTrainTime=@dtStartTrainTime"); strSql.Append(" where strGUID=@strGUID"); SqlParameter[] parameters = { new SqlParameter("@strGUID", SqlDbType.VarChar, 50), new SqlParameter("@dtArriveTime", SqlDbType.DateTime), new SqlParameter("@dtCallTime", SqlDbType.DateTime), new SqlParameter("@strTrainNo", SqlDbType.VarChar, 50), new SqlParameter("@dtChuQinTime", SqlDbType.DateTime), new SqlParameter("@strTrainJiaoLuGUID", SqlDbType.VarChar, 50), new SqlParameter("@nNeedRest", SqlDbType.Int, 4), new SqlParameter("@dtStartTrainTime", SqlDbType.DateTime) }; parameters[0].Value = model.strGUID; parameters[1].Value = model.dtArriveTime; parameters[2].Value = model.dtCallTime; parameters[3].Value = model.strTrainNo; parameters[4].Value = model.dtChuQinTime; parameters[5].Value = model.strTrainJiaoLuGUID; parameters[6].Value = model.nNeedRest; parameters[7].Value = model.dtStartTrainTime; int rows1 = (int)SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters); if (rows1 > 0) { return(1); } else { return(0); } }
public List <TF.RunSafty.Model.TAB_Plan_Rest> GetPlaceList(List <TF.RunSafty.Model.TAB_Plan_Rest> placeList) { if (placeList != null) { List <TF.RunSafty.Model.TAB_Plan_Rest> resultList = new List <TF.RunSafty.Model.TAB_Plan_Rest>(); foreach (TF.RunSafty.Model.TAB_Plan_Rest place in placeList) { TF.RunSafty.Model.TAB_Plan_Rest model = new TF.RunSafty.Model.TAB_Plan_Rest(); model.dtArriveTime = place.dtArriveTime; model.dtCallTime = place.dtCallTime; model.nID = place.nID; model.strGUID = place.strGUID; model.strTrainJiaoLuGUID = place.strTrainJiaoLuGUID; model.strTrainmanGUID1 = place.strTrainmanGUID1; model.strTrainmanGUID2 = place.strTrainmanGUID2; model.strTrainmanGUID3 = place.strTrainmanGUID3; model.strTrainmanGUID4 = place.strTrainmanGUID4; model.strTrainNoGUID = place.strTrainNoGUID; model.strWorkGrouGUID = place.strWorkGrouGUID; model.strTrainNo = place.strTrainNo; model.dtChuQinTime = place.dtChuQinTime; model.dtStartTrainTime = place.dtStartTrainTime; model.dtSignTime = place.dtSignTime; model.ePlanState = place.ePlanState; model.nNeedRest = place.nNeedRest; model.nFinished = place.nFinished; model.strTrainmanName1 = place.strTrainmanName1; model.strTrainmanName2 = place.strTrainmanName2; model.strTrainmanName3 = place.strTrainmanName3; model.strTrainmanName4 = place.strTrainmanName4; model.strTrainmanNumber1 = place.strTrainmanNumber1; model.strTrainmanNumber2 = place.strTrainmanNumber2; model.strTrainmanNumber3 = place.strTrainmanNumber3; model.strTrainmanNumber4 = place.strTrainmanNumber4; resultList.Add(model); } return(resultList); } return(null); }
/// <summary> /// 增加一条数据 /// </summary> public int AddPlan(TF.RunSafty.Model.TAB_Plan_Rest model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into TAB_Plan_Sign("); strSql.Append("strGUID,dtArriveTime,dtCallTime,dtChuQinTime,strTrainNo,strTrainJiaoLuGUID,nNeedRest,dtStartTrainTime)"); strSql.Append(" values ("); strSql.Append("@strGUID,@dtArriveTime,@dtCallTime,@dtChuQinTime,@strTrainNo,@strTrainJiaoLuGUID,@nNeedRest,@dtStartTrainTime)"); SqlParameter[] parameters = { new SqlParameter("@strGUID", SqlDbType.VarChar, 50), new SqlParameter("@dtArriveTime", SqlDbType.VarChar, 50), new SqlParameter("@dtCallTime", SqlDbType.VarChar, 50), new SqlParameter("@dtChuQinTime", SqlDbType.VarChar, 50), new SqlParameter("@strTrainNo", SqlDbType.VarChar, 50), new SqlParameter("@strTrainJiaoLuGUID", SqlDbType.VarChar, 50), new SqlParameter("@nNeedRest", SqlDbType.Int, 4), new SqlParameter("@dtStartTrainTime", SqlDbType.VarChar, 50) }; parameters[0].Value = model.strGUID; parameters[1].Value = model.dtArriveTime; parameters[2].Value = model.dtCallTime; parameters[3].Value = model.dtChuQinTime; parameters[4].Value = model.strTrainNo; parameters[5].Value = model.strTrainJiaoLuGUID; parameters[6].Value = model.nNeedRest; parameters[7].Value = model.dtStartTrainTime; int rows = (int)SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters); if (rows > 0) { return(1); } else { return(0); } }
/// <summary> /// 得到一个对象实体 /// </summary> public TF.RunSafty.Model.TAB_Plan_Rest GetModel(string strGUID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from TAB_Plan_Sign "); strSql.Append(" where strGUID=@strGUID "); SqlParameter[] parameters = { new SqlParameter("@strGUID", SqlDbType.VarChar, 50) }; parameters[0].Value = strGUID; TF.RunSafty.Model.TAB_Plan_Rest model = new TF.RunSafty.Model.TAB_Plan_Rest(); DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public TF.RunSafty.Model.TAB_Plan_Rest DataRowToModel2(DataRow row) { TF.RunSafty.Model.TAB_Plan_Rest model = new TF.RunSafty.Model.TAB_Plan_Rest(); if (row != null) { if (row["nID"] != null && row["nID"].ToString() != "") { model.nID = int.Parse(row["nID"].ToString()); } if (row["strGUID"] != null) { model.strGUID = row["strGUID"].ToString(); } if (row["strTrainJiaoLuGUID"] != null) { model.strTrainJiaoLuGUID = row["strTrainJiaoLuGUID"].ToString(); } if (row["dtArriveTime"] != null && row["dtArriveTime"].ToString() != "1900-01-01 00:00:00") { model.dtArriveTime = row["dtArriveTime"].ToString(); } else { model.dtArriveTime = ""; } if (row["dtCallTime"] != null && row["dtCallTime"].ToString() != "1900-01-01 00:00:00") { model.dtCallTime = row["dtCallTime"].ToString(); } else { model.dtCallTime = ""; } if (row["strTrainNo"] != null) { model.strTrainNo = row["strTrainNo"].ToString(); } if (row["dtChuQinTime"] != null && row["dtChuQinTime"].ToString() != "") { model.dtChuQinTime = row["dtChuQinTime"].ToString(); } else { model.dtChuQinTime = ""; } if (row["strTrainNoGUID"] != null) { model.strTrainNoGUID = row["strTrainNoGUID"].ToString(); } if (row["strWorkGrouGUID"] != null) { model.strWorkGrouGUID = row["strWorkGrouGUID"].ToString(); } if (row["strTrainmanGUID1"] != null) { model.strTrainmanGUID1 = row["strTrainmanGUID1"].ToString(); } if (row["strTrainmanGUID2"] != null) { model.strTrainmanGUID2 = row["strTrainmanGUID2"].ToString(); } if (row["strTrainmanGUID3"] != null) { model.strTrainmanGUID3 = row["strTrainmanGUID3"].ToString(); } if (row["strTrainmanGUID4"] != null) { model.strTrainmanGUID4 = row["strTrainmanGUID4"].ToString(); } if (row["nNeedRest"] != null && row["nNeedRest"].ToString() != "") { model.nNeedRest = int.Parse(row["nNeedRest"].ToString()); } if (row["nFinished"] != null && row["nFinished"].ToString() != "") { model.nFinished = int.Parse(row["nFinished"].ToString()); } if (row["ePlanState"] != null && row["ePlanState"].ToString() != "") { model.ePlanState = int.Parse(row["ePlanState"].ToString()); } if (row["dtSignTime"] != null && row["dtSignTime"].ToString() != "" && row["dtSignTime"].ToString() != "1900-01-01 00:00:00") { model.dtSignTime = row["dtSignTime"].ToString(); } else { model.dtSignTime = ""; } if (row["dtStartTrainTime"] != null && row["dtStartTrainTime"].ToString() != "") { model.dtStartTrainTime = row["dtStartTrainTime"].ToString(); } else { model.dtStartTrainTime = ""; } if (row["strTrainmanName1"] != null && row["strTrainmanName1"].ToString() != "") { model.strTrainmanName1 = row["strTrainmanName1"].ToString(); } else { model.strTrainmanName1 = ""; } if (row["strTrainmanName2"] != null && row["strTrainmanName2"].ToString() != "") { model.strTrainmanName2 = row["strTrainmanName2"].ToString(); } else { model.strTrainmanName2 = ""; } if (row["strTrainmanName3"] != null && row["strTrainmanName3"].ToString() != "") { model.strTrainmanName3 = row["strTrainmanName3"].ToString(); } else { model.strTrainmanName3 = ""; } if (row["strTrainmanName4"] != null && row["strTrainmanName4"].ToString() != "") { model.strTrainmanName4 = row["strTrainmanName4"].ToString(); } else { model.strTrainmanName4 = ""; } if (row["strTrainmanNumber4"] != null && row["strTrainmanNumber4"].ToString() != "") { model.strTrainmanNumber4 = row["strTrainmanNumber4"].ToString(); } else { model.strTrainmanNumber4 = ""; } if (row["strTrainmanNumber3"] != null && row["strTrainmanNumber3"].ToString() != "") { model.strTrainmanNumber3 = row["strTrainmanNumber3"].ToString(); } else { model.strTrainmanNumber3 = ""; } if (row["strTrainmanNumber2"] != null && row["strTrainmanNumber2"].ToString() != "") { model.strTrainmanNumber2 = row["strTrainmanNumber2"].ToString(); } else { model.strTrainmanNumber2 = ""; } if (row["strTrainmanNumber1"] != null && row["strTrainmanNumber1"].ToString() != "") { model.strTrainmanNumber1 = row["strTrainmanNumber1"].ToString(); } else { model.strTrainmanNumber1 = ""; } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(TF.RunSafty.Model.TAB_Plan_Rest model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TAB_Plan_Sign set "); strSql.Append("strTrainJiaoLuGUID=@strTrainJiaoLuGUID,"); strSql.Append("dtArriveTime=@dtArriveTime,"); strSql.Append("dtCallTime=@dtCallTime,"); strSql.Append("strTrainNo=@strTrainNo,"); strSql.Append("dtChuQinTime=@dtChuQinTime,"); strSql.Append("strTrainNoGUID=@strTrainNoGUID,"); strSql.Append("strWorkGrouGUID=@strWorkGrouGUID,"); strSql.Append("strTrainmanGUID1=@strTrainmanGUID1,"); strSql.Append("strTrainmanGUID2=@strTrainmanGUID2,"); strSql.Append("strTrainmanGUID3=@strTrainmanGUID3,"); strSql.Append("strTrainmanGUID4=@strTrainmanGUID4,"); strSql.Append("ePlanState=@ePlanState,"); strSql.Append("nNeedRest=@nNeedRest,"); strSql.Append("nFinished=@nFinished,"); strSql.Append("dtSignTime=@dtSignTime,"); strSql.Append("dtStartTrainTime=@dtStartTrainTime"); strSql.Append(" where strGUID=@strGUID"); SqlParameter[] parameters = { new SqlParameter("@strTrainJiaoLuGUID", SqlDbType.VarChar, 50), new SqlParameter("@dtArriveTime", SqlDbType.DateTime), new SqlParameter("@dtCallTime", SqlDbType.DateTime), new SqlParameter("@strTrainNo", SqlDbType.VarChar, 50), new SqlParameter("@dtChuQinTime", SqlDbType.DateTime), new SqlParameter("@strTrainNoGUID", SqlDbType.VarChar, 50), new SqlParameter("@strWorkGrouGUID", SqlDbType.VarChar, 50), new SqlParameter("@strTrainmanGUID1", SqlDbType.VarChar, 50), new SqlParameter("@strTrainmanGUID2", SqlDbType.VarChar, 50), new SqlParameter("@strTrainmanGUID3", SqlDbType.VarChar, 50), new SqlParameter("@strTrainmanGUID4", SqlDbType.VarChar, 50), new SqlParameter("@ePlanState", SqlDbType.VarChar, 50), new SqlParameter("@nNeedRest", SqlDbType.Int, 4), new SqlParameter("@nFinished", SqlDbType.Int, 4), new SqlParameter("@dtSignTime", SqlDbType.VarChar, 50), new SqlParameter("@dtStartTrainTime", SqlDbType.VarChar, 50), new SqlParameter("@strGUID", SqlDbType.VarChar, 50) }; parameters[0].Value = model.strTrainJiaoLuGUID; parameters[1].Value = model.dtArriveTime; parameters[2].Value = model.dtCallTime; parameters[3].Value = model.strTrainNo; parameters[4].Value = model.dtChuQinTime; parameters[5].Value = model.strTrainNoGUID; parameters[6].Value = model.strWorkGrouGUID; parameters[7].Value = model.strTrainmanGUID1; parameters[8].Value = model.strTrainmanGUID2; parameters[9].Value = model.strTrainmanGUID3; parameters[10].Value = model.strTrainmanGUID4; parameters[11].Value = model.ePlanState; parameters[12].Value = model.nNeedRest; parameters[13].Value = model.nFinished; parameters[14].Value = model.dtSignTime; parameters[15].Value = model.dtStartTrainTime; parameters[16].Value = model.strGUID; int rows = (int)SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool UpdateAndFirst(TF.RunSafty.Model.TAB_Plan_Rest model, string jiaoluID) { StringBuilder strSql = new StringBuilder(); strSql.Append("update TAB_Plan_Sign set "); strSql.Append("strTrainJiaoLuGUID=@strTrainJiaoLuGUID,"); strSql.Append("dtArriveTime=@dtArriveTime,"); strSql.Append("dtCallTime=@dtCallTime,"); strSql.Append("strTrainNo=@strTrainNo,"); strSql.Append("dtChuQinTime=@dtChuQinTime,"); strSql.Append("dtStartTrainTime=@dtStartTrainTime,"); strSql.Append("strTrainNoGUID=@strTrainNoGUID,"); strSql.Append("strWorkGrouGUID=@strWorkGrouGUID,"); strSql.Append("strTrainmanGUID1=@strTrainmanGUID1,"); strSql.Append("strTrainmanGUID2=@strTrainmanGUID2,"); strSql.Append("strTrainmanGUID3=@strTrainmanGUID3,"); strSql.Append("strTrainmanGUID4=@strTrainmanGUID4"); strSql.Append(" where strGUID=@strGUID"); SqlParameter[] parameters = { new SqlParameter("@strTrainJiaoLuGUID", SqlDbType.VarChar, 50), new SqlParameter("@dtArriveTime", SqlDbType.DateTime), new SqlParameter("@dtCallTime", SqlDbType.DateTime), new SqlParameter("@strTrainNo", SqlDbType.VarChar, 50), new SqlParameter("@dtChuQinTime", SqlDbType.DateTime), new SqlParameter("@dtStartTrainTime", SqlDbType.DateTime), new SqlParameter("@strTrainNoGUID", SqlDbType.VarChar, 50), new SqlParameter("@strWorkGrouGUID", SqlDbType.VarChar, 50), new SqlParameter("@strTrainmanGUID1", SqlDbType.VarChar, 50), new SqlParameter("@strTrainmanGUID2", SqlDbType.VarChar, 50), new SqlParameter("@strTrainmanGUID3", SqlDbType.VarChar, 50), new SqlParameter("@strTrainmanGUID4", SqlDbType.VarChar, 50), new SqlParameter("@strGUID", SqlDbType.VarChar, 50) }; parameters[0].Value = model.strTrainJiaoLuGUID; parameters[1].Value = model.dtArriveTime; parameters[2].Value = model.dtCallTime; parameters[3].Value = model.strTrainNo; parameters[4].Value = model.dtChuQinTime; parameters[5].Value = model.dtStartTrainTime; parameters[6].Value = model.strTrainNoGUID; parameters[7].Value = model.strWorkGrouGUID; parameters[8].Value = model.strTrainmanGUID1; parameters[9].Value = model.strTrainmanGUID2; parameters[10].Value = model.strTrainmanGUID3; parameters[11].Value = model.strTrainmanGUID4; parameters[12].Value = model.strGUID; int rows1 = (int)SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters); string strSql2 = "update TAB_Plan_SignJiaoLuIndex set strTrainJiaoLuGUID=" + jiaoluID + " where nID=1"; int rows2 = (int)SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql2.ToString()); if (rows1 + rows2 > 0) { return(true); } else { return(false); } }
public void SetModelValue(TF.RunSafty.Model.InterfaceModel.PlanSign paramModel, TF.RunSafty.Model.TAB_Plan_Rest PlanSign) { PlanSign.strGUID = paramModel.strGUID; PlanSign.nNeedRest = paramModel.nNeedRest; PlanSign.strTrainJiaoLuGUID = paramModel.strTrainJiaoLuGUID; PlanSign.strTrainNo = paramModel.strTrainNo; PlanSign.dtArriveTime = paramModel.dtArriveTime; PlanSign.dtCallTime = paramModel.dtCallTime; PlanSign.dtChuQinTime = paramModel.dtChuQinTime; PlanSign.dtStartTrainTime = paramModel.dtStartTrainTime; }
//编辑 public int Edit(TF.RunSafty.Model.TAB_Plan_Rest model) { return(dal.UpdatePlan(model)); }
public int EditParamModel(TF.RunSafty.Model.InterfaceModel.PlanSign paramModel, TF.RunSafty.Model.TAB_Plan_Rest PlanSign) { SetModelValue(paramModel, PlanSign); return(this.Edit(PlanSign)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(TF.RunSafty.Model.TAB_Plan_Rest model) { model.strGUID = System.Guid.NewGuid().ToString(); return(dal.AddPlan(model)); }
public void SetModelValue(TF.RunSafty.Model.InterfaceModel.PlanRestModel PlanRestModel, TF.RunSafty.Model.TAB_Plan_Rest Plan_Rest) { string dt = DateTime.Now.ToString(); if (PlanRestModel.data.dtarrivetime.ToString() != "") { Plan_Rest.dtArriveTime = PlanRestModel.data.dtarrivetime.ToString(); } else { Plan_Rest.dtArriveTime = dt; } if (PlanRestModel.data.dtcalltime.ToString() != "") { Plan_Rest.dtCallTime = PlanRestModel.data.dtcalltime.ToString(); } else { Plan_Rest.dtCallTime = dt; } if (PlanRestModel.data.dtchuqintime.ToString() != "") { Plan_Rest.dtChuQinTime = PlanRestModel.data.dtchuqintime.ToString(); } else { Plan_Rest.dtChuQinTime = dt; } if (PlanRestModel.data.dtStartTrainTime.ToString() != "") { Plan_Rest.dtStartTrainTime = PlanRestModel.data.dtStartTrainTime.ToString(); } else { Plan_Rest.dtStartTrainTime = dt; } if (PlanRestModel.data.dtSignTime.ToString() != "") { Plan_Rest.dtSignTime = PlanRestModel.data.dtSignTime.ToString(); } else { Plan_Rest.dtSignTime = dt; } Plan_Rest.strGUID = PlanRestModel.data.strguid; Plan_Rest.strTrainJiaoLuGUID = PlanRestModel.data.strtrainjiaoluguid; Plan_Rest.strTrainmanGUID1 = PlanRestModel.data.strtrainmanguid1; Plan_Rest.strTrainmanGUID2 = PlanRestModel.data.strtrainmanguid2; Plan_Rest.strTrainmanGUID3 = PlanRestModel.data.strtrainmanguid3; Plan_Rest.strTrainmanGUID4 = PlanRestModel.data.strtrainmanguid4; Plan_Rest.strTrainNo = PlanRestModel.data.strtrainno; Plan_Rest.strTrainNoGUID = PlanRestModel.data.strtrainnoguid; Plan_Rest.strWorkGrouGUID = PlanRestModel.data.strworkgrouguid; Plan_Rest.nNeedRest = PlanRestModel.data.nNeedRest; Plan_Rest.nFinished = PlanRestModel.data.nFinished;; if (PlanRestModel.data.ePlanState != "") { Plan_Rest.ePlanState = int.Parse(PlanRestModel.data.ePlanState); } else { Plan_Rest.ePlanState = 0; } }
/// <summary> /// 更新一条数据 /// </summary> public bool UpdateAndFirst(TF.RunSafty.Model.TAB_Plan_Rest model, string JiaoLuGUID) { return(dal.UpdateAndFirst(model, JiaoLuGUID)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(TF.RunSafty.Model.TAB_Plan_Rest model) { return(dal.Update(model)); }