私は現在、従業員の休暇管理に取り組んでいます。マネージャー用に 2 つのグリッド ビューがあり、特定の従業員が適用した休暇を表示します。これには、完全な休暇の詳細が含まれています。休暇が適用されると Pending を示す GridView の Status 列があります。マネージャがログインして、ハイパーリンクである [更新] 列をクリックすると、休暇の詳細を示す別のページにリダイレクトされ、休暇を受け入れるか拒否することができます。彼が 2 つのいずれかを実行すると、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 の行 DataBound コード
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();
}
}