public List <SalaryModel> GetEmployeeSalReport(int EmployeeId, DateTime FromDate, DateTime ToDate)
        {
            EmployeeEntities   db        = new EmployeeEntities();
            List <SalaryModel> lstSalary = new List <SalaryModel>();

            //// By using Stored Procedure
            try
            {
                DataTable dtTable = new DataTable();
                using (var cmd = db.Database.Connection.CreateCommand())
                {
                    db.Database.Connection.Open();
                    cmd.CommandText = "usp_GetEmployeeSalReport";
                    cmd.CommandType = CommandType.StoredProcedure;

                    DbParameter paramName = cmd.CreateParameter();
                    paramName.ParameterName = "EmployeeId";
                    paramName.Value         = EmployeeId;
                    cmd.Parameters.Add(paramName);

                    DbParameter paramFromDate = cmd.CreateParameter();
                    paramFromDate.ParameterName = "FromDate";
                    paramFromDate.Value         = FromDate;
                    cmd.Parameters.Add(paramFromDate);

                    DbParameter paramToDate = cmd.CreateParameter();
                    paramToDate.ParameterName = "ToDate";
                    paramToDate.Value         = ToDate;
                    cmd.Parameters.Add(paramToDate);

                    DbDataAdapter da = DbProviderFactories.GetFactory("System.Data.SqlClient").CreateDataAdapter();
                    da.SelectCommand = cmd;
                    da.Fill(dtTable);
                    db.Database.Connection.Close();
                }
                foreach (DataRow dr in dtTable.Rows)
                {
                    SalaryModel blmodel = new SalaryModel();
                    blmodel.TransactionId = Convert.ToInt32(dr["TransactionId"].ToString());
                    blmodel.Salary        = Convert.ToDecimal(dr["Salary"]);
                    blmodel.EmployeeId    = Convert.ToInt32(dr["EmployeeId"].ToString());
                    blmodel.FirstName     = dr["FirstName"].ToString();
                    blmodel.LastName      = dr["LastName"].ToString();
                    blmodel.SalaryMonth   = dr["SalaryMonth"].ToString();

                    lstSalary.Add(blmodel);
                }
            }
            catch (Exception ex)
            {
                db.Database.Connection.Close();
                throw ex;
            }

            db.Dispose();
            return(lstSalary);
        }
        public string SaveSalary(SalaryModel model)
        {
            string           message = "";
            EmployeeEntities db      = new EmployeeEntities();
            var saveSalary           = new tbl_employeeSalary()
            {
                EmployeeId      = model.EmployeeId,
                Salary          = model.Salary,
                TransactionDate = DateTime.Now,
                SalaryMonth     = model.SalaryMonth,
            };

            db.tbl_employeeSalary.Add(saveSalary);
            db.SaveChanges();
            message = "Salary Added for Employee Succesfully";
            return(message);
        }