有人可以在我的项目中帮助我解决这个问题。 我有工作人员有不同的登录和具有相同的角色。我有一个客户页面,工人可以申请公司的职位(网格),具有不同的班次(公司职位内的另一个网格)。当工人在该班次上申请时,该行将在网格中消失。
我的问题是..我想在另一名工作人员登录时再次显示该行。
我怎么能这样做..我只在一个工人那里做过。
这就是我所拥有的......
控制器:
//to load the data of the grid
public JsonResult LoadCustomerPositionShiftWorkerList(int? clientCusPosId, int? clientId)
{
List<userWorkerCompare> workerDetails = new List<userWorkerCompare>();
GlobalVariables.SiteMapFile = "ClientSiteMapProvider";
MembershipUser membershipUser = Membership.GetUser();
string userId = membershipUser.ProviderUserKey.ToString();
var workerIdList = new List<Int32>();
var customerPositionShiftList = new List<Client_Customer_Position_Shift>();
List<ClientCustomerPositionShiftInfo> clientCustomerPositionShiftList = new List<ClientCustomerPositionShiftInfo>();
var filterList = (from a in db.Worker_Customer_Apply_Shift
where a.LogicalDelete == false && a.Client_Customer_PositionID == clientCusPosId
select a).ToList();
//this is to get workerId
if (Roles.IsUserInRole("Worker"))
{
var listWorker = (from a in db.Workers
where a.LogicalDelete == false
select new
{
a.ID,
a.userId,
a.FirstName,
a.LastName,
a.MiddleName,
a.BirthDate,
a.Gender_LookID,
a.LogicalDelete
}).ToList();
if (listWorker.Count() > 0)
{
foreach (var row in listWorker)
{
var cli = new userWorkerCompare
{
ID = row.ID,
FirstName = row.FirstName,
MiddleName = row.MiddleName,
LastName = row.LastName,
LogicalDelete = row.LogicalDelete,
userId = row.userId.ToString()
};
workerDetails.Add(cli);
}
var workerProfile = (from a in workerDetails
join b in db.Workers
on a.ID equals b.ID
where a.LogicalDelete == false && a.userId == userId
select b).SingleOrDefault();
ViewBag.WorkerProfile = workerProfile;
var workerAvail = (from a in db.Worker_Availability
where a.LogicalDelete == false
&& a.Worker_ID == workerProfile.ID
select a).ToList();
ViewBag.WorkerAvail = workerAvail;
var workerId = (from a in workerDetails
where a.LogicalDelete == false && a.userId == userId
select a.ID).SingleOrDefault();
ViewBag.WorkerId = workerId;
//this is to compare customer position shift from worker availability
if (clientCusPosId.HasValue)
{
customerPositionShiftList = (from a in db.Client_Customer_Position_Shift
where a.LogicalDelete == false && a.Client_Customer_PositionID == clientCusPosId
select a).ToList();
foreach (var row in customerPositionShiftList)
{
var workerList = (from a in db.Worker_Availability
where a.LogicalDelete == false && a.Worker_ID == workerProfile.ID
select a).ToList();
foreach (var Availability in workerList)
{
if (Availability.AvailableDay_LookID == row.Day_LookID || Availability.AvailableDay_LookID == 76 || row.Day_LookID == 76)
{
if (((Availability.StartTime == "Anytime" && Availability.EndTime == "Anytime") || (row.StartTime == "Anytime" && row.EndTime == "Anytime")) ||
(row.StartTime == "Anytime" || row.EndTime == "Anytime") || (Availability.StartTime == "Anytime" || Availability.EndTime == "Anytime"))
{
workerIdList.Add(row.ID);
}
else
{
DateTime availStartTime = Convert.ToDateTime(Availability.StartTime);
DateTime posStartTime = Convert.ToDateTime(row.StartTime);
DateTime availEndTime = Convert.ToDateTime(Availability.EndTime);
DateTime posEndTime = Convert.ToDateTime(row.EndTime);
if ((Availability.StartTime == row.StartTime &&
Availability.EndTime == row.EndTime) || (Availability.StartTime == row.StartTime ||
Availability.EndTime == row.EndTime) || (availStartTime < posStartTime && availEndTime > posEndTime))
{
workerIdList.Add(row.ID);
}
}
}
}
}
}
//to show compared list
var toBeList = (from a in customerPositionShiftList
where a.LogicalDelete == false
select a).ToList();
//after applying this one triggers to hide the row
var setToList =
toBeList.Select(x => x.ID).Except(filterList.Select(y => y.clientCusPosShiftId)).ToList();
var cusWorkList = (from a in db.Client_Customer_Position_Shift
where a.LogicalDelete == false
&& workerIdList.Contains(a.ID)
&& setToList.Contains(a.ID)
select new
{
a.ID,
a.Client_CustomerID,
a.Client_Customer_PositionID,
a.Day_LookID,
a.EndTime,
a.StartTime,
a.LogicalDelete
}).ToList();
if (cusWorkList.Count() > 0)
{
foreach (var row in cusWorkList)
{
ClientCustomerPositionShiftInfo ccpsi = new ClientCustomerPositionShiftInfo
{
ID = row.ID,
ClientID = clientId.HasValue ? clientId.Value : 0,
Client_Customer_PositionID = row.Client_Customer_PositionID,
Client_CustomerID = row.Client_CustomerID,
Day = GetLookupDisplayValById(row.Day_LookID),
StartTime = row.StartTime != "Anytime" ? Convert.ToDateTime(row.StartTime).ToString("hh:mm tt") : row.StartTime.Trim(),
EndTime = row.EndTime != "Anytime" ? Convert.ToDateTime(row.EndTime).ToString("hh:mm tt") : row.EndTime.Trim(),
DayID = (row.Day_LookID)
};
clientCustomerPositionShiftList.Add(ccpsi);
}
}
}
}
return Json(clientCustomerPositionShiftList.ToList().OrderBy(p => p.DayID), JsonRequestBehavior.AllowGet);
}
查看/脚本:
<script type="text/javascript">
$(document).ready(function () {
var comparegrid = $("#positionShiftWorkerComparedGrid").kendoGrid({
scrollable: false,
sortable: true,
pageable: true,
dataSource: {
transport: {
read: {
url: '/Customer/LoadCustomerPositionShiftWorkerList?clientCusId=' + clientCusId + '&clientId=' + clientId + '&clientCusPosId=' + clientCusPosId,
dataType: "json",
type: "POST"
}
},
pageSize: 10
},
rowTemplate: kendo.template($("#positionShiftWorkerComparedTemplate").html().replace('k-alt', '')),
altRowTemplate: kendo.template($("#positionShiftWorkerComparedTemplate").html())
});
});
</script>
谢谢!