protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["LoginUserId"] == null) { Response.Redirect("~/Default.aspx"); return; } else { ViewState["LoginUserGroup"] = Session["LoginUserGrp"].ToString(); ViewState["LoginId"] = Session["LoginId"].ToString(); } DDLPrjLed.Enabled = true; DDLPrjLed.Items.Clear(); DDLPrjLed.DataSource = BLayer.FillEmp(0, " And IsNull(EmpGroup,'')='Ledger'"); DDLPrjLed.DataValueField = "EmpId"; DDLPrjLed.DataTextField = "EmpName"; DDLPrjLed.DataBind(); DDLPrjLed.Items.Insert(0, new ListItem("--Select Ledger--", "0")); int IntEmpId = 0; if (ViewState["LoginUserGroup"].ToString() == "EMP") { IntEmpId = int.Parse(ViewState["LoginId"].ToString()); ddlEmployee.Enabled = false; } else { ddlEmployee.Enabled = true; } ddlEmployee.Items.Clear(); ddlEmployee.DataSource = BLayer.FillEmp(IntEmpId, ""); ddlEmployee.DataValueField = "EmpId"; ddlEmployee.DataTextField = "EmpName"; ddlEmployee.DataBind(); if (IntEmpId == 0) { ddlEmployee.Items.Insert(0, new ListItem("--Select Employee--", "0")); } DDLPrjName.Items.Clear(); DDLPrjName.DataSource = BLayer.FillProject(""); DDLPrjName.DataValueField = "PrjId"; DDLPrjName.DataTextField = "PrjName"; DDLPrjName.DataBind(); DDLPrjName.Items.Insert(0, new ListItem("--Select Project--", "0")); DDLPrjModule.Items.Clear(); DDLPrjModule.Items.Insert(0, new ListItem("--Select Module--", "0")); ddlWrkStatus.SelectedIndex = 0; } }
protected void DispRecord(string pStrNavigation) { int IntId = 0; StrSql = new StringBuilder(); StrSql.Length = 0; if (pStrNavigation == "EXAC") { IntId = int.Parse(HidFldId.Value); } else if (pStrNavigation.Trim().ToUpper() == "FIRST") { StrSql.AppendLine("Select Top 1 Id From WorkAssDet"); if (int.Parse(ddlEmployee.SelectedValue) != 0) { StrSql.AppendLine("Where EmpId=" + int.Parse(ddlEmployee.SelectedValue)); } StrSql.AppendLine("Order By Id"); } else if (pStrNavigation.Trim().ToUpper() == "NEXT") { if (HidFldId.Value == "") { LblMsg.Text = "Data not found"; return; } StrSql.AppendLine("Select Top 1 Id From WorkAssDet Where Id > " + int.Parse(HidFldId.Value)); if (int.Parse(ddlEmployee.SelectedValue) != 0) { StrSql.AppendLine("And EmpId=" + int.Parse(ddlEmployee.SelectedValue)); } } else if (pStrNavigation.Trim().ToUpper() == "PREV") { if (HidFldId.Value == "") { LblMsg.Text = "Data not found"; return; } StrSql.AppendLine("Select Top 1 Id From WorkAssDet Where Id < " + int.Parse(HidFldId.Value)); if (int.Parse(ddlEmployee.SelectedValue) != 0) { StrSql.AppendLine("And EmpId=" + int.Parse(ddlEmployee.SelectedValue)); } StrSql.AppendLine("Order By Id Desc"); } else if (pStrNavigation.Trim().ToUpper() == "LAST") { StrSql.AppendLine("Select Top 1 Id From WorkAssDet "); if (int.Parse(ddlEmployee.SelectedValue) != 0) { StrSql.AppendLine("Where EmpId=" + int.Parse(ddlEmployee.SelectedValue)); } StrSql.AppendLine("Order By Id Desc"); } if (pStrNavigation != "EXAC") { dtTemp = new DataTable(); dtTemp = SqlFunc.ExecuteDataTable(StrSql.ToString()); if (dtTemp.Rows.Count != 0) { IntId = int.Parse(dtTemp.Rows[0]["Id"].ToString()); } } StrSql = new StringBuilder(); StrSql.Length = 0; StrSql.AppendLine("Select W.Id,W.PrjLedId,W.PrjId,W.PrjModId,CM.ClientName,W.EmpId"); StrSql.AppendLine(",Convert(Varchar(10),W.AssignDate,103) As AssignDate,W.AssignTime"); StrSql.AppendLine(",W.DueDays,Convert(Varchar(10),W.DueDate,103) As DueDate"); StrSql.AppendLine(",W.WorkDet1,W.WorkDet2,W.WorkDet3,W.WorkStatus"); StrSql.AppendLine(",Case When IsNull(W.CompleteDate,'')<>''"); StrSql.AppendLine(" Then Convert(Varchar(10),W.CompleteDate,103) Else '' End As CompleteDate"); StrSql.AppendLine(",W.CompleteTime,W.Remark"); StrSql.AppendLine("From WorkAssDet W"); StrSql.AppendLine("Left Join Emp_Mast PL On PL.Id=W.PrjLedId"); StrSql.AppendLine("Left Join Emp_Mast E On E.Id=W.EmpId"); StrSql.AppendLine("Left Join Project_Mast P On P.Id=W.PrjId"); StrSql.AppendLine("Left Join Client_Mast CM On CM.Id=P.ClientId"); StrSql.AppendLine("Left Join Project_Module M On M.Id=W.PrjModId"); StrSql.AppendLine("Where W.Id=" + IntId); dtTemp = new DataTable(); dtTemp = SqlFunc.ExecuteDataTable(StrSql.ToString()); if (dtTemp.Rows.Count == 0) { ClearAll(); LblMsg.Text = "Data not found"; return; } LblMsg.Text = ""; HidFldId.Value = IntId.ToString(); DDLPrjLed.Items.Clear(); DDLPrjLed.DataSource = BLayer.FillEmp(0, " And IsNull(EmpGroup,'')='Ledger'"); DDLPrjLed.DataValueField = "EmpId"; DDLPrjLed.DataTextField = "EmpName"; DDLPrjLed.DataBind(); DDLPrjLed.Items.Insert(0, new ListItem("--Select Ledger--", "0")); DDLPrjName.Items.Clear(); DDLPrjName.DataSource = BLayer.FillProject(""); DDLPrjName.DataValueField = "PrjId"; DDLPrjName.DataTextField = "PrjName"; DDLPrjName.DataBind(); DDLPrjName.Items.Insert(0, new ListItem("--Select Project--", "0")); DDLPrjModule.Items.Clear(); DDLPrjModule.DataSource = BLayer.FillPrjModule(int.Parse(DDLPrjName.SelectedValue)); DDLPrjModule.DataValueField = "ModId"; DDLPrjModule.DataTextField = "ModName"; DDLPrjModule.DataBind(); DDLPrjModule.Items.Insert(0, new ListItem("--Select Module--", "0")); int IntEmpId = 0; if (ViewState["LoginUserGroup"].ToString() == "EMP") { IntEmpId = int.Parse(ViewState["LoginId"].ToString()); ddlEmployee.Enabled = false; } ddlEmployee.Items.Clear(); ddlEmployee.DataSource = BLayer.FillEmp(0, ""); ddlEmployee.DataValueField = "EmpId"; ddlEmployee.DataTextField = "EmpName"; ddlEmployee.DataBind(); ddlEmployee.Items.Insert(0, new ListItem("--Select Employee--", "0")); if (dtTemp.Rows[0]["PrjLedId"].ToString() != "") { DDLPrjLed.SelectedValue = dtTemp.Rows[0]["PrjLedId"].ToString(); } if (dtTemp.Rows[0]["PrjId"].ToString() != "") { DDLPrjName.SelectedValue = dtTemp.Rows[0]["PrjId"].ToString(); } if (dtTemp.Rows[0]["PrjModId"].ToString() != "") { DDLPrjModule.SelectedValue = dtTemp.Rows[0]["PrjModId"].ToString(); } if (dtTemp.Rows[0]["EmpId"].ToString() != "") { ddlEmployee.SelectedValue = dtTemp.Rows[0]["EmpId"].ToString(); } ddlEmployee.Enabled = false; TxtClientName.Text = dtTemp.Rows[0]["ClientName"].ToString(); TxtAssignDate.Text = dtTemp.Rows[0]["AssignDate"].ToString(); TxtAssignTime.Text = dtTemp.Rows[0]["AssignTime"].ToString(); TxtDueDays.Text = dtTemp.Rows[0]["DueDays"].ToString(); TxtDueDate.Text = dtTemp.Rows[0]["DueDate"].ToString(); TxtWrkDetails1.Text = dtTemp.Rows[0]["WorkDet1"].ToString(); TxtWrkDetails2.Text = dtTemp.Rows[0]["WorkDet2"].ToString(); TxtWrkDetails3.Text = dtTemp.Rows[0]["WorkDet3"].ToString(); //ddlWrkStatus.Text = dtTemp.Rows[0]["WorkStatus"].ToString(); if (dtTemp.Rows[0]["WorkStatus"].ToString() != "") { ddlWrkStatus.SelectedValue = dtTemp.Rows[0]["WorkStatus"].ToString(); } TxtCompleteDate.Text = dtTemp.Rows[0]["CompleteDate"].ToString(); TxtCompleteTime.Text = dtTemp.Rows[0]["CompleteTime"].ToString(); TxtRemark.Text = dtTemp.Rows[0]["Remark"].ToString(); }
protected void btnWorkSelect_Click(object sender, ImageClickEventArgs e) { try { ImageButton btndetails = sender as ImageButton; GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer; Session["Id"] = GridWork.DataKeys[gvrow.RowIndex].Value.ToString(); HidFldId.Value = Session["Id"].ToString(); StrSql = new StringBuilder(); StrSql.Length = 0; StrSql.AppendLine("Select W.Id,W.PrjLedId,W.PrjId,W.PrjModId,CM.ClientName,W.EmpId"); StrSql.AppendLine(",Convert(Varchar(10),W.AssignDate,103) As AssignDate,W.AssignTime"); StrSql.AppendLine(",W.DueDays,Convert(Varchar(10),W.DueDate,103) As DueDate"); StrSql.AppendLine(",W.WorkDet1,W.WorkDet2,W.WorkDet3,W.WorkStatus"); StrSql.AppendLine(",Case When IsNull(W.CompleteDate,'')<>''"); StrSql.AppendLine(" Then Convert(Varchar(10),W.CompleteDate,103) Else '' End As CompleteDate"); StrSql.AppendLine(",W.CompleteTime,W.Remark"); StrSql.AppendLine("From WorkAssDet W"); StrSql.AppendLine("Left Join Emp_Mast PL On PL.Id=W.PrjLedId"); StrSql.AppendLine("Left Join Emp_Mast E On E.Id=W.EmpId"); StrSql.AppendLine("Left Join Project_Mast P On P.Id=W.PrjId"); StrSql.AppendLine("Left Join Client_Mast CM On CM.Id=P.ClientId"); StrSql.AppendLine("Left Join Project_Module M On M.Id=W.PrjModId"); StrSql.AppendLine("Where W.Id=" + int.Parse(HidFldId.Value)); dtTemp = new DataTable(); dtTemp = SqlFunc.ExecuteDataTable(StrSql.ToString()); if (dtTemp.Rows.Count == 0) { LblMsg.Text = "Data not found"; return; } DDLPrjLed.Items.Clear(); DDLPrjLed.DataSource = BLayer.FillEmp(0, " And IsNull(EmpGroup,'')='Ledger'"); DDLPrjLed.DataValueField = "EmpId"; DDLPrjLed.DataTextField = "EmpName"; DDLPrjLed.DataBind(); DDLPrjLed.Items.Insert(0, new ListItem("--Select Ledger--", "0")); DDLPrjName.Items.Clear(); DDLPrjName.DataSource = BLayer.FillProject(""); DDLPrjName.DataValueField = "PrjId"; DDLPrjName.DataTextField = "PrjName"; DDLPrjName.DataBind(); DDLPrjName.Items.Insert(0, new ListItem("--Select Project--", "0")); DDLPrjModule.Items.Clear(); DDLPrjModule.DataSource = BLayer.FillPrjModule(int.Parse(DDLPrjName.SelectedValue)); DDLPrjModule.DataValueField = "ModId"; DDLPrjModule.DataTextField = "ModName"; DDLPrjModule.DataBind(); DDLPrjModule.Items.Insert(0, new ListItem("--Select Module--", "0")); int IntEmpId = 0; if (ViewState["LoginUserGroup"].ToString() == "EMP") { IntEmpId = int.Parse(ViewState["LoginId"].ToString()); ddlEmployee.Enabled = false; } ddlEmployee.Items.Clear(); ddlEmployee.DataSource = BLayer.FillEmp(0, ""); ddlEmployee.DataValueField = "EmpId"; ddlEmployee.DataTextField = "EmpName"; ddlEmployee.DataBind(); ddlEmployee.Items.Insert(0, new ListItem("--Select Employee--", "0")); if (dtTemp.Rows[0]["PrjLedId"].ToString() != "") { DDLPrjLed.SelectedValue = dtTemp.Rows[0]["PrjLedId"].ToString(); } if (dtTemp.Rows[0]["PrjId"].ToString() != "") { DDLPrjName.SelectedValue = dtTemp.Rows[0]["PrjId"].ToString(); } if (dtTemp.Rows[0]["PrjModId"].ToString() != "") { DDLPrjModule.SelectedValue = dtTemp.Rows[0]["PrjModId"].ToString(); } if (dtTemp.Rows[0]["EmpId"].ToString() != "") { ddlEmployee.SelectedValue = dtTemp.Rows[0]["EmpId"].ToString(); } TxtClientName.Text = dtTemp.Rows[0]["ClientName"].ToString(); TxtAssignDate.Text = dtTemp.Rows[0]["AssignDate"].ToString(); TxtAssignTime.Text = dtTemp.Rows[0]["AssignTime"].ToString(); TxtDueDays.Text = dtTemp.Rows[0]["DueDays"].ToString(); TxtDueDate.Text = dtTemp.Rows[0]["DueDate"].ToString(); TxtWrkDetails1.Text = dtTemp.Rows[0]["WorkDet1"].ToString(); TxtWrkDetails2.Text = dtTemp.Rows[0]["WorkDet2"].ToString(); TxtWrkDetails3.Text = dtTemp.Rows[0]["WorkDet3"].ToString(); //ddlWrkStatus.Text = dtTemp.Rows[0]["WorkStatus"].ToString(); if (dtTemp.Rows[0]["WorkStatus"].ToString() != "") { ddlWrkStatus.SelectedValue = dtTemp.Rows[0]["WorkStatus"].ToString(); } TxtCompleteDate.Text = dtTemp.Rows[0]["CompleteDate"].ToString(); TxtCompleteTime.Text = dtTemp.Rows[0]["CompleteTime"].ToString(); TxtRemark.Text = dtTemp.Rows[0]["Remark"].ToString(); // Move to Edit Tab MyMenu.Items[0].ImageUrl = "~/Images/ViewDisable.jpg"; MyMenu.Items[1].ImageUrl = "~/Images/NewOrEditEnable.jpg"; MyMenu.Items[1].Selected = true; MyMultiView.ActiveViewIndex = 1; } catch (Exception ex) { Response.Write(ex.ToString()); } }
protected void ClearAll() { try { LblMsg.Text = ""; HidFldId.Value = ""; DDLPrjLed.Enabled = true; DDLPrjLed.Items.Clear(); DDLPrjLed.DataSource = BLayer.FillEmp(0, " And IsNull(EmpGroup,'')='Ledger'"); DDLPrjLed.DataValueField = "EmpId"; DDLPrjLed.DataTextField = "EmpName"; DDLPrjLed.DataBind(); DDLPrjLed.Items.Insert(0, new ListItem("--Select Ledger--", "0")); DDLPrjName.Items.Clear(); DDLPrjName.DataSource = BLayer.FillProject(""); DDLPrjName.DataValueField = "PrjId"; DDLPrjName.DataTextField = "PrjName"; DDLPrjName.DataBind(); DDLPrjName.Items.Insert(0, new ListItem("--Select Project--", "0")); DDLPrjModule.Items.Clear(); DDLPrjModule.Items.Add("---Select Module---"); int IntEmpId = 0; if (ViewState["LoginUserGroup"].ToString() == "EMP") { IntEmpId = int.Parse(ViewState["LoginId"].ToString()); ddlEmployee.Enabled = false; } else { ddlEmployee.Enabled = true; } ddlEmployee.Items.Clear(); ddlEmployee.DataSource = BLayer.FillEmp(IntEmpId, ""); ddlEmployee.DataValueField = "EmpId"; ddlEmployee.DataTextField = "EmpName"; ddlEmployee.DataBind(); if (IntEmpId == 0) { ddlEmployee.Items.Insert(0, new ListItem("--Select Employee--", "0")); } TxtClientName.Text = ""; TxtAssignDate.Text = ""; TxtAssignTime.Text = ""; TxtDueDays.Text = ""; TxtDueDate.Text = ""; TxtWrkDetails1.Text = ""; TxtWrkDetails2.Text = ""; TxtWrkDetails3.Text = ""; ddlWrkStatus.SelectedIndex = 0; TxtCompleteDate.Text = ""; TxtCompleteTime.Text = ""; TxtRemark.Text = ""; } catch (Exception ex) { Response.Write(ex.ToString()); } }