public void UpdateDelegation(delegation ToUpdateDelegation) { try { delegation delegation = new DataAccess.delegation(); delegation = (from d in entities.delegations where d.DelgID == ToUpdateDelegation.DelgID select d).FirstOrDefault(); if (delegation!=null) { delegation.DelApproveEmpID = ToUpdateDelegation.DelApproveEmpID; delegation.DelgEmpID = ToUpdateDelegation.DelgEmpID; delegation.DelgFromDate = ToUpdateDelegation.DelgFromDate; delegation.DelgStatus = ToUpdateDelegation.DelgStatus; delegation.DelgToDate = ToUpdateDelegation.DelgToDate; entities.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public void SaveNewDelegation(delegation toSaveDelegation) { try { entities.delegations.Add(toSaveDelegation); entities.SaveChanges(); } catch (Exception ex) { throw ex; } }
public delegation SearchDelegationWithDelgEmpIdNApprovedIDNStatusNDate(int DelgEmpId,int approvedId,string status) { try { delegation delegation = new delegation(); DateTime nowTime = DateTime.UtcNow; delegation = (from d in entities.delegations where d.DelgEmpID == DelgEmpId && d.DelApproveEmpID==approvedId && d.DelgStatus==status &&(d.DelgFromDate >= nowTime || nowTime <= d.DelgToDate) select d).FirstOrDefault(); return delegation; } catch (Exception ex) { throw ex; } }
public void SaveNewDelegation(delegation curdel) { _DelegationRepository.SaveNewDelegation(curdel); }
public void UpdateDelegation(delegation ToUpdateDelegation) { _DelegationRepository.UpdateDelegation(ToUpdateDelegation); }
//method to check Dep Head public bool isTempDepHead(string email) { bool ans = false; int id2; delegation delg = new delegation(); List<employee> empl2 = new List<employee>(); employee emp2 = new employee(); var q = from e in se.employees where e.EmployeeEmail == email select e; emp2 = q.FirstOrDefault(); id2 = emp2.EmployeeID; //checking the delegation Table var m = from del in se.delegations where del.DelgEmpID == id2 && del.DelgToDate >= DateTime.Today && del.DelgStatus == "approved" select del; delg = m.FirstOrDefault(); if (delg != null) { ans = true; } else ans = false; return ans; }
public bool searchDelegation() { int LoginId = Convert.ToInt32(Session["userid"].ToString()); currentEmp = new employee(); currentEmp = _EmployeeService.GetEmployeeDetailsByEmpID(LoginId); Currentdelegation = new delegation(); Currentdelegation = _DelegationService.SearchDelegationWithDelgApproveEmpId_Status_Date(LoginId, "approved"); if (Currentdelegation != null) { PanelSubmit.Visible = true; lblDelegated.Text = "You may assign a temporary Department Head."; ddlEmpName.SelectedValue = Currentdelegation.DelgEmpID.ToString(); txtEmpID.Text = Currentdelegation.DelgEmpID.ToString(); currentEmp = new employee(); currentEmp = _EmployeeService.GetEmployeeDetailsByEmpID(Currentdelegation.DelgEmpID); txtEmpContact.Text = currentEmp.EmployeeContact.ToString(); this.FromDate = Currentdelegation.DelgFromDate.ToString("MM/dd/yyyy"); this.ToDate = Currentdelegation.DelgToDate.ToString("MM/dd/yyyy"); BtnEnable(true); return true; } else { BtnEnable(false); return false; } }
protected void EmpName_SelectedIndexChanged(object sender, EventArgs e) { #region ** ClearAll ClearNewAllData(); BtnEnable(false); #endregion #region ** DataBindinEmployeeDetails currentEmp = new employee(); currentEmp = _EmployeeService.GetEmployeeDetailsByEmpID(int.Parse(ddlEmpName.SelectedItem.Value)); if (currentEmp != null) { txtEmpContact.Text = currentEmp.EmployeeContact.ToString(); txtEmpID.Text = ddlEmpName.SelectedItem.Value; } else { PanelError.Visible = true; } #endregion BtnEnable(true); btnResetDelegation.Enabled = false; #region ** CheckDelegationForLoginId int LoginId = Convert.ToInt32(Session["userid"].ToString()); currentEmp = new employee(); currentEmp = _EmployeeService.GetEmployeeDetailsByEmpID(int.Parse(ddlEmpName.SelectedItem.Value)); Currentdelegation = new delegation(); Currentdelegation = _DelegationService.SearchDelegationWithDelgEmpId_ApprovedID_Status_Date(int.Parse(ddlEmpName.SelectedItem.Value), LoginId,"approved"); if (Currentdelegation != null) { PanelSubmit.Visible = true; lblDelegated.Text = "You may assign a temporary Department Head."; ddlEmpName.SelectedValue = Currentdelegation.DelgEmpID.ToString(); txtEmpID.Text = Currentdelegation.DelgEmpID.ToString(); txtEmpContact.Text = currentEmp.EmployeeContact.ToString(); this.FromDate = Currentdelegation.DelgFromDate.ToString("MM/dd/yyyy"); this.ToDate = Currentdelegation.DelgToDate.ToString("MM/dd/yyyy"); btnResetDelegation.Enabled = true; btnSubmitDeligation.Enabled = true; } #endregion }
protected void btnSubmitDeligation_Click(object sender, EventArgs e) { int LoginId = Convert.ToInt32(Session["userid"].ToString()); //Check Is there have Delegation Firstly delegation Firstdelegation = new delegation(); Firstdelegation = _DelegationService.SearchDelegationWithDelgApproveEmpId_Status_Date(LoginId, "approved"); //Check Is there have Delegation for dropdownlist Currentdelegation = new delegation(); Currentdelegation = _DelegationService.SearchDelegationWithDelgEmpId_ApprovedID_Status_Date(int.Parse(ddlEmpName.SelectedValue), LoginId, "approved"); #region ** Bind data to update or save delegation delegation ToUpdateDelegation = new delegation(); ToUpdateDelegation.DelgEmpID = int.Parse(ddlEmpName.SelectedItem.Value); ToUpdateDelegation.DelgStatus = "approved"; ToUpdateDelegation.DelApproveEmpID = LoginId; string fromdate_txt = Page.Request.Form["dpd1"].ToString(); String[] FromDateArr = fromdate_txt.Split('/'); Fromyear = Int32.Parse(FromDateArr[2]); Frommonth = Int32.Parse(FromDateArr[0]); Fromday = Int32.Parse(FromDateArr[1]); DateTime FromDateTime = new DateTime(Fromyear, Frommonth, Fromday); ToUpdateDelegation.DelgFromDate = FromDateTime; string todate_txt = Page.Request.Form["dpd2"].ToString(); String[] ToDateArr = todate_txt.Split('/'); Toyear = Int32.Parse(ToDateArr[2]); Tomonth = Int32.Parse(ToDateArr[0]); Today = Int32.Parse(ToDateArr[1]); DateTime ToDateTime = new DateTime(Toyear, Tomonth, Today); ToUpdateDelegation.DelgToDate = ToDateTime; #endregion // Save if (Firstdelegation == null && Currentdelegation==null) { _DelegationService.SaveNewDelegation(ToUpdateDelegation); ClearNewAllData(); BtnEnable(false); PanelSubmit.Visible = true; } // Update else if (Firstdelegation != null && Firstdelegation.DelgEmpID == int.Parse(ddlEmpName.SelectedValue) && Currentdelegation!=null) { ToUpdateDelegation.DelgID = Currentdelegation.DelgID; _DelegationService.UpdateDelegation(ToUpdateDelegation); ClearNewAllData(); BtnEnable(false); PanelSubmit.Visible = true; } else { ClearNewAllData(); BtnEnable(false); PanelErrorSave.Visible = true; lblErrorSave.Text = "The Temporay Department Head has already been assigned."; } }
protected void btnResetDelegation_Click(object sender, EventArgs e) { int LoginId = Convert.ToInt32(Session["userid"].ToString()); Currentdelegation = new delegation(); Currentdelegation = _DelegationService.SearchDelegationWithDelgEmpId_ApprovedID_Status_Date(int.Parse(ddlEmpName.SelectedValue), LoginId, "approved"); delegation ToUpdateDelegation = new delegation(); ToUpdateDelegation.DelgID = Currentdelegation.DelgID; ToUpdateDelegation.DelApproveEmpID = Currentdelegation.DelApproveEmpID; ToUpdateDelegation.DelgEmpID = Currentdelegation.DelgEmpID; ToUpdateDelegation.DelgFromDate = Currentdelegation.DelgFromDate; ToUpdateDelegation.DelgToDate = Currentdelegation.DelgToDate; ToUpdateDelegation.DelgStatus = "cancel"; _DelegationService.UpdateDelegation(ToUpdateDelegation); ClearNewAllData(); BtnEnable(false); PanelCancel.Visible = true; }