public SalaryDetails GetMonthlySalaryByEmpId(string empid, string month, string year, string numberOfDays)
        {
            DbConnectionManager connect = new DbConnectionManager();
            SqlConnection       conn    = connect.connectToDb();
            string     salaryQuery      = "select * from monthlySalary where emp_id = " + empid + " and month = '" + year + "/" + month + "/" + numberOfDays + " 00:00:00.000'";
            SqlCommand cmd = new SqlCommand(salaryQuery);

            cmd.Connection = conn;
            SqlDataAdapter da = new SqlDataAdapter();

            da.SelectCommand = cmd;
            DataSet ds = new DataSet();

            da.Fill(ds, "monthlySalary");
            List <SalaryDetails> salaryArtifactList = new List <SalaryDetails>();

            SalaryDetails      salary        = new SalaryDetails();
            AttendanceArtifact selectedMonth = new AttendanceArtifact();

            foreach (DataRow dr in ds.Tables["monthlySalary"].Rows)
            {
                salary.Id            = int.Parse(empid);
                salary.MonthlySalary = float.Parse(dr["monthlySalary"].ToString());
                salary.Allowance     = float.Parse(dr["allowance"].ToString());
                salary.Insurance     = float.Parse(dr["insurance"].ToString());
                salary.NetSalary     = float.Parse(dr["netSalary"].ToString());

                salaryArtifactList.Add(salary);
            }
            return(salary);
        }
コード例 #2
0
        private void show_button_Click(object sender, EventArgs e)
        {
            AttendanceArtifact attendance = new AttendanceArtifact();

            Month selectedmonth = (Month)selectMonth_combobox.SelectedItem;

            List<AttendanceArtifact> list = new List<AttendanceArtifact>();
            list = attendance.GetAttendanceCount(selectedmonth.Id.ToString(),selectYear_combobox.SelectedItem.ToString(),selectedmonth.NumberOfDays.ToString());
            dataGridView1.DataSource = list;
        }
        public List <SalaryDetails> GetMonthlySalaryDetails(string month, string year, string numberOfDays)
        {
            DbConnectionManager connect = new DbConnectionManager();
            SqlConnection       conn    = connect.connectToDb();
            string     employeeQuery    = "select * from employee ";
            SqlCommand cmd = new SqlCommand(employeeQuery);

            cmd.Connection = conn;
            SqlDataAdapter da = new SqlDataAdapter();

            da.SelectCommand = cmd;
            DataSet ds = new DataSet();

            da.Fill(ds, "employee");
            List <SalaryDetails> monthlySalaryDetails = new List <SalaryDetails>();

            foreach (DataRow dr in ds.Tables["employee"].Rows)
            {
                string empid = (dr["id"].ToString());

                SalaryDetails      salary        = new SalaryDetails();
                AttendanceArtifact selectedMonth = new AttendanceArtifact();

                SalaryDetails tempObj = salary.GetSalaryCredentialsByEmpId(empid);
                salary.FirstName       = dr["fname"].ToString();
                salary.MiddleName      = dr["middlename"].ToString();
                salary.LastName        = dr["lname"].ToString();
                salary.Designation     = dr["designation"].ToString();
                salary.Id              = int.Parse(empid);
                salary.BasicSalary     = tempObj.BasicSalary;
                salary.NoOfPresentDays = int.Parse(selectedMonth.GetAttendanceCountByEmpID(empid, month, year, numberOfDays));
                salary.MonthlySalary   = (salary.BasicSalary * salary.NoOfPresentDays);
                salary.Allowance       = (salary.MonthlySalary * (tempObj.Allowance / 100));
                salary.Insurance       = (salary.MonthlySalary * (tempObj.Insurance / 100));
                salary.NetSalary       = (salary.MonthlySalary + salary.Allowance - salary.Insurance);
                monthlySalaryDetails.Add(salary);

                string     redundantCheckQuery = "select * from monthlySalary where emp_id = " + int.Parse(empid) + " and month = '" + year + "/" + month + "/" + numberOfDays + " 00:00:00.000'";
                SqlCommand cmd1 = new SqlCommand(redundantCheckQuery);
                cmd1.Connection = conn;
                SqlDataAdapter da1 = new SqlDataAdapter();
                da1.SelectCommand = cmd1;
                DataSet ds1 = new DataSet();
                da1.Fill(ds1, "monthlySalary");
                if (ds1.Tables["monthlySalary"].Rows.Count == 0)
                {
                    string     salaryQuery = "insert into monthlySalary(emp_id,month,monthlySalary,allowance,insurance,netSalary) values( " + int.Parse(empid) + ",'" + year + "/" + month + "/" + numberOfDays + " 00:00:00.000' ," + salary.MonthlySalary + "," + salary.Allowance + "," + salary.Insurance + "," + salary.NetSalary + ")";
                    SqlCommand command     = new SqlCommand(salaryQuery);
                    command.Connection = conn;
                    command.ExecuteNonQuery();
                }
            }
            connect.diconnectFromDb(conn);
            return(monthlySalaryDetails);
        }
        private void show_button_Click(object sender, EventArgs e)
        {
            AttendanceArtifact attendance = new AttendanceArtifact();

            Month selectedmonth = (Month)selectMonth_combobox.SelectedItem;

            List <AttendanceArtifact> list = new List <AttendanceArtifact>();

            list = attendance.GetAttendanceCount(selectedmonth.Id.ToString(), selectYear_combobox.SelectedItem.ToString(), selectedmonth.NumberOfDays.ToString());
            dataGridView1.DataSource = list;
        }
        public List <AttendanceArtifact> GetAttendanceCount(string month, string year, string numberOfDays)
        {
            DbConnectionManager connect = new DbConnectionManager();
            SqlConnection       conn    = connect.connectToDb();

            string noOfDays = numberOfDays;

            string     employeeQuery = "select * from employee ";
            SqlCommand cmd           = new SqlCommand(employeeQuery);

            cmd.Connection = conn;
            SqlDataAdapter da = new SqlDataAdapter();

            da.SelectCommand = cmd;
            DataSet ds = new DataSet();

            da.Fill(ds, "employee");
            List <AttendanceArtifact> attendanceArtifactList = new List <AttendanceArtifact>();

            foreach (DataRow dr in ds.Tables["employee"].Rows)
            {
                string     empid           = (dr["id"].ToString());
                string     attendanceQuery = "select * from attendance where employee_id = " + empid + " and attendance_date between '" + year + "/" + month + "/1 00:00:00.000' and '" + year + "/" + month + "/" + noOfDays + " 00:00:00.000' and present = 'True'";
                SqlCommand cmd1            = new SqlCommand(attendanceQuery);
                cmd1.Connection = conn;
                SqlDataAdapter da1 = new SqlDataAdapter();
                da1.SelectCommand = cmd1;
                DataSet ds1 = new DataSet();
                da1.Fill(ds1, "attendance");

                AttendanceArtifact attendance = new AttendanceArtifact();

                attendance.Id                  = int.Parse(empid);
                attendance.FirstName           = dr["fname"].ToString();
                attendance.MiddleName          = dr["middlename"].ToString();
                attendance.LastName            = dr["lname"].ToString();
                attendance.Designation         = dr["designation"].ToString();
                attendance.ContactDetails      = dr["contactdetails"].ToString();
                attendance.NumberOfPresentDays = ds1.Tables["attendance"].Rows.Count.ToString();
                attendanceArtifactList.Add(attendance);
                connect.diconnectFromDb(conn);
            }
            return(attendanceArtifactList);
        }
コード例 #6
0
        public List<AttendanceArtifact> GetAttendanceCount(string month, string year, string numberOfDays)
        {
            DbConnectionManager connect = new DbConnectionManager();
            SqlConnection conn = connect.connectToDb();

            string noOfDays = numberOfDays;

            string employeeQuery = "select * from employee ";
            SqlCommand cmd = new SqlCommand(employeeQuery);
            cmd.Connection = conn;
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            DataSet ds = new DataSet();
            da.Fill(ds, "employee");
            List<AttendanceArtifact> attendanceArtifactList = new List<AttendanceArtifact>();
            foreach (DataRow dr in ds.Tables["employee"].Rows)
            {
                string empid = (dr["id"].ToString());
                string attendanceQuery = "select * from attendance where employee_id = " + empid + " and attendance_date between '" + year + "/" + month + "/1 00:00:00.000' and '" + year + "/" + month + "/" + noOfDays + " 00:00:00.000' and present = 'True'";
                SqlCommand cmd1 = new SqlCommand(attendanceQuery);
                cmd1.Connection = conn;
                SqlDataAdapter da1 = new SqlDataAdapter();
                da1.SelectCommand = cmd1;
                DataSet ds1 = new DataSet();
                da1.Fill(ds1, "attendance");

                AttendanceArtifact attendance = new AttendanceArtifact();

                attendance.Id = int.Parse(empid);
                attendance.FirstName = dr["fname"].ToString();
                attendance.MiddleName = dr["middlename"].ToString();
                attendance.LastName = dr["lname"].ToString();
                attendance.Designation = dr["designation"].ToString();
                attendance.ContactDetails = dr["contactdetails"].ToString();
                attendance.NumberOfPresentDays = ds1.Tables["attendance"].Rows.Count.ToString();
                attendanceArtifactList.Add(attendance);
                connect.diconnectFromDb(conn);

            }
            return attendanceArtifactList;
        }
コード例 #7
0
        public SalaryDetails GetMonthlySalaryByEmpId(string empid, string month, string year, string numberOfDays)
        {
            DbConnectionManager connect = new DbConnectionManager();
            SqlConnection conn = connect.connectToDb();
            string salaryQuery = "select * from monthlySalary where emp_id = " + empid + " and month = '" + year + "/" + month + "/"+numberOfDays+" 00:00:00.000'";
            SqlCommand cmd = new SqlCommand(salaryQuery);
            cmd.Connection = conn;
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            DataSet ds = new DataSet();
            da.Fill(ds, "monthlySalary");
            List<SalaryDetails> salaryArtifactList = new List<SalaryDetails>();

            SalaryDetails salary = new SalaryDetails();
            AttendanceArtifact selectedMonth = new AttendanceArtifact();
            foreach (DataRow dr in ds.Tables["monthlySalary"].Rows)
            {
                salary.Id = int.Parse(empid);
                salary.MonthlySalary = float.Parse(dr["monthlySalary"].ToString());
                salary.Allowance = float.Parse(dr["allowance"].ToString());
                salary.Insurance = float.Parse(dr["insurance"].ToString());
                salary.NetSalary = float.Parse(dr["netSalary"].ToString());

                salaryArtifactList.Add(salary);

            }
            return salary;
        }
コード例 #8
0
        public List<SalaryDetails> GetMonthlySalaryDetails(string month, string year, string numberOfDays)
        {
            DbConnectionManager connect = new DbConnectionManager();
            SqlConnection conn = connect.connectToDb();
                       string employeeQuery = "select * from employee ";
            SqlCommand cmd = new SqlCommand(employeeQuery);
            cmd.Connection = conn;
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            DataSet ds = new DataSet();
            da.Fill(ds, "employee");
            List<SalaryDetails> monthlySalaryDetails = new List<SalaryDetails>();
            foreach (DataRow dr in ds.Tables["employee"].Rows)
            {

                string empid = (dr["id"].ToString());

                SalaryDetails salary = new SalaryDetails();
                AttendanceArtifact selectedMonth = new AttendanceArtifact();

                SalaryDetails tempObj = salary.GetSalaryCredentialsByEmpId(empid);
                salary.FirstName = dr["fname"].ToString();
                salary.MiddleName = dr["middlename"].ToString();
                salary.LastName = dr["lname"].ToString();
                salary.Designation = dr["designation"].ToString();
                salary.Id = int.Parse(empid);
                salary.BasicSalary = tempObj.BasicSalary;
                salary.NoOfPresentDays = int.Parse(selectedMonth.GetAttendanceCountByEmpID(empid, month, year, numberOfDays));
                salary.MonthlySalary = (salary.BasicSalary * salary.NoOfPresentDays);
                salary.Allowance = (salary.MonthlySalary * (tempObj.Allowance / 100));
                salary.Insurance = (salary.MonthlySalary * (tempObj.Insurance/100));
                salary.NetSalary = (salary.MonthlySalary + salary.Allowance - salary.Insurance);
                monthlySalaryDetails.Add(salary);

                string redundantCheckQuery = "select * from monthlySalary where emp_id = " + int.Parse(empid) + " and month = '" + year + "/" + month + "/" + numberOfDays + " 00:00:00.000'";
                SqlCommand cmd1 = new SqlCommand(redundantCheckQuery);
                cmd1.Connection = conn;
                SqlDataAdapter da1 = new SqlDataAdapter();
                da1.SelectCommand = cmd1;
                DataSet ds1 = new DataSet();
                da1.Fill(ds1, "monthlySalary");
                if (ds1.Tables["monthlySalary"].Rows.Count == 0)
                {
                    string salaryQuery = "insert into monthlySalary(emp_id,month,monthlySalary,allowance,insurance,netSalary) values( " + int.Parse(empid) + ",'" + year + "/" + month + "/" + numberOfDays + " 00:00:00.000' ," +salary.MonthlySalary+","+salary.Allowance+","+salary.Insurance+","+ salary.NetSalary + ")";
                    SqlCommand command = new SqlCommand(salaryQuery);
                    command.Connection = conn;
                    command.ExecuteNonQuery();

                }
            }
            connect.diconnectFromDb(conn);
            return monthlySalaryDetails;
        }