Ejemplo n.º 1
0
        public void Update_Transaction(string tno, string bssn, string sssn, string pno, string ptype, DateTimePicker date, float price, float profit, string agent)
        {
            {
                SqlCommand Update_Transaction = SqlConnectionCommand.getCommand();
                Update_Transaction.CommandText = "USE srdb UPDATE TRANSACTIONS SET " +
                                                 "BSSN = @strbssn, SSSN = @strsssn, Pno = @strpno,PType = @strptype, Date = @strdate, Price = @floatprice, Profit = @floatprofit, AgentID = @stragent WHERE tnum = @strtno;";

                //addproperty.Parameters.AddWithValue("@strproperty", comboboxtype.SelectedText);

                Update_Transaction.Parameters.AddWithValue("@strtno", tno);
                Update_Transaction.Parameters.AddWithValue("@strbssn", bssn);
                Update_Transaction.Parameters.AddWithValue("@strsssn", sssn);
                Update_Transaction.Parameters.AddWithValue("@strpno", pno);
                Update_Transaction.Parameters.AddWithValue("@strptype", ptype);
                Update_Transaction.Parameters.AddWithValue("@strdate", dateTimePicker1.Value);
                Update_Transaction.Parameters.AddWithValue("@floatprice", price);
                Update_Transaction.Parameters.AddWithValue("@floatprofit", profit);
                Update_Transaction.Parameters.AddWithValue("@stragent", agent);
                MessageBox.Show(Update_Transaction.CommandText.ToString());
                try
                {
                    Update_Transaction.ExecuteNonQuery();
                    MessageBox.Show("Successfully Updated" + " " + tno + " " + date,
                                    "Updated Transaction", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    this.Hide();
                    SelectedTransaction select_trans = new SelectedTransaction();
                    select_trans.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(" Please make sure BSSN, SSSN, Property Number and Agent ID is valid ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    //MessageBox.Show(" Please Enter a Different PNO Number ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // MessageBox.Show("Failed to Update a transaction: " + ex.Message, "Update transaction Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }//end
                Updateowner(propertynum.Text, buyerssn.Text);
            }
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //String type = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();

            this.Hide();

            SelectedTransaction Transaction_page = new SelectedTransaction();

            Transaction_page.transnum.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
            Transaction_page.transdate.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
            Transaction_page.sssnselect.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
            Transaction_page.bssnselect.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
            Transaction_page.selectpno.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
            Transaction_page.selectptype.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
            Transaction_page.selectprofit.Text = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
            Transaction_page.selectprice.Text = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
            Transaction_page.agentid.Text = dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString();

            //  Seller_page.State.Text = dataGridViewBuyerSeller.Rows[e.RowIndex].Cells[9].Value.ToString();
            //  Seller_page.Zip.Text = dataGridViewBuyerSeller.Rows[e.RowIndex].Cells[10].Value.ToString();

            Transaction_page.Show();
            //this.Controls.Add(vScrollBar1);
        }