Exemplo n.º 1
0
        public void Save(InsuranceProgram insuranceProgram)
        {
            try
            {
                using (var em = EntityManagerFactory.CreateInstance(ds))
                {
                    string[] columns = { "ID",                   "Program",                    "PercentageByCompany",
                                         "PercentageByEmployee", "PercentageByEmployeeFemale",
                                         "InsuranceId" };

                    object[] values = { Guid.NewGuid(),                        insuranceProgram.Program,
                                        insuranceProgram.PercentageByCompany,
                                        insuranceProgram.PercentageByEmployee, insuranceProgram.PercentageByEmployeeFemale,
                                        insuranceProgram.InsuranceId };

                    var q = new Query().Select(columns).From(tableName).Insert(values);

                    em.ExecuteNonQuery(q.ToSql());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        private void ViewInsuranceProgramDetail(InsuranceProgram insuranceProgram)
        {
            txtID.Text = insuranceProgram.ID.ToString();

            txtProgram.Text          = insuranceProgram.Program;
            txtByCompany.Text        = insuranceProgram.PercentageByCompany.ToString().Replace(".", ",");
            txtByEmployee.Text       = insuranceProgram.PercentageByEmployee.ToString().Replace(".", ",");
            txtByEmployeeFemale.Text = insuranceProgram.PercentageByEmployeeFemale.ToString().Replace(".", ",");
        }
Exemplo n.º 3
0
        private void RenderInsuranceProgram(InsuranceProgram insuranceProgram)
        {
            var item = new ListViewItem(insuranceProgram.ID.ToString());

            item.SubItems.Add(insuranceProgram.Program);
            item.SubItems.Add(insuranceProgram.PercentageByCompany.ToString());
            item.SubItems.Add(insuranceProgram.PercentageByEmployee.ToString());
            item.SubItems.Add(insuranceProgram.PercentageByEmployeeFemale.ToString());

            lvwData.Items.Add(item);
        }
Exemplo n.º 4
0
        public InsuranceProgram GetLast(Guid insuranceId)
        {
            InsuranceProgram insuranceProgram = null;

            using (var em = EntityManagerFactory.CreateInstance(ds))
            {
                var sql = "SELECT TOP 1 InsuranceProgram.ID, InsuranceProgram.Program, "
                          + "InsuranceProgram.PercentageByCompany, InsuranceProgram.PercentageByEmployee, InsuranceProgram.PercentageByEmployeeFemale,"
                          + "InsuranceProgram.InsuranceId, Insurance.InsuranceCode, Insurance.InsuranceName "
                          + "FROM InsuranceProgram INNER JOIN Insurance ON InsuranceProgram.InsuranceId = Insurance.ID "
                          + "WHERE InsuranceProgram.InsuranceId = '{" + insuranceId + "}'";

                insuranceProgram = em.ExecuteObject <InsuranceProgram>(sql, new InsuranceProgramMapper());
            }

            return(insuranceProgram);
        }
Exemplo n.º 5
0
        private void SaveInsuranceProgram()
        {
            if (txtProgram.Text == "")
            {
                MessageBox.Show("Program harus diisi", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtProgram.Focus();
            }
            else if (formMode == FormMode.Add && insuranceProgramRepository.IsInsuranceProgramExisted(txtProgram.Text, new Guid(txtInsuranceId.Text)))
            {
                MessageBox.Show("Program : " + txtProgram.Text + " sudah ada ", "Perhatian",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                var insuranceProgram = new InsuranceProgram();

                insuranceProgram.Program                    = txtProgram.Text;
                insuranceProgram.PercentageByCompany        = double.Parse(txtByCompany.Text == "" ? "0" : txtByCompany.Text.Replace(",", "."));
                insuranceProgram.PercentageByEmployee       = double.Parse(txtByEmployee.Text == "" ? "0" : txtByEmployee.Text.Replace(",", "."));
                insuranceProgram.PercentageByEmployeeFemale = double.Parse(txtByEmployeeFemale.Text == "" ? "0" : txtByEmployeeFemale.Text.Replace(",", "."));

                insuranceProgram.InsuranceId = new Guid(txtInsuranceId.Text);

                if (formMode == FormMode.Add)
                {
                    insuranceProgramRepository.Save(insuranceProgram);
                    GetLastInsuranceProgram(new Guid(txtInsuranceId.Text));
                }
                else if (formMode == FormMode.Edit)
                {
                    insuranceProgram.ID = new Guid(txtID.Text);
                    insuranceProgramRepository.Update(insuranceProgram);
                }

                LoadInsuranceProgram();
                DisableForm();

                formMode  = FormMode.View;
                this.Text = "Program " + txtInsurance.Text;
            }
        }