Пример #1
0
        public void Update(SalaryUpdate salaryUpdate)
        {
            try
            {
                using (var em = EntityManagerFactory.CreateInstance(ds))
                {
                    string[] columns = { "EffectiveDate", "BranchId",         "GradeId",        "OccupationId",
                                         "UpdateType",    "MainSalary",       "LunchAllowance", "TransportAllowance",
                                         "FuelAllowance", "VehicleAllowance", "Notes",          "CreatedDate",       "CreatedBy",
                                         "ModifiedDate",  "ModifiedBy" };

                    object[] values = { salaryUpdate.EffectiveDate.ToShortDateString(), salaryUpdate.BranchId,
                                        salaryUpdate.GradeId,                           salaryUpdate.OccupationId,    salaryUpdate.UpdateType,
                                        salaryUpdate.MainSalary,                        salaryUpdate.LunchAllowance,  salaryUpdate.TransportAllowance,
                                        salaryUpdate.FuelAllowance,                     salaryUpdate.VehicleAllowance,salaryUpdate.Notes,
                                        DateTime.Now.ToShortDateString(),               Store.ActiveUser,             DateTime.Now.ToShortDateString(),
                                        Store.ActiveUser };

                    var q = new Query().Select(columns).From(tableName).Update(values)
                            .Where("ID").Equal(salaryUpdate.ID);

                    em.ExecuteNonQuery(q.ToSql());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        private void RenderSalaryUpdate(SalaryUpdate salaryUpdate)
        {
            var item = new ListViewItem(salaryUpdate.ID.ToString());

            item.SubItems.Add(salaryUpdate.EffectiveDate.ToString("dd/MM/yyyy"));
            item.SubItems.Add(salaryUpdate.BranchName);
            item.SubItems.Add(salaryUpdate.GradeName);
            item.SubItems.Add(salaryUpdate.OccupationName);

            if (salaryUpdate.UpdateType == 1)
            {
                item.SubItems.Add("Persen");
            }
            else
            {
                item.SubItems.Add("Nilai");
            }

            item.SubItems.Add(salaryUpdate.MainSalary.ToString("N0").Replace(",", "."));
            item.SubItems.Add(salaryUpdate.LunchAllowance.ToString("N0").Replace(",", "."));
            item.SubItems.Add(salaryUpdate.TransportAllowance.ToString("N0").Replace(",", "."));
            item.SubItems.Add(salaryUpdate.FuelAllowance.ToString("N0").Replace(",", "."));
            item.SubItems.Add(salaryUpdate.VehicleAllowance.ToString("N0").Replace(",", "."));


            lvwData.Items.Add(item);
        }
Пример #3
0
        public SalaryUpdate GetById(Guid id)
        {
            SalaryUpdate salaryUpdate = null;

            using (var em = EntityManagerFactory.CreateInstance(ds))
            {
                string sql = "SELECT su.*, b.BranchName, g.GradeName, o.OccupationName FROM "
                             + "((SalaryUpdate su LEFT JOIN Branch b ON su.BranchId = b.ID) "
                             + "LEFT JOIN Grade g ON su.GradeId = g.ID) LEFT JOIN Occupation o "
                             + "ON su.OccupationId = o.ID "
                             + "WHERE su.ID='{" + id + "}'";

                salaryUpdate = em.ExecuteObject <SalaryUpdate>(sql, new SalaryUpdateMapper());
            }

            return(salaryUpdate);
        }
Пример #4
0
        private void ViewSalaryUpdateDetail(SalaryUpdate salaryUpdate)
        {
            dtpEffectiveDate.Value = salaryUpdate.EffectiveDate;

            cboBranch.Text     = salaryUpdate.BranchName;
            cboGrade.Text      = salaryUpdate.GradeName;
            cboOccupation.Text = salaryUpdate.OccupationName;

            if (salaryUpdate.UpdateType == 1)
            {
                rbPercentage.Checked = true;
            }
            else
            {
                rbValue.Checked = true;
            }

            txtSalaryMain.Text         = salaryUpdate.MainSalary == 0?"0":salaryUpdate.MainSalary.ToString();
            txtLunchAllowance.Text     = salaryUpdate.LunchAllowance == 0?"0":salaryUpdate.LunchAllowance.ToString();
            txtTransportAllowance.Text = salaryUpdate.TransportAllowance == 0?"0":salaryUpdate.TransportAllowance.ToString();
            txtFuelAllowance.Text      = salaryUpdate.FuelAllowance == 0?"0":salaryUpdate.FuelAllowance.ToString();
            txtVehicleAllowance.Text   = salaryUpdate.VehicleAllowance == 0?"0":salaryUpdate.VehicleAllowance.ToString();
        }
Пример #5
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (chkBranch.Checked == false && chkGrade.Checked == false && chkOccupation.Checked == false)
            {
                MessageBox.Show("Kriteria belum dipilih (cabang/pangkat/jabatan)", "Perhatian",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                var employees = employeeRepository.GetByIds(new Guid(txtBranchId.Text),
                                                            new Guid(txtGradeId.Text), new Guid(txtOccupationId.Text));


                if (employees.Count != 0)
                {
                    foreach (var employee in employees)
                    {
                        var employeeSalary = new EmployeeSalary();

                        employeeSalary.EmployeeId    = employee.ID;
                        employeeSalary.EffectiveDate = dtpEffectiveDate.Value;
                        employeeSalary.OccupationAllowancePerMonth    = employee.LastSalary.OccupationAllowancePerMonth;
                        employeeSalary.FixedAllowancePerMonth         = employee.LastSalary.FixedAllowancePerMonth;
                        employeeSalary.HealthAllowancePerMonth        = employee.LastSalary.HealthAllowancePerMonth;
                        employeeSalary.CommunicationAllowancePerMonth = employee.LastSalary.CommunicationAllowancePerMonth;
                        employeeSalary.SupervisionAllowancePerMonth   = employee.LastSalary.SupervisionAllowancePerMonth;
                        employeeSalary.OtherAllowance = employee.LastSalary.OtherAllowance;
                        employeeSalary.OtherFee       = employee.LastSalary.OtherFee;

                        if (rbPercentage.Checked)
                        {
                            employeeSalary.MainSalary                     = txtSalaryMain.Text == ""?0 : Math.Floor(employee.LastSalary.MainSalary * decimal.Parse(txtSalaryMain.Text) / 100) + employee.LastSalary.MainSalary;
                            employeeSalary.FuelAllowancePerDays           = txtFuelAllowance.Text == ""?0: Math.Floor(employee.LastSalary.FuelAllowancePerDays * decimal.Parse(txtFuelAllowance.Text) / 100) + employee.LastSalary.FuelAllowancePerDays;
                            employeeSalary.VehicleAllowancePerDays        = txtVehicleAllowance.Text == ""?0:Math.Floor(employee.LastSalary.VehicleAllowancePerDays * decimal.Parse(txtVehicleAllowance.Text) / 100) + employee.LastSalary.VehicleAllowancePerDays;
                            employeeSalary.LunchAllowancePerDays          = txtLunchAllowance.Text == ""?0:Math.Floor(employee.LastSalary.LunchAllowancePerDays * decimal.Parse(txtLunchAllowance.Text) / 100) + employee.LastSalary.LunchAllowancePerDays;
                            employeeSalary.TransportationAllowancePerDays = txtTransportAllowance.Text == ""?0:Math.Floor(employee.LastSalary.TransportationAllowancePerDays * decimal.Parse(txtTransportAllowance.Text) / 100) + employee.LastSalary.TransportationAllowancePerDays;
                        }
                        else if (rbValue.Checked)
                        {
                            employeeSalary.MainSalary                     = txtSalaryMain.Text == "" ? 0 : decimal.Parse(txtSalaryMain.Text.Replace(".", "")) + employee.LastSalary.MainSalary;
                            employeeSalary.FuelAllowancePerDays           = txtFuelAllowance.Text == "" ? 0 : decimal.Parse(txtFuelAllowance.Text.Replace(".", "")) + employee.LastSalary.FuelAllowancePerDays;
                            employeeSalary.VehicleAllowancePerDays        = txtVehicleAllowance.Text == "" ? 0 : decimal.Parse(txtVehicleAllowance.Text.Replace(".", "")) + employee.LastSalary.VehicleAllowancePerDays;
                            employeeSalary.LunchAllowancePerDays          = txtLunchAllowance.Text == "" ? 0 : decimal.Parse(txtLunchAllowance.Text.Replace(".", "")) + employee.LastSalary.LunchAllowancePerDays;
                            employeeSalary.TransportationAllowancePerDays = txtTransportAllowance.Text == "" ? 0 : decimal.Parse(txtTransportAllowance.Text.Replace(".", "")) + employee.LastSalary.TransportationAllowancePerDays;
                        }

                        employeeSalaryRepository.Save(employeeSalary);
                    }

                    var salaryUpdate = new SalaryUpdate();

                    salaryUpdate.EffectiveDate = dtpEffectiveDate.Value;
                    salaryUpdate.BranchId      = new Guid(txtBranchId.Text);
                    salaryUpdate.GradeId       = new Guid(txtGradeId.Text);
                    salaryUpdate.OccupationId  = new Guid(txtOccupationId.Text);

                    if (rbPercentage.Checked)
                    {
                        salaryUpdate.UpdateType = 1;
                    }
                    else if (rbValue.Checked)
                    {
                        salaryUpdate.UpdateType = 2;
                    }

                    salaryUpdate.MainSalary         = txtSalaryMain.Text == ""?0: decimal.Parse(txtSalaryMain.Text.Replace(".", ""));
                    salaryUpdate.LunchAllowance     = txtLunchAllowance.Text == ""?0:decimal.Parse(txtLunchAllowance.Text.Replace(".", ""));
                    salaryUpdate.TransportAllowance = txtTransportAllowance.Text == ""?0:decimal.Parse(txtTransportAllowance.Text.Replace(".", ""));
                    salaryUpdate.FuelAllowance      = txtFuelAllowance.Text == "" ? 0 : decimal.Parse(txtFuelAllowance.Text.Replace(".", ""));
                    salaryUpdate.VehicleAllowance   = txtVehicleAllowance.Text == ""?0:decimal.Parse(txtVehicleAllowance.Text.Replace(".", ""));
                    salaryUpdate.Notes = "";

                    salaryUpdateRepository.Save(salaryUpdate);

                    DisableForm();
                    LoadSalaryUpdate();
                    ClearForm();
                    formMode = FormMode.View;
                }
                else
                {
                    MessageBox.Show("Karyawan dengan kriteria tersebut tidak ditemukan", "Perhatian",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }