示例#1
0
        private void EmployeeLoyaltyPoint_GetAll()
        {
            DataTable dtEmployeePoint = new Business.HR.EmployeeLoyaltyPoint().EmployeeLoyaltyPoint_GetAll(ddlMonth.SelectedValue, int.Parse(ddlYear.SelectedValue));

            gvEmployeePoint.DataSource = dtEmployeePoint;
            gvEmployeePoint.DataBind();
        }
        private void IndividualLoyalityPoint_ByEmployeeId()
        {
            DataTable dtEmployeePoint = new Business.HR.EmployeeLoyaltyPoint().IndividualLoyalityPoint_ByEmployeeId(int.Parse(HttpContext.Current.User.Identity.Name));
            DataTable dtList          = dtEmployeePoint.Clone();

            if (DateTime.Now.Month == 1 || DateTime.Now.Month == 2 || DateTime.Now.Month == 3)
            {
                foreach (DataRow drItem in new Business.HR.EmployeeLoyaltyPoint().LoyalityPointFromJanuary(dtEmployeePoint).Rows)
                {
                    dtList.ImportRow(drItem);
                }
            }
            else
            {
                foreach (DataRow drItem in new Business.HR.EmployeeLoyaltyPoint().LoyalityPointBeforeJanuary(dtEmployeePoint).Rows)
                {
                    dtList.ImportRow(drItem);
                }
            }
            if (dtList.AsEnumerable().Any())
            {
                gvLoyalityPoint.DataSource = dtList;
            }
            else
            {
                gvLoyalityPoint.DataSource = null;
            }
            gvLoyalityPoint.DataBind();
        }
        private decimal IndividualLoyalityPoint_ByEmployeeId(int userId)
        {
            DataTable dtEmployeePoint = new Business.HR.EmployeeLoyaltyPoint().IndividualLoyalityPoint_ByEmployeeId(userId);
            decimal   totalPoint      = 0;

            if (DateTime.Now.Month == 1 || DateTime.Now.Month == 2 || DateTime.Now.Month == 3)
            {
                totalPoint = new Business.HR.EmployeeLoyaltyPoint().CalculateLoyalityPointFromJanuary(dtEmployeePoint);
            }
            else
            {
                totalPoint = new Business.HR.EmployeeLoyaltyPoint().CalculateLoyalityPointBeforeJanuary(dtEmployeePoint);
            }
            return(totalPoint);
        }
        private void IndividualLoyalityPoint_ByEmployeeId()
        {
            DataTable dtEmployeePoint = new Business.HR.EmployeeLoyaltyPoint().IndividualLoyalityPoint_ByEmployeeId(int.Parse(HttpContext.Current.User.Identity.Name));
            int       totalPoint      = 0;

            if (DateTime.Now.Month == 1 || DateTime.Now.Month == 2 || DateTime.Now.Month == 3)
            {
                totalPoint = new Business.HR.EmployeeLoyaltyPoint().CalculateLoyalityPointFromJanuary(dtEmployeePoint);
            }
            else
            {
                totalPoint = new Business.HR.EmployeeLoyaltyPoint().CalculateLoyalityPointBeforeJanuary(dtEmployeePoint);
            }
            lblLoyalityPoint.InnerText = string.Concat("(LP:", totalPoint, ")");
        }
        private List <Models.LoyalityPointModel> GetLoyalityPoint(int employeeId)
        {
            List <Models.LoyalityPointModel> model = new List <Models.LoyalityPointModel>();
            DataTable dtEmployeePoint = new Business.HR.EmployeeLoyaltyPoint().IndividualLoyalityPoint_ByEmployeeId(employeeId);
            DataTable dtList          = dtEmployeePoint.Clone();

            if (DateTime.Now.Month == 1 || DateTime.Now.Month == 2 || DateTime.Now.Month == 3)
            {
                foreach (DataRow drItem in new Business.HR.EmployeeLoyaltyPoint().LoyalityPointFromJanuary(dtEmployeePoint).Rows)
                {
                    dtList.ImportRow(drItem);
                }
            }
            else
            {
                foreach (DataRow drItem in new Business.HR.EmployeeLoyaltyPoint().LoyalityPointBeforeJanuary(dtEmployeePoint).Rows)
                {
                    dtList.ImportRow(drItem);
                }
            }
            if (dtList != null &&
                dtList.AsEnumerable().Any())
            {
                foreach (DataRow dr in dtList.Rows)
                {
                    model.Add(new Models.LoyalityPointModel
                    {
                        Month  = string.Format("Assesment Month: {0}", dr["Month"].ToString()),
                        Year   = string.Format("Assesment Year: {0}", dr["Year"].ToString()),
                        Point  = string.Format("Point: {0}", dr["Point"].ToString()),
                        Reason = string.Format("Reason: ", dr["Reason"].ToString())
                    });
                }
            }

            return(model);
        }
示例#6
0
        protected void gvEmployeePoint_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                Business.HR.EmployeeLoyaltyPoint objEmployeeLoyaltyPoint = new Business.HR.EmployeeLoyaltyPoint();

                if (e.CommandName == "E")
                {
                    Entity.HR.EmployeeLoyaltyPoint employeeLoyaltyPoint = new Entity.HR.EmployeeLoyaltyPoint();

                    GridViewRow gvEmployeePoint = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

                    DropDownList ddlLaoyalPointReason = (DropDownList)gvEmployeePoint.FindControl("ddlLaoyalPointReason");
                    TextBox      txtPoint             = (TextBox)gvEmployeePoint.FindControl("txtPoint");
                    TextBox      txtNote = (TextBox)gvEmployeePoint.FindControl("txtNote");


                    employeeLoyaltyPoint.EmployeeId           = int.Parse(e.CommandArgument.ToString());
                    employeeLoyaltyPoint.Month                = ddlMonth.SelectedValue;
                    employeeLoyaltyPoint.Year                 = int.Parse(ddlYear.SelectedValue);
                    employeeLoyaltyPoint.LoyaltyPointReasonId = int.Parse(ddlLaoyalPointReason.SelectedValue);
                    employeeLoyaltyPoint.Point                = (!string.IsNullOrEmpty(txtPoint.Text)) ? decimal.Parse(txtPoint.Text) : 0;
                    employeeLoyaltyPoint.Note                 = txtNote.Text;
                    employeeLoyaltyPoint.CreatedBy            = Convert.ToInt32(HttpContext.Current.User.Identity.Name);

                    if (Validation(employeeLoyaltyPoint.LoyaltyPointReasonId))
                    {
                        int response = objEmployeeLoyaltyPoint.EmployeeLoyaltyPoint_Save(employeeLoyaltyPoint);
                        if (response > 0)
                        {
                            Message1.IsSuccess = true;
                            Message1.Text      = "Employee Loyalty point is updated.";
                        }
                        else
                        {
                            Message1.IsSuccess = false;
                            Message1.Text      = "Sorry! Employee Loyalty point is not updated.";
                        }
                        Message1.Show = true;
                    }
                }
                else if (e.CommandName == "D")
                {
                    GridViewRow gvEmployeePointRow = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
                    long        loyaltyId          = 0;
                    if (long.TryParse(gvEmployeePoint.DataKeys[gvEmployeePointRow.RowIndex].Values[0].ToString(), out loyaltyId))
                    {
                        int response = objEmployeeLoyaltyPoint.EmployeeLoyaltyPoint_Delete(loyaltyId);
                        if (response > 0)
                        {
                            EmployeeLoyaltyPoint_GetAll();
                            Message1.IsSuccess = true;
                            Message1.Text      = "Employee Loyalty point is deleted.";
                        }
                        else
                        {
                            Message1.IsSuccess = false;
                            Message1.Text      = "Sorry! Employee Loyalty point is not deleted.";
                        }
                    }
                    Message1.Show = true;
                }
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message1.IsSuccess = false;
                Message1.Text      = ex.Message;
                Message1.Show      = true;
            }
        }