Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            CashTransaction add = new CashTransaction();

            add.addMoney(Convert.ToInt32(textBox1.Text), User_Details.UID);
            MyProfile_UserControl.Instance.showDetails(User_Details.UID);
            this.Close();
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            CashTransaction cash          = new CashTransaction();
            Boolean         moneyRecieved = cash.removeMoney(price, UIDMP);

            con.Open();
            try {
                if (MessageBox.Show($"Do you want to sell to user '{UID.Text}'??", "Message", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    String qry1 = $"DELETE FROM [Bids] WHERE PID={Property_Viewer.selectedPID}";
                    String qry2 = $"UPDATE [Property] SET UID='{UIDMP}',Availablity=0,AskPrice=0 WHERE PID={Property_Viewer.selectedPID} ";
                    String qry3 = $"INSERT INTO [Transaction] (customer_UID,owner_UID,PID,price,date) values " +
                                  $"({UIDMP},{User_Details.UID},{PIDMP},{price},@date)";
                    //need to refresh it after that
                    if (moneyRecieved)
                    {
                        cash.addMoney(price, User_Details.UID);
                    }
                    else
                    {
                        throw new Exception("User: "******" dosent has enough cash in wallet\n\n");
                    }
                    dr = new SqlCommand(qry1, con).ExecuteReader();
                    dr.Close();
                    dr = new SqlCommand(qry2, con).ExecuteReader();
                    dr.Close();

                    cmd = new SqlCommand(qry3, con);
                    cmd.Parameters.Add("@date", SqlDbType.Date).Value = DateTime.Today;
                    dr = cmd.ExecuteReader();
                    dr.Close();
                    dr.Close();;
                    MessageBox.Show("Transaction completed successfully");
                    MyProperties_UserControl.Instance.refreshDataGridView(User_Details.UID);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                if (moneyRecieved)
                {
                    cash.addMoney(price, UIDMP);
                }
            }
            con.Close();
        }
Beispiel #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            CashTransaction remove = new CashTransaction();

            if (textBox1.Text != "")
            {
                if (!remove.removeMoney(Convert.ToInt32(textBox1.Text), User_Details.UID))
                {
                    MessageBox.Show("You do not have the required balance");
                }
                MyProfile_UserControl.Instance.showDetails(User_Details.UID);
                this.Close();
            }
            else
            {
                MessageBox.Show("Field is empty");
            }
        }