我目前从事员工休假管理工作。经理有 2 个网格视图,其中一个显示由特定员工申请的休假,其中包含完整的休假详细信息。GridView 中有 Status 列,一旦申请休假,就会显示 Pending。一旦经理登录并单击作为超链接的更新列,他将重定向到另一个显示休假详细信息的页面,他可以接受或拒绝休假。一旦他做了这两个中的任何一个,gridview 将获得更新的设置状态=接受或拒绝待处理。
在另一个用于员工的网格视图中,显示了他/她申请的所有休假。即使网格视图已获得状态,一旦他应用它将显示待处理,一旦经理接受/拒绝,它就会分别显示。
员工 GridView 中也有超链接列,当他单击时,他将被重定向到另一个页面,显示他申请的休假的详细信息,并且它有一个重新申请休假的按钮。
此重新申请仅适用于被拒绝或处于待处理状态的休假。
问题是当员工重新申请可能是通过编辑详细信息或使用相同的详细信息来更新员工的拒绝休假 GridView 但它不会被他重新申请的特定拒绝行替换。它将需要新的请假请求。我需要将拒绝的请假请求替换为重新申请的请假请求,将状态从拒绝设置为待处理。
对不起或很长的帖子,但我想解释整个场景。光秃秃的。:)
ReAply的cs代码
protected void BtnReApply_Click(object sender, EventArgs e)
{
MTMSDTO objc = new MTMSDTO();
int Flag = 0;
LblLoggedInUser.Text = Session["EmpName"].ToString();
objc.LoggedInUser = LblLoggedInUser.Text;
objc.TypeofLeave = LblTypeofLeave.Text;
string date;
date = Convert.ToDateTime(TxtBeginDate.Text).ToString("dd/MM/yyyy");
DateTime dt = new DateTime();
dt = Convert.ToDateTime(date);
objc.BeginDate = dt;
objc.EndDate = Convert.ToDateTime(TxtEndDate.Text);
objc.Description = TxtDescription.Text;
objc.NumofDays = Convert.ToInt32(TxtNumofDays.Text);
objc.Status = LblStatus.Text;
int X = obj.InsertLeave(objc);
{
if (X >= 0)
{
Flag = 1;
}
else
{
Flag = 0;
}
}
if (Flag == 1)
{
LblSuccess.Visible = true;
LblSuccess.Text = "Data Added Successfully and Leave Application Succesfully Sent";
}
else
{
LblErr.Visible = true;
LblErr.Text = "Failed To Add Data and Send Leave Request!!!";
}
MailMessage message = new MailMessage();
message.To.Add("");
message.Subject = "Leave Request";
message.From = new MailAddress("");
message.IsBodyHtml = true;
LblLoggedInUser.Text = Session["EmpName"].ToString();
objc.LoggedInUser = LblLoggedInUser.Text;
TxtManager.Text = Session["Manager"].ToString();
objc.Manager = TxtManager.Text;
objc.TypeofLeave = LblTypeofLeave.Text;
objc.NumofDays = Convert.ToInt32(TxtNumofDays.Text.Trim());
message.Body = "<span style = font-family:Arial,font-size:10pt>";
message.Body += "Hello <b>" + Session["Manager"].ToString() + "</b>,<br /><br />";
message.Body += "<b>" + Session["EmpName"].ToString() + "</b>" + " has requested" + "<b>" + " " + LblTypeofLeave.Text + "</b>" + " for" + "<b>" + " " + TxtNumofDays.Text + " " + "</b><br />";
message.Body += "day/days, kindly login to the portal to Accept or Reject it";
message.Body += "<br />";
message.Body += "<br />";
message.Body += "Thank You.<br />";
message.Body += "</span>";
SmtpClient smtp = new SmtpClient("");
smtp.Send(message);
LblTypeofLeave.Text = "";
TxtBeginDate.Text = "";
TxtEndDate.Text = "";
TxtDescription.Text = "";
TxtNumofDays.Text = "";
LblStatus.Text = "";
}
员工 GridView 的行数据绑定代码
protected void GridViewLeaveHistory_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink ViewDetails = e.Row.FindControl("ViewDetails") as HyperLink;
ViewDetails.NavigateUrl = "ReApply.aspx?LeaveID=" + e.Row.Cells[0].Text;
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
((Label)e.Row.Cells[0].FindControl("Description")).Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRow pr = ((DataRowView)e.Row.DataItem).Row;
string status = Convert.ToString(pr["Status"]);
if (status == "Accepted")
{
e.Row.Cells[6].BackColor = System.Drawing.Color.LightBlue;
e.Row.Cells[7].Visible = false;
}
else
{
if(status == "Rejected")
e.Row.Cells[6].BackColor = System.Drawing.Color.Yellow;
if (status == "Pending")
e.Row.Cells[6].BackColor = System.Drawing.Color.LightGray;
}
}
}
这是员工的 GridView 代码
protected void GrdLeaveHistory()
{
MTMSDTO objc = new MTMSDTO();
{
objc.EmpName = Convert.ToString(Session["EmpName"]);
DataSet GrdLH = obj.GrdLeaveHistory(objc);
DataView GrdLeaveH = new DataView();
GrdLeaveH.Table = GrdLH.Tables[0];
GridViewLeaveHistory.DataSource = GrdLeaveH;
GridViewLeaveHistory.DataBind();
}
}