Esempio n. 1
0
        private void txtClient_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            ClientListing lst = new ClientListing();

            lst.ShowDialog();

            using (SqlConnection conn = new SqlConnection(ClassDBUtils.DBConnString))
            {
                try
                {
                    conn.Open();

                    string strSQL = "select * from vwDealAllocations where clientno = '" + ClassGenLib.selectedClient + "' order by dealdate, id";

                    SqlCommand cmd = new SqlCommand(strSQL, conn);
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        DataTable dt = new DataTable();
                        da.Fill(dt);

                        grdTrades.DataSource = dt;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error connecting to database! Reason:- " + ex.Message, "Falcon20", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
            }
        }
Esempio n. 2
0
        private void txtClient_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            ClientListing lst = new ClientListing();

            lst.ShowDialog();

            using (SqlConnection conn = new SqlConnection(ClassDBUtils.DBConnString))
            {
                try
                {
                    conn.Open();

                    //string strSQL = "select distinct dealtype, dealdate, dealno, asset, qty, price, consideration, dealvalue, grosscommission, stampduty, vat, capitalgains, investorprotection, zselevy, commissionerlevy, csdlevy from vwDealAllocations where clientno = '" + ClassGenLib.selectedClient + "' order by dealdate";
                    string strSQL = "select * from vwDealAllocations where clientno = '" + ClassGenLib.selectedClient + "' order by dealdate, id";

                    SqlCommand cmd = new SqlCommand(strSQL, conn);
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        DataTable dt = new DataTable();
                        da.Fill(dt);

                        grdTrades.DataSource = dt;
                    }

                    cmd.CommandText = "select * from cashbooktrans where clientno = '" + ClassGenLib.selectedClient + "' order by transdate desc";
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        DataTable dt = new DataTable();

                        da.Fill(dt);

                        grdTransactions.DataSource = dt;
                    }

                    SqlCommand cmdPort = new SqlCommand("spGetClientPortfolio", conn);
                    cmdPort.CommandType = CommandType.StoredProcedure;
                    SqlParameter p1 = new SqlParameter("@clientno", ClassGenLib.selectedClient);
                    SqlParameter p2 = new SqlParameter("@user", ClassGenLib.username);
                    cmdPort.Parameters.Add(p1); cmdPort.Parameters.Add(p2);
                    cmdPort.ExecuteNonQuery();

                    strSQL  = "select x.asset, x.bought, x.sold, (x.bought-x.sold) as net, a.assetname ";
                    strSQL += " from tblClientPortfolio x inner join assets a on x.asset = a.assetcode where x.clientno = '" + ClassGenLib.selectedClient + "'";

                    using (SqlDataAdapter da = new SqlDataAdapter(strSQL, conn))
                    {
                        DataTable dt = new DataTable();
                        da.Fill(dt);

                        grdPortfolio.DataSource = dt;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error connecting to database! Reason:- " + ex.Message, "Falcon20", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
            }
        }