public static List <TruckTeam> GetTruckTeams() { string sql = @"SELECT [TeamID] ,[TeamName] ,[Leader] ,[Remark] ,[CheckInTime] ,[AlterTime] FROM[TruckTeam] where IsDelete=0"; SqlDataReader sdr = DBHelper.ExecuteReader(sql); List <TruckTeam> truckTeamlist = new List <TruckTeam>(); if (sdr.HasRows) { while (sdr.Read()) { TruckTeam truckTeam = new TruckTeam(); truckTeam.TeamID = Convert.ToInt32(sdr["TeamID"]); truckTeam.TeamName = sdr["TeamName"].ToString(); truckTeam.Leader = sdr["Leader"].ToString(); truckTeam.CheckInTime = Convert.ToDateTime(sdr["CheckInTime"]); truckTeam.AlterTime = Convert.ToDateTime(sdr["AlterTime"]); truckTeam.Remark = sdr["Remark"].ToString(); truckTeamlist.Add(truckTeam); } } return(truckTeamlist); }
protected void gvTruckTeam_RowUpdating(object sender, GridViewUpdateEventArgs e) { TruckTeam tt = new TruckTeam(); tt.TeamID = Convert.ToInt32(gvTruckTeam.DataKeys[e.RowIndex].Value); tt.TeamName = ((TextBox)(gvTruckTeam.Rows[e.RowIndex].Cells[1].Controls[0])).Text; try { tt.CheckInTime = Convert.ToDateTime(((TextBox)(gvTruckTeam.Rows[e.RowIndex].Cells[3].FindControl("txtBeginTime"))).Text); } catch (Exception) { this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入正确的时间!')", true); return; } tt.Leader = ((TextBox)(gvTruckTeam.Rows[e.RowIndex].Cells[2].Controls[0])).Text; tt.Remark = ((TextBox)(gvTruckTeam.Rows[e.RowIndex].Cells[5].FindControl("txtRemark"))).Text; if (LogisticsManagerBLL.TruckTeamBLL.UpdateTruckTeam(tt) > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('修改成功!')", true); gvTruckTeam.EditIndex = -1; BindTruckTeam(); return; } else { this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('修改失败!')", true); gvTruckTeam.EditIndex = -1; BindTruckTeam(); return; } }
public static DataTable GetTruckTeam(TruckTeam team) { StringBuilder sql = new StringBuilder(@"SELECT [TeamID] ,[TeamName] ,[Leader] ,[Remark] ,[CheckInTime] ,[AlterTime] FROM[TruckTeam] where IsDelete=0"); List <string> wherelist = new List <string>(); List <SqlParameter> para = new List <SqlParameter>(); if (team.TeamID != -1) { wherelist.Add("[TeamID]=@TeamID"); para.Add(new SqlParameter("@TeamID", team.TeamID)); } if (!string.IsNullOrWhiteSpace(team.Leader)) { wherelist.Add("[Leader] like @Leader"); para.Add(new SqlParameter("@Leader", "%" + team.Leader + "%")); } if (wherelist.Count > 0) { sql.Append($" and {string.Join(" and ", wherelist.ToArray())}"); } return(DBHelper.ExecuteDataTable(sql.ToString(), para.ToArray())); }
protected void btnAdd_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtTruckName.Text)) { this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入车队名称!')", true); return; } if (string.IsNullOrWhiteSpace(txtLeader.Text)) { this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请输入车队负责人!')", true); return; } TruckTeam tm = new TruckTeam() { TeamName = txtTruckName.Text, Leader = txtLeader.Text, Remark = txtRemark.Text }; if (LogisticsManagerBLL.TruckTeamBLL.AddTruckTeam(tm) > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加成功!')", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败!')", true); } }
protected void btnSelect_Click(object sender, EventArgs e) { TruckTeam tt = new TruckTeam() { TeamName = ddlTruck.SelectedValue, Leader = txtLeader.Text }; rpt_TruckTeam.DataSource = LogisticsManagerBLL.TruckTeamBLL.GetTruckTeams(tt); rpt_TruckTeam.DataBind(); }
public static int AddTruckTeam(TruckTeam tm) { string sql = "insert into [TruckTeam] values(@TeamName,@Leader,@Remark,getdate(),0,getdate())"; SqlParameter[] para = { new SqlParameter("@TeamName", tm.TeamName), new SqlParameter("@Leader", tm.Leader), new SqlParameter("@Remark", tm.Remark) }; return(DBHelper.ExcuteNonQuery(sql, para)); }
protected void btnSelect_Click(object sender, EventArgs e) { int teamID = Convert.ToInt32(ddlTruck.SelectedValue); string leader = txtLeader.Text; TruckTeam team = new TruckTeam() { TeamID = teamID, Leader = leader }; gvTruckTeam.DataSource = LogisticsManagerBLL.TruckTeamBLL.GetTruckTeam(team); gvTruckTeam.DataBind(); }
public static int UpdateTruckTeam(TruckTeam tt) { string sql = "update [TruckTeam] set TeamName=@TeamName,Leader=@Leader,CheckInTime=@CheckInTime,Remark=@Remark,AlterTime=getdate() where TeamID=@TeamID"; SqlParameter[] para = { new SqlParameter("@TeamID", tt.TeamID), new SqlParameter("@Leader", tt.Leader), new SqlParameter("@Remark", tt.Remark), new SqlParameter("@TeamName", tt.TeamName), new SqlParameter("@CheckInTime", tt.CheckInTime) }; return(DBHelper.ExcuteNonQuery(sql, para)); }
public static List <TruckTeam> GetTruckTeams(TruckTeam tt) { StringBuilder sql = new StringBuilder(@"SELECT [TeamID] ,[TeamName] ,[Leader] ,[Remark] ,[CheckInTime] ,[AlterTime] FROM[TruckTeam] and IsDelete=0"); List <string> wherelist = new List <string>(); List <SqlParameter> paralist = new List <SqlParameter>(); if (tt.TeamName != "-1") { wherelist.Add("TeamName=@TeamName"); paralist.Add(new SqlParameter("@TeamName", tt.TeamName)); } if (!string.IsNullOrWhiteSpace(tt.Leader)) { wherelist.Add("Leader=@Leader"); paralist.Add(new SqlParameter("@Leader", tt.Leader)); } if (wherelist.Count > 0) { sql.Append($" where {string.Join(" and ",wherelist.ToArray())}"); } SqlDataReader sdr = DBHelper.ExecuteReader(sql.ToString(), paralist.ToArray()); List <TruckTeam> truckTeamlist = new List <TruckTeam>(); if (sdr.HasRows) { while (sdr.Read()) { TruckTeam truckTeam = new TruckTeam(); truckTeam.TeamID = Convert.ToInt32(sdr["TeamID"]); truckTeam.TeamName = sdr["TeamName"].ToString(); truckTeam.Leader = sdr["Leader"].ToString(); truckTeam.CheckInTime = Convert.ToDateTime(sdr["CheckInTime"]); truckTeam.AlterTime = Convert.ToDateTime(sdr["AlterTime"]); truckTeam.Remark = sdr["Remark"].ToString(); truckTeamlist.Add(truckTeam); } } return(truckTeamlist); }
public static int UpdateTruckTeam(TruckTeam tt) { return(LogisticsManagerDAL.TruckTeamDAL.UpdateTruckTeam(tt)); }
public static List <TruckTeam> GetTruckTeams(TruckTeam tt) { return(LogisticsManagerDAL.TruckTeamDAL.GetTruckTeams(tt)); }
public static int AddTruckTeam(TruckTeam tm) { return(LogisticsManagerDAL.TruckTeamDAL.AddTruckTeam(tm)); }
public static DataTable GetTruckTeam(TruckTeam team) { return(LogisticsManagerDAL.TruckTeamDAL.GetTruckTeam(team)); }