示例#1
0
        public bool UpdateTransaction(MadeToOrder order)
        {
            bool success = false;

            try
            {
                _conn.Open();

                //preparing statement
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection = _conn;

                string stmt = "UPDATE orders SET ";
                stmt += "customerid=?customerid,";
                //stmt += "date_of_order=?dateoforder,";
                stmt += "date_of_use=?dateofuse,";
                stmt += "date_of_pickup=?dateofpickup,";
                stmt += "purpose=?purpose,";
                stmt += "total_amount=?amount,";
                stmt += "downpayment=?downpayment,";
                stmt += "notes=?notes ";
                stmt += "WHERE ordernum=?ordernum;";

                cmd.CommandText = stmt;
                cmd.Prepare();

                //binding parameters
                cmd.Parameters.AddWithValue("?ordernum", order.TransactionId);
                cmd.Parameters.AddWithValue("?customerid", order.CustomerId);
                //cmd.Parameters.AddWithValue("?dateoforder", _dateOfOrder);
                cmd.Parameters.AddWithValue("?dateofuse", order.DateOfUse);
                cmd.Parameters.AddWithValue("?dateofpickup", order.DateOfPickUp);
                cmd.Parameters.AddWithValue("?purpose", order.Purpose);
                cmd.Parameters.AddWithValue("?amount", order.TotalAmount);
                cmd.Parameters.AddWithValue("?downpayment", order.Downpayment);
                cmd.Parameters.AddWithValue("?notes", order.Notes);

                cmd.ExecuteNonQuery();

                success = true;
                //MessageBox.Show("Updated Successfully!");
            }
            catch (MySqlException ex)
            {
                //Trace.WriteLine("Error: {0}", ex.ToString());
                //MessageBox.Show("Error occurred in updating the transaction.");
            }
            finally
            {
                _conn.Close();
            }
            return(success);
        }
示例#2
0
        public bool SaveTransaction(MadeToOrder order)
        {
            bool success = false;

            try
            {
                _conn.Open();

                //preparing statement
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection = _conn;

                string stmt = "INSERT INTO orders(refnum,customerid,date_of_order,date_of_use,date_of_pickup,purpose,total_amount,downpayment,notes) ";
                stmt += "VALUES(?referenceno,?customerid,?dateoforder,?dateofuse,?dateofpickup,?purpose,?amount,?downpayment,?notes);";

                cmd.CommandText = stmt;
                cmd.Prepare();

                //binding parameters
                cmd.Parameters.AddWithValue("?referenceno", order.ReferenceNo);
                cmd.Parameters.AddWithValue("?customerid", order.CustomerId);
                cmd.Parameters.AddWithValue("?dateoforder", order.DateOfOrder);
                cmd.Parameters.AddWithValue("?dateofuse", order.DateOfUse);
                cmd.Parameters.AddWithValue("?dateofpickup", order.DateOfPickUp);
                cmd.Parameters.AddWithValue("?purpose", order.Purpose);
                cmd.Parameters.AddWithValue("?amount", order.TotalAmount);
                cmd.Parameters.AddWithValue("?downpayment", order.Downpayment);
                cmd.Parameters.AddWithValue("?notes", order.Notes);

                cmd.ExecuteNonQuery();

                success = true;
                //MessageBox.Show("Order Transaction Saved!");
            }
            catch (MySqlException ex)
            {
                //Trace.WriteLine("Error: {0}", ex.ToString());
                //MessageBox.Show("Error occurred in saving the transaction.");
            }
            finally
            {
                _conn.Close();
            }
            return(success);
        }
示例#3
0
        public MadeToOrder GetInfoByRefNum(string referenceno)
        {
            MadeToOrder order = new MadeToOrder();

            try
            {
                _conn.Open();
                _dataAdapter = new MySqlDataAdapter("SELECT * from orders where refnum=?refnum;", _conn);
                _dataAdapter.SelectCommand.Parameters.AddWithValue("?refnum", referenceno);
                _dTable = new DataTable();
                _dataAdapter.Fill(_dTable);

                order.TransactionId = Int32.Parse(_dTable.Rows[0]["ordernum"].ToString());
                order.ReferenceNo   = _dTable.Rows[0]["refnum"].ToString();
                order.CustomerId    = Int32.Parse(_dTable.Rows[0]["customerid"].ToString());
                order.DateOfOrder   = DateTime.Parse(_dTable.Rows[0]["date_of_order"].ToString());
                order.DateOfUse     = DateTime.Parse(_dTable.Rows[0]["date_of_use"].ToString());
                order.DateOfPickUp  = DateTime.Parse(_dTable.Rows[0]["date_of_pickup"].ToString());
                order.Purpose       = _dTable.Rows[0]["purpose"].ToString();
                order.TotalAmount   = Double.Parse(_dTable.Rows[0]["total_amount"].ToString());
                order.Downpayment   = Double.Parse(_dTable.Rows[0]["downpayment"].ToString());
                order.Notes         = _dTable.Rows[0]["notes"].ToString();
            }


            catch (Exception e)
            {
                //MessageBox.Show("Order Transaction does not exist.");
                //Trace.WriteLine("Error:" + e.Message);
            }

            finally
            {
                _conn.Close();
            }

            return(order);
        }