コード例 #1
0
        private void EnterInvestmentInfo(InvestmentInfo info)
        {
            try
            {
                int nps = 0;
                if (info.NPS)
                {
                    nps = 1;
                }
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    string query = lblAlreadyFilled.Visible

                        ? string.Format("UPDATE InvestmentInfo SET DOB = '{1}',Income = {2}, OtherIncome = {3}, Rent = {4}, EF = '{5}', NPS = {6}, Risk = '{7}' WHERE CustomerId = {0}",
                                        info.CustomerId, info.DOB, info.Income, info.OtherIncome, info.Rent, info.EF, nps, info.Risk)

                        : string.Format("INSERT INTO InvestmentInfo VALUES( {0}, '{1}', {2}, {3}, {4}, '{5}', {6}, '{7}')",
                                        info.CustomerId, info.DOB, info.Income, info.OtherIncome, info.Rent, info.EF, nps, info.Risk);

                    using (SqlCommand cmd = new SqlCommand(query, conn))
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
コード例 #2
0
        protected void btnUpdateInvestmentInfo_Click(object sender, EventArgs e)
        {
            InvestmentInfo cInfo = new InvestmentInfo();

            cInfo.CustomerId  = _customerId;
            cInfo.DOB         = txtDOB.Text;
            cInfo.Income      = Convert.ToDouble(txtAnnualIncome.Text);
            cInfo.OtherIncome = Convert.ToDouble(txtOtherIncome.Text);
            cInfo.Rent        = Convert.ToDouble(txtRentAmount.Text);

            cInfo.EF = string.Join(",", cbPF.Items.Cast <ListItem>()
                                   .Where(li => li.Selected)
                                   .ToList());

            cInfo.NPS  = rdNps.SelectedIndex == 1;
            cInfo.Risk = dpRisk.SelectedValue;

            this.EnterInvestmentInfo(cInfo);

            // Reload the page data
            this.RefreshData();
        }