/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.Machine model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Machine("); strSql.Append("Remark,CreatUserID,RecordUpdateUserID,RecordIsDelete,RecordUpdateTime,RecordCreateTime,Latitude,Longitude,LocationAddress,AgentId,UserID,AgentName,SupervisorId,SupervisorName,SalesmanId,SalesmanName,SN,MAC,Address,Status,TeamViewerNumber,TeamViewerPwd,ActivationCode,MachineSupplierId,Platform,FlatDeviceNumber,SId"); strSql.Append(") values ("); strSql.Append("@Remark,@CreatUserID,@RecordUpdateUserID,@RecordIsDelete,@RecordUpdateTime,@RecordCreateTime,@Latitude,@Longitude,@LocationAddress,@AgentId,@UserID,@AgentName,@SupervisorId,@SupervisorName,@SalesmanId,@SalesmanName,@SN,@MAC,@Address,@Status,@TeamViewerNumber,@TeamViewerPwd,@ActivationCode,@MachineSupplierId,@Platform,@FlatDeviceNumber,@SId"); strSql.Append(") "); strSql.Append(";select SCOPE_IDENTITY()"); SqlParameter[] parameters = { new SqlParameter("@Remark", model.Remark), new SqlParameter("@CreatUserID", model.CreatUserID), new SqlParameter("@RecordUpdateUserID", model.RecordUpdateUserID), new SqlParameter("@RecordIsDelete", model.RecordIsDelete), new SqlParameter("@RecordUpdateTime", model.RecordUpdateTime), new SqlParameter("@RecordCreateTime", model.RecordCreateTime), new SqlParameter("@Latitude", model.Latitude), new SqlParameter("@Longitude", model.Longitude), new SqlParameter("@LocationAddress", model.LocationAddress), new SqlParameter("@AgentId", model.AgentId), new SqlParameter("@UserID", model.UserID), new SqlParameter("@AgentName", model.AgentName), new SqlParameter("@SupervisorId", model.SupervisorId), new SqlParameter("@SupervisorName", model.SupervisorName), new SqlParameter("@SalesmanId", model.SalesmanId), new SqlParameter("@SalesmanName", model.SalesmanName), new SqlParameter("@SN", model.SN), new SqlParameter("@MAC", model.MAC), new SqlParameter("@Address", model.Address), new SqlParameter("@Status", model.Status), new SqlParameter("@TeamViewerNumber", model.TeamViewerNumber), new SqlParameter("@TeamViewerPwd", model.TeamViewerPwd), new SqlParameter("@ActivationCode", model.ActivationCode), new SqlParameter("@MachineSupplierId", model.MachineSupplierId), new SqlParameter("@Platform", model.Platform), new SqlParameter("@FlatDeviceNumber", model.FlatDeviceNumber), new SqlParameter("@SId", model.SId) }; object obj = BWJSHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public BWJS.Model.Machine GetModelByUserId(int userId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from Machine "); strSql.Append(" where UserID=@UserID and RecordIsDelete=0"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int, 4) }; parameters[0].Value = userId; BWJS.Model.Machine model = new BWJS.Model.Machine(); DataSet ds = BWJSHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public BWJS.Model.Machine GetModel(int MachineID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from Machine "); strSql.Append(" where MachineID=@MachineID"); SqlParameter[] parameters = { new SqlParameter("@MachineID", SqlDbType.Int, 4) }; parameters[0].Value = MachineID; BWJS.Model.Machine model = new BWJS.Model.Machine(); DataSet ds = BWJSHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.Machine model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.Machine model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.Machine model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Machine set "); strSql.Append(" Remark = @Remark , "); strSql.Append(" CreatUserID = @CreatUserID , "); strSql.Append(" RecordUpdateUserID = @RecordUpdateUserID , "); strSql.Append(" RecordIsDelete = @RecordIsDelete , "); strSql.Append(" RecordUpdateTime = @RecordUpdateTime , "); strSql.Append(" RecordCreateTime = @RecordCreateTime , "); strSql.Append(" Latitude = @Latitude , "); strSql.Append(" Longitude = @Longitude , "); strSql.Append(" LocationAddress = @LocationAddress , "); strSql.Append(" AgentId = @AgentId , "); strSql.Append(" UserID = @UserID , "); strSql.Append(" AgentName = @AgentName , "); strSql.Append(" SupervisorId = @SupervisorId , "); strSql.Append(" SupervisorName = @SupervisorName , "); strSql.Append(" SalesmanId = @SalesmanId , "); strSql.Append(" SalesmanName = @SalesmanName , "); strSql.Append(" SN = @SN , "); strSql.Append(" MAC = @MAC , "); strSql.Append(" Address = @Address , "); strSql.Append(" Status = @Status , "); strSql.Append(" TeamViewerNumber = @TeamViewerNumber , "); strSql.Append(" TeamViewerPwd = @TeamViewerPwd , "); strSql.Append(" ActivationCode = @ActivationCode , "); strSql.Append(" MachineSupplierId = @MachineSupplierId ,"); strSql.Append(" Platform = @Platform , "); strSql.Append(" FlatDeviceNumber = @FlatDeviceNumber , "); strSql.Append(" SId = @SId "); strSql.Append(" where MachineID=@MachineID "); SqlParameter[] parameters = { new SqlParameter("@MachineID", model.MachineID), new SqlParameter("@Remark", model.Remark), new SqlParameter("@CreatUserID", model.CreatUserID), new SqlParameter("@RecordUpdateUserID", model.RecordUpdateUserID), new SqlParameter("@RecordIsDelete", model.RecordIsDelete), new SqlParameter("@RecordUpdateTime", model.RecordUpdateTime), new SqlParameter("@RecordCreateTime", model.RecordCreateTime), new SqlParameter("@Latitude", model.Latitude), new SqlParameter("@Longitude", model.Longitude), new SqlParameter("@LocationAddress", model.LocationAddress), new SqlParameter("@AgentId", model.AgentId), new SqlParameter("@UserID", model.UserID), new SqlParameter("@AgentName", model.AgentName), new SqlParameter("@SupervisorId", model.SupervisorId), new SqlParameter("@SupervisorName", model.SupervisorName), new SqlParameter("@SalesmanId", model.SalesmanId), new SqlParameter("@SalesmanName", model.SalesmanName), new SqlParameter("@SN", model.SN), new SqlParameter("@MAC", model.MAC), new SqlParameter("@Address", model.Address), new SqlParameter("@Status", model.Status), new SqlParameter("@TeamViewerNumber", model.TeamViewerNumber), new SqlParameter("@TeamViewerPwd", model.TeamViewerPwd), new SqlParameter("@ActivationCode", model.ActivationCode), new SqlParameter("@MachineSupplierId", model.MachineSupplierId), new SqlParameter("@Platform", model.Platform), new SqlParameter("@FlatDeviceNumber", model.FlatDeviceNumber), new SqlParameter("@SId", model.SId) }; int rows = BWJSHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// datarow转成对象实体 /// </summary> public BWJS.Model.Machine DataRowToModel(DataRow row) { BWJS.Model.Machine model = new BWJS.Model.Machine(); if (row != null) { if (row["MachineID"].ToString() != "") { model.MachineID = int.Parse(row["MachineID"].ToString()); } model.Remark = row["Remark"].ToString(); if (row["CreatUserID"].ToString() != "") { model.CreatUserID = int.Parse(row["CreatUserID"].ToString()); } if (row["RecordUpdateUserID"].ToString() != "") { model.RecordUpdateUserID = int.Parse(row["RecordUpdateUserID"].ToString()); } if (row["RecordIsDelete"].ToString() != "") { if ((row["RecordIsDelete"].ToString() == "1") || (row["RecordIsDelete"].ToString().ToLower() == "true")) { model.RecordIsDelete = true; } else { model.RecordIsDelete = false; } } if (row["RecordUpdateTime"].ToString() != "") { model.RecordUpdateTime = DateTime.Parse(row["RecordUpdateTime"].ToString()); } if (row["RecordCreateTime"].ToString() != "") { model.RecordCreateTime = DateTime.Parse(row["RecordCreateTime"].ToString()); } model.Latitude = row["Latitude"].ToString(); model.Longitude = row["Longitude"].ToString(); model.LocationAddress = row["LocationAddress"].ToString(); if (row["AgentId"].ToString() != "") { model.AgentId = int.Parse(row["AgentId"].ToString()); } if (row["UserID"].ToString() != "") { model.UserID = int.Parse(row["UserID"].ToString()); } model.AgentName = row["AgentName"].ToString(); if (row["SupervisorId"].ToString() != "") { model.SupervisorId = int.Parse(row["SupervisorId"].ToString()); } model.SupervisorName = row["SupervisorName"].ToString(); if (row["SalesmanId"].ToString() != "") { model.SalesmanId = int.Parse(row["SalesmanId"].ToString()); } model.SalesmanName = row["SalesmanName"].ToString(); model.SN = row["SN"].ToString(); model.MAC = row["MAC"].ToString(); model.Address = row["Address"].ToString(); if (row["Status"].ToString() != "") { model.Status = int.Parse(row["Status"].ToString()); } model.TeamViewerNumber = row["TeamViewerNumber"].ToString(); model.TeamViewerPwd = row["TeamViewerPwd"].ToString(); model.ActivationCode = row["ActivationCode"].ToString(); if (row["MachineSupplierId"].ToString() != "") { model.MachineSupplierId = int.Parse(row["MachineSupplierId"].ToString()); } model.Platform = row["Platform"].ToString(); model.FlatDeviceNumber = row["FlatDeviceNumber"].ToString(); model.SId = row["SId"].ToString(); return(model); } else { return(null); } }